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[], lines: OrderLineInput[], handler: ConfigurableOperationInput) => Promise<Fulfillment | InvalidFulfillmentHandlerError | CreateFulfillmentError>;
  async getFulfillmentLines(ctx: RequestContext, id: ID) => Promise<FulfillmentLine[]>;
  async getFulfillmentsLinesForOrderLine(ctx: RequestContext, orderLineId: ID) => Promise<FulfillmentLine[]>;
  async transitionToState(ctx: RequestContext, fulfillmentId: ID, state: FulfillmentState) => Promise<
        | {
              fulfillment: Fulfillment;
              orders: Order[];
              fromState: FulfillmentState;
              toState: FulfillmentState;
          }
        | FulfillmentStateTransitionError
    >;
  getNextStates(fulfillment: Fulfillment) => readonly FulfillmentState[];
}

Members

constructor

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

create

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

getFulfillmentLines

method
type:
(ctx: RequestContext, id: ID) => Promise<FulfillmentLine[]>

getFulfillmentsLinesForOrderLine

method
type:
(ctx: RequestContext, orderLineId: ID) => Promise<FulfillmentLine[]>

transitionToState

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) => readonly FulfillmentState[]
Returns an array of the next valid states for the Fulfillment.