Interface: OrdersUpdateSupplier
This is the caller side of the contract.
Remarks
- The processUpdateRequest method converts the raw http request into an PatchOrdersRequest
- The PatchOrdersRequest is processed by the other system which returns the OrderDto for the patched order
- The provideUpdatedOrder method converts the OrderDto to a response that is suitable for the requesting system.
Methods
processUpdateRequest
▸ processUpdateRequest(request): Promise<{ fields?: [{ field?: string; operation?: PatchOperation.Remove; } | { field?: string ; operation?: Append ; value?: unknown } | { field?: string ; operation?: Set ; value?: unknown }, ...(({ field?: string; operation?: PatchOperation.Remove; }) | Object | Object)[]] ; filters?: [{ field?: string ; operation?: FilterOperation ; value?: unknown }, ...Object[]] }>
Handle the incoming request and transform it to a QueryOrdersRequest.
Parameters
| Name | Type | Description |
|---|---|---|
request | Object | The raw http request to process. |
request.body? | string | - |
request.headers? | Record<string, string> | - |
request.method? | string | - |
request.url? | string | - |
Returns
Promise<{ fields?: [{ field?: string; operation?: PatchOperation.Remove; } | { field?: string ; operation?: Append ; value?: unknown } | { field?: string ; operation?: Set ; value?: unknown }, ...(({ field?: string; operation?: PatchOperation.Remove; }) | Object | Object)[]] ; filters?: [{ field?: string ; operation?: FilterOperation ; value?: unknown }, ...Object[]] }>
The PatchOrdersRequest
Example
Raw http request:
POST /order_id=1234
Content-Type: application/json
{
"state": 1,
"customer_update": {
"name": "John"
}
}
PatchOrdersRequest:
{
filters: [
{field: 'id', operation: FilterOperation.Equal, value: enforce<OrderDto["id"]>('1234')}
],
fields: [
{field: 'status', operation: PatchOperation.Set, value: enforce<OrderDto["status"]>('PROCESSING')},
{field: 'deliveryAddress.firstName', operation: PatchOperation.Set, value: enforce<AddressDto["firstName"]>('John')},
{field: 'invoiceAddress.firstName', operation: PatchOperation.Set, value: enforce<AddressDto["firstName"]>('John')},
],
}
Defined in
src/contracts/patch-orders/handler/orders-update-supplier.ts:50
provideUpdatedOrders
▸ provideUpdatedOrders(orders): Promise<{ body?: string ; headers?: Record<string, string> ; statusCode?: number }>
Convert the updated orders to valid http response.
Parameters
| Name | Type | Description |
|---|---|---|
orders | { attributeValues?: Record<string, unknown> = ZAttributeValues; customer?: { id?: string; mailAddress?: string; phoneNumber?: string; vatId?: string; attributeValues?: Record<string, unknown>; } ; deliveryAddress?: { id?: string; company?: string; firstName?: string; surname?: string; line2?: string; street?: string; houseNumber?: string; zipCode?: string; city?: string; countryCode?: string; state?: string; attributeValues?: Record<...>; } ; id?: string ; invoiceAddress?: { id?: string; company?: string; firstName?: string; surname?: string; line2?: string; street?: string; houseNumber?: string; zipCode?: string; city?: string; countryCode?: string; state?: string; attributeValues?: Record<...>; } ; items?: { id?: string; name?: string; description?: string; sku?: string; amount?: number; singleNetPrice?: { value?: number; divisor?: number; currencyCode?: string; }; singleGrossPrice?: { value?: number; divisor?: number; currencyCode?: string; }; taxRate?: number; attributeValues?: Record<...>; }[] ; orderDate?: string = ZDateTimeString; orderNumber?: string ; paymentStatus?: "OPEN" | "IN_PROGRESS" | "PARTIALLY_PAID" | "PAID" | "PARTIALLY_REFUNDED" | "REFUNDED" = ZPaymentStatus; shipments?: { id?: string; date?: string; sourceCountryCode?: string; method?: string; netPrice?: { value?: number; divisor?: number; currencyCode?: string; }; grossPrice?: { value?: number; divisor?: number; currencyCode?: string; }; taxRate?: number; attributeValues?: Record<...>; }[] ; status?: "OPEN" | "CONFIRMED" | "PROCESSING" | "CANCELED" | "COMPLETED" = ZOrderStatus; transactions?: { id?: string; date?: string; type?: "PAYMENT" | "REFUND"; method?: string; amount?: { value?: number; divisor?: number; currencyCode?: string; }; attributeValues?: Record<string, unknown>; }[] }[] | The updated orders. |
Returns
Promise<{ body?: string ; headers?: Record<string, string> ; statusCode?: number }>
Defined in
src/contracts/patch-orders/handler/orders-update-supplier.ts:57