Interface: OrdersUpdateConsumer
Implement this interface for APIs that can receive order updates.
Methods
updateOrders
▸ updateOrders(request): Promise<{ 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>; }[] }[]>
Updates a set of orders.
Parameters
| Name | Type | Description |
|---|---|---|
request | Object | The request that contain details for patching orders |
request.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)[]] | - |
request.filters? | [{ field?: string ; operation?: FilterOperation ; value?: unknown }, ...Object[]] | - |
Returns
Promise<{ 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 list of patched orders
Remarks
The request contain filters. All orders that match against all filters are updated.
Example
Request:
{
filters: [
{field: 'status', operation: FilterOperation.Equal, value: 'OPEN'}
{field: 'customer.vatId', operation: FilterOperation.NotEqual, value: ''}
],
fields: [
{field: 'customer.vatId', operation: PatchOperation.Remove}
]
}
This request will remove the vatId of the customer in orders (fields) that match against these filters:
- Filter 1: status == 'OPEN'
AND
- Filter 2: vatId != ''
If the data in the external system contains:
| Order # | Status | Customer VatId. |
| ------- | --------- | --------------- |
| ORD#1 | OPEN | |
| ORD#2 | OPEN | DE123456789 |
| ORD#3 | COMPLETED | |
| ORD#4 | COMPLETED | DE123456789 |
| ORD#5 | OPEN | DE987654321 |
The request would match against ORD#2 and ORD#5
But NOT against:
- ORD#1 because VatId. is empty
- ORD#3 because status != 'OPEN' and VatId. is empty
- ORD#4 because status != 'OPEN'
Defined in
src/contracts/patch-orders/handler/orders-update-consumer.ts:60