🚨 Announcement: A New Chapter for Vendure read more

FulfillmentService

FulfillmentService

Contains methods relating to Fulfillment entities.

Signature

class FulfillmentService {
  constructor(connection: TransactionalConnection, fulfillmentStateMachine: FulfillmentStateMachine, eventBus: EventBus, configService: ConfigService, customFieldRelationService: CustomFieldRelationService)
  async create(ctx: RequestContext, orders: Order[], items: OrderItem[], handler: ConfigurableOperationInput) => Promise<Fulfillment | InvalidFulfillmentHandlerError | CreateFulfillmentError>;
  async getOrderItemsByFulfillmentId(ctx: RequestContext, id: ID) => Promise<OrderItem[]>;
  async getFulfillmentLineSummary(ctx: RequestContext, id: ID) => Promise<Array<{ orderLine: OrderLine; quantity: number }>>;
  async getFulfillmentsByOrderLineId(ctx: RequestContext, orderLineId: ID) => Promise<Array<{ fulfillment: Fulfillment; orderItemIds: Set<ID> }>>;
  async getFulfillmentByOrderItemId(ctx: RequestContext, orderItemId: ID) => Promise<Fulfillment | undefined>;
  async transitionToState(ctx: RequestContext, fulfillmentId: ID, state: FulfillmentState) => Promise<
        | {
              fulfillment: Fulfillment;
              orders: Order[];
              fromState: FulfillmentState;
              toState: FulfillmentState;
          }
        | FulfillmentStateTransitionError
    >;
  getNextStates(fulfillment: Fulfillment) => ReadonlyArray<FulfillmentState>;
}

Members

constructor

method
type:
(connection: TransactionalConnection, fulfillmentStateMachine: FulfillmentStateMachine, eventBus: EventBus, configService: ConfigService, customFieldRelationService: CustomFieldRelationService) => FulfillmentService

create

async method
type:
(ctx: RequestContext, orders: Order[], items: OrderItem[], handler: ConfigurableOperationInput) => Promise<Fulfillment | InvalidFulfillmentHandlerError | CreateFulfillmentError>
Creates a new Fulfillment for the given Orders and OrderItems, using the specified FulfillmentHandler.

getOrderItemsByFulfillmentId

async method
type:
(ctx: RequestContext, id: ID) => Promise<OrderItem[]>
Returns all OrderItems associated with the specified Fulfillment.

getFulfillmentLineSummary

async method
type:
(ctx: RequestContext, id: ID) => Promise<Array<{ orderLine: OrderLine; quantity: number }>>

getFulfillmentsByOrderLineId

async method
type:
(ctx: RequestContext, orderLineId: ID) => Promise<Array<{ fulfillment: Fulfillment; orderItemIds: Set<ID> }>>

getFulfillmentByOrderItemId

async method
type:
(ctx: RequestContext, orderItemId: ID) => Promise<Fulfillment | undefined>
Returns the Fulfillment for the given OrderItem (if one exists).

transitionToState

async method
type:
(ctx: RequestContext, fulfillmentId: ID, state: FulfillmentState) => Promise< | { fulfillment: Fulfillment; orders: Order[]; fromState: FulfillmentState; toState: FulfillmentState; } | FulfillmentStateTransitionError >
Transitions the specified Fulfillment to a new state and upon successful transition publishes a FulfillmentStateTransitionEvent.

getNextStates

method
type:
(fulfillment: Fulfillment) => ReadonlyArray<FulfillmentState>
Returns an array of the next valid states for the Fulfillment.