Skip to main content

FulfillmentService

FulfillmentService

Contains methods relating to Fulfillment entities.

Signature
class FulfillmentService {
constructor(connection: TransactionalConnection, fulfillmentStateMachine: FulfillmentStateMachine, eventBus: EventBus, configService: ConfigService, customFieldRelationService: CustomFieldRelationService)
create(ctx: RequestContext, orders: Order[], lines: OrderLineInput[], handler: ConfigurableOperationInput) => Promise<Fulfillment | InvalidFulfillmentHandlerError | CreateFulfillmentError>;
getFulfillmentLines(ctx: RequestContext, id: ID) => Promise<FulfillmentLine[]>;
getFulfillmentsLinesForOrderLine(ctx: RequestContext, orderLineId: ID, relations: RelationPaths<FulfillmentLine> = []) => Promise<FulfillmentLine[]>;
transitionToState(ctx: RequestContext, fulfillmentId: ID, state: FulfillmentState) => Promise<
| {
fulfillment: Fulfillment;
orders: Order[];
fromState: FulfillmentState;
toState: FulfillmentState;
}
| FulfillmentStateTransitionError
>;
getNextStates(fulfillment: Fulfillment) => readonly FulfillmentState[];
}

constructor

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

create

method
(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
(ctx: RequestContext, id: ID) => Promise<FulfillmentLine[]>

getFulfillmentsLinesForOrderLine

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

transitionToState

method
(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
(fulfillment: Fulfillment) => readonly FulfillmentState[]

Returns an array of the next valid states for the Fulfillment.