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 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.

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.