@deliverart/sdk-js-order 2.11.1 → 2.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +372 -396
- package/dist/index.cjs +215 -34
- package/dist/index.d.cts +5748 -301
- package/dist/index.d.ts +5748 -301
- package/dist/index.js +15218 -3
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -14,510 +14,486 @@ pnpm add @deliverart/sdk-js-order @deliverart/sdk-js-core
|
|
|
14
14
|
|
|
15
15
|
### Core Types
|
|
16
16
|
|
|
17
|
-
#### OrderType
|
|
18
|
-
```typescript
|
|
19
|
-
type OrderType = 'delivery' | 'take_away' | 'kitchen'
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
#### OrderStatus
|
|
23
17
|
```typescript
|
|
18
|
+
type OrderType = 'delivery' | 'collection' | 'kitchen'
|
|
24
19
|
type OrderStatus = 'pending' | 'confirmed' | 'rejected'
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
#### OrderPreparationStatus
|
|
28
|
-
```typescript
|
|
29
20
|
type OrderPreparationStatus = 'to_prepare' | 'in_preparation' | 'done'
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
#### OrderSource
|
|
33
|
-
```typescript
|
|
34
21
|
type OrderSource = 'application' | 'ecommerce' | 'partner'
|
|
22
|
+
type OrderPlanningMode = 'PLANNED' | 'FORCED'
|
|
35
23
|
```
|
|
36
24
|
|
|
37
25
|
### Models
|
|
38
26
|
|
|
39
|
-
|
|
40
|
-
- `
|
|
41
|
-
- `
|
|
42
|
-
- `
|
|
43
|
-
- `
|
|
44
|
-
- `
|
|
45
|
-
- `
|
|
46
|
-
- `
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
27
|
+
- `Order`
|
|
28
|
+
- `OrderDetails`
|
|
29
|
+
- `DeliveryOrder`
|
|
30
|
+
- `CollectionOrder`
|
|
31
|
+
- `TakeAwayOrder` (deprecated alias)
|
|
32
|
+
- `KitchenOrder`
|
|
33
|
+
- `DeliveryOrderDetails`
|
|
34
|
+
- `CollectionOrderDetails`
|
|
35
|
+
- `TakeAwayOrderDetails` (deprecated alias)
|
|
36
|
+
- `KitchenOrderDetails`
|
|
37
|
+
- `WritableOrder`
|
|
38
|
+
- `WritableUpdateOrder`
|
|
39
|
+
- `OrderMenuItem`
|
|
40
|
+
- `OrderMenuItemDetails`
|
|
41
|
+
- `OrderMenuItemModifier`
|
|
42
|
+
- `OrderMenuItemModifierDetails`
|
|
43
|
+
- `Bundle`
|
|
44
|
+
- `BundleDetails`
|
|
45
|
+
- `WritableBundle`
|
|
46
|
+
- `FeeSimulation`
|
|
47
|
+
- `OrderRescheduleWindow`
|
|
48
|
+
- `OrderRescheduleOption`
|
|
49
|
+
- `OrderRescheduleReferenceBundle`
|
|
50
|
+
|
|
51
|
+
## Typed Inputs and Outputs
|
|
52
|
+
|
|
53
|
+
`Order` and `OrderDetails` are discriminated by `type`.
|
|
54
|
+
|
|
55
|
+
- `delivery` orders expose delivery-specific fields like `address`, `requestedDeliveryTime`, `finalDeliveryTime`, `deliveryStartedAt`, `deliveredAt`
|
|
56
|
+
- `collection` orders expose collection-specific fields like `requestedCollectionTime`, `finalCollectionTime`, `collectedAt`
|
|
57
|
+
- `kitchen` orders exclude both delivery and collection scheduling fields
|
|
58
|
+
- all order read models also expose scheduling metadata such as `scheduledWindowStart`, `scheduledWindowEnd`, `schedulingVersion` and `planningMode`
|
|
59
|
+
- delivery read models additionally expose `estimatedRouteDurationSeconds`, `estimatedRouteDistanceMeters` and `stopSequence`
|
|
60
|
+
|
|
61
|
+
`CreateOrderInput` and `CalculateOrderFeesInput` are also discriminated by `type`.
|
|
62
|
+
|
|
63
|
+
- `delivery` accepts fields such as `address`, `customerAddress`, `locationData`, `referenceBundle`, `deliveryTime`
|
|
64
|
+
- `collection` accepts `collectionTime`
|
|
65
|
+
- the legacy alias `take_away` is still accepted on write for backward compatibility
|
|
66
|
+
- `kitchen` does not accept delivery or collection scheduling fields
|
|
67
|
+
- all writable order inputs also accept `forceScheduling?: boolean` for internal operator-only retries that bypass slot/capacity validation
|
|
68
|
+
|
|
69
|
+
`UpdateOrderInput` keeps common editable fields and enforces mutually exclusive delivery / collection scheduling fields.
|
|
70
|
+
|
|
71
|
+
## Order Requests
|
|
72
|
+
|
|
73
|
+
### CreateOrder
|
|
54
74
|
|
|
55
75
|
```typescript
|
|
56
|
-
import { CreateOrder } from '@deliverart/sdk-js-order'
|
|
57
|
-
|
|
58
|
-
const order = await sdk.call(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
vat: 'IT12345678901',
|
|
73
|
-
taxCode: 'RSSMRA80A01H501U',
|
|
74
|
-
billingAddress: {
|
|
75
|
-
street: 'Via Fatturazione 10',
|
|
76
|
+
import { CreateOrder } from '@deliverart/sdk-js-order'
|
|
77
|
+
|
|
78
|
+
const order = await sdk.call(
|
|
79
|
+
new CreateOrder({
|
|
80
|
+
type: 'delivery',
|
|
81
|
+
source: 'application',
|
|
82
|
+
pointOfSale: '/point_of_sales/123e4567-e89b-12d3-a456-426614174000',
|
|
83
|
+
customer: '/customers/123e4567-e89b-12d3-a456-426614174001',
|
|
84
|
+
customerInfo: {
|
|
85
|
+
firstName: 'John',
|
|
86
|
+
lastName: 'Doe',
|
|
87
|
+
email: 'john@example.com',
|
|
88
|
+
phoneNumber: '+39123456789',
|
|
89
|
+
},
|
|
90
|
+
address: {
|
|
91
|
+
line1: 'Via Roma 1',
|
|
76
92
|
city: 'Milano',
|
|
77
93
|
postalCode: '20100',
|
|
78
|
-
country: 'IT'
|
|
94
|
+
country: 'IT',
|
|
79
95
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
items: [
|
|
96
|
-
{
|
|
97
|
-
menuItem: '/menu_items/1',
|
|
98
|
-
quantity: 2,
|
|
99
|
-
price: 1500, // In cents
|
|
100
|
-
modifiers: [
|
|
101
|
-
{
|
|
102
|
-
menuItemModifier: '/menu_item_modifiers/1',
|
|
103
|
-
quantity: 1,
|
|
104
|
-
price: 200
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
}
|
|
108
|
-
],
|
|
109
|
-
deliveryTime: '2024-12-25T19:30:00+00:00',
|
|
110
|
-
notes: 'Please ring the bell'
|
|
111
|
-
}));
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**Input Parameters:**
|
|
115
|
-
- `type: OrderType` (required) - Order type
|
|
116
|
-
- `source: OrderSource` (required) - Order source
|
|
117
|
-
- `pointOfSale: string` (required) - Point of sale IRI
|
|
118
|
-
- `salesMode: string` (optional) - Sales mode IRI
|
|
119
|
-
- `customer: string` (optional) - Customer IRI
|
|
120
|
-
- `customerBusinessProfile: string` (optional) - Business profile IRI
|
|
121
|
-
- `customerInfo: OrderCustomerInfo` (optional) - Customer contact info
|
|
122
|
-
- `billingInfo: OrderBillingInfo` (optional) - Billing information (includes businessName, vat, taxCode, billingAddress, billingData)
|
|
123
|
-
- `address: Address` (optional) - Delivery/collection address
|
|
124
|
-
- `items: OrderMenuItem[]` (required) - Order items
|
|
125
|
-
- `deliveryTime: string` (optional) - Requested delivery time (ISO 8601)
|
|
126
|
-
- `collectionTime: string` (optional) - Requested collection time (ISO 8601)
|
|
127
|
-
- `preparationTime: string` (optional) - Preparation time (ISO 8601)
|
|
128
|
-
- `discount: string` (optional) - Discount amount in cents
|
|
129
|
-
- `notes: string` (optional) - General notes
|
|
130
|
-
- `deliveryNotes: string` (optional) - Delivery notes
|
|
131
|
-
- `kitchenNotes: string` (optional) - Kitchen notes
|
|
132
|
-
- `autoAccept: boolean` (optional) - Auto-accept order
|
|
133
|
-
- `partner: string` (optional) - Partner identifier
|
|
134
|
-
- `partnerIdentifier: string` (optional) - External partner order ID
|
|
135
|
-
- `displayId: string` (optional) - Custom display ID
|
|
136
|
-
|
|
137
|
-
**Response:** `OrderDetails`
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
#### GetOrders
|
|
142
|
-
Get paginated list of orders with filters.
|
|
143
|
-
|
|
144
|
-
```typescript
|
|
145
|
-
import { GetOrders } from '@deliverart/sdk-js-order';
|
|
146
|
-
|
|
147
|
-
const orders = await sdk.call(new GetOrders({
|
|
148
|
-
query: {
|
|
149
|
-
'status[]': ['pending', 'confirmed'],
|
|
150
|
-
'type[]': ['delivery'],
|
|
151
|
-
pointOfSale: '/point_of_sales/123',
|
|
152
|
-
'order[createdAt]': 'desc',
|
|
153
|
-
page: 1
|
|
154
|
-
}
|
|
155
|
-
}));
|
|
96
|
+
deliveryTime: '2026-03-22T19:30:00+01:00',
|
|
97
|
+
items: [
|
|
98
|
+
{
|
|
99
|
+
menuItem: '/menu_items/123e4567-e89b-12d3-a456-426614174002',
|
|
100
|
+
salesMode: null,
|
|
101
|
+
variant: null,
|
|
102
|
+
quantity: 2,
|
|
103
|
+
notes: 'No onions',
|
|
104
|
+
removals: [],
|
|
105
|
+
modifiers: [],
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
}),
|
|
109
|
+
)
|
|
156
110
|
```
|
|
157
111
|
|
|
158
|
-
|
|
159
|
-
- `status[]?: OrderStatus[]` - Filter by statuses
|
|
160
|
-
- `type[]?: OrderType[]` - Filter by types
|
|
161
|
-
- `pointOfSale?: string` - Filter by point of sale IRI
|
|
162
|
-
- `customer?: string` - Filter by customer IRI
|
|
163
|
-
- `createdAt[before]?: string` - Created before date
|
|
164
|
-
- `createdAt[after]?: string` - Created after date
|
|
165
|
-
- `order[createdAt]?: 'asc' | 'desc'` - Sort by creation date
|
|
166
|
-
- `order[deliveryTime]?: 'asc' | 'desc'` - Sort by delivery time
|
|
167
|
-
- `page?: number` - Page number
|
|
112
|
+
Response: `OrderDetails`
|
|
168
113
|
|
|
169
|
-
|
|
114
|
+
Useful response fields after create/update
|
|
115
|
+
- `scheduledWindowStart`
|
|
116
|
+
- `scheduledWindowEnd`
|
|
117
|
+
- `planningMode`
|
|
118
|
+
- `schedulingVersion`
|
|
119
|
+
- for `delivery`: `estimatedRouteDurationSeconds`, `estimatedRouteDistanceMeters`, `stopSequence`
|
|
170
120
|
|
|
171
|
-
|
|
121
|
+
`planningMode` can be:
|
|
122
|
+
- `PLANNED`
|
|
123
|
+
- `FORCED`
|
|
172
124
|
|
|
173
|
-
|
|
174
|
-
Get detailed information about a specific order.
|
|
125
|
+
### CalculateOrderFees
|
|
175
126
|
|
|
176
127
|
```typescript
|
|
177
|
-
import {
|
|
128
|
+
import { CalculateOrderFees } from '@deliverart/sdk-js-order'
|
|
178
129
|
|
|
179
|
-
const
|
|
130
|
+
const fees = await sdk.call(
|
|
131
|
+
new CalculateOrderFees({
|
|
132
|
+
type: 'collection',
|
|
133
|
+
source: 'application',
|
|
134
|
+
pointOfSale: '/point_of_sales/123e4567-e89b-12d3-a456-426614174000',
|
|
135
|
+
collectionTime: '2026-03-22T20:00:00+01:00',
|
|
136
|
+
items: [
|
|
137
|
+
{
|
|
138
|
+
menuItem: '/menu_items/123e4567-e89b-12d3-a456-426614174002',
|
|
139
|
+
salesMode: null,
|
|
140
|
+
variant: null,
|
|
141
|
+
quantity: 1,
|
|
142
|
+
notes: null,
|
|
143
|
+
removals: [],
|
|
144
|
+
modifiers: [],
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
}),
|
|
148
|
+
)
|
|
180
149
|
```
|
|
181
150
|
|
|
182
|
-
|
|
183
|
-
- `orderId: string` (required)
|
|
151
|
+
Response: `FeeSimulation`
|
|
184
152
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
#### GetPointOfSaleOrders
|
|
190
|
-
Get orders for a specific point of sale.
|
|
153
|
+
### GetOrders
|
|
191
154
|
|
|
192
155
|
```typescript
|
|
193
|
-
import {
|
|
194
|
-
|
|
195
|
-
const orders = await sdk.call(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
156
|
+
import { GetOrders } from '@deliverart/sdk-js-order'
|
|
157
|
+
|
|
158
|
+
const orders = await sdk.call(
|
|
159
|
+
new GetOrders({
|
|
160
|
+
query: {
|
|
161
|
+
type: ['delivery', 'collection'],
|
|
162
|
+
status: ['pending', 'confirmed'],
|
|
163
|
+
preparationStatus: 'to_prepare',
|
|
164
|
+
'order[createdAt]': 'desc',
|
|
165
|
+
page: 1,
|
|
166
|
+
},
|
|
167
|
+
}),
|
|
168
|
+
)
|
|
201
169
|
```
|
|
202
170
|
|
|
203
|
-
|
|
204
|
-
- `
|
|
205
|
-
- `
|
|
171
|
+
Main query params
|
|
172
|
+
- `type?: OrderType | OrderType[]`
|
|
173
|
+
- `source?: OrderSource | OrderSource[]`
|
|
174
|
+
- `status?: OrderStatus | OrderStatus[]`
|
|
175
|
+
- `preparationStatus?: OrderPreparationStatus | OrderPreparationStatus[]`
|
|
176
|
+
- `paymentMethod?: PaymentMethod | PaymentMethod[]`
|
|
177
|
+
- `paymentStatus?: PaymentStatus | PaymentStatus[]`
|
|
178
|
+
- `partner?: OrderPartner | OrderPartner[]`
|
|
179
|
+
- `partnerIdentifier?: string | string[]`
|
|
180
|
+
- `isRead?: boolean`
|
|
181
|
+
- `exists[acceptedAt]?: boolean`
|
|
182
|
+
- `exists[preparationEndedAt]?: boolean`
|
|
183
|
+
- `exists[collectedAt]?: boolean`
|
|
184
|
+
- `exists[deliveredAt]?: boolean`
|
|
185
|
+
- `page?: number`
|
|
186
|
+
|
|
187
|
+
Response: `Paginated<Order>`
|
|
188
|
+
|
|
189
|
+
### GetOrderDetails
|
|
206
190
|
|
|
207
|
-
|
|
191
|
+
```typescript
|
|
192
|
+
import { GetOrderDetails } from '@deliverart/sdk-js-order'
|
|
208
193
|
|
|
209
|
-
|
|
194
|
+
const order = await sdk.call(new GetOrderDetails('123e4567-e89b-12d3-a456-426614174003'))
|
|
195
|
+
```
|
|
210
196
|
|
|
211
|
-
|
|
212
|
-
|
|
197
|
+
Response: `OrderDetails`
|
|
198
|
+
|
|
199
|
+
### GetPointOfSaleOrders
|
|
213
200
|
|
|
214
201
|
```typescript
|
|
215
|
-
import {
|
|
202
|
+
import { GetPointOfSaleOrders } from '@deliverart/sdk-js-order'
|
|
216
203
|
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
204
|
+
const orders = await sdk.call(
|
|
205
|
+
new GetPointOfSaleOrders('123e4567-e89b-12d3-a456-426614174000', {
|
|
206
|
+
query: {
|
|
207
|
+
status: 'pending',
|
|
208
|
+
page: 1,
|
|
209
|
+
},
|
|
210
|
+
}),
|
|
211
|
+
)
|
|
221
212
|
```
|
|
222
213
|
|
|
223
|
-
|
|
224
|
-
- `orderId: string` (required)
|
|
225
|
-
- `input: Partial<OrderInput>` (required) - Fields to update
|
|
214
|
+
Response: `Paginated<Order>`
|
|
226
215
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
---
|
|
230
|
-
|
|
231
|
-
#### ConfirmOrder
|
|
232
|
-
Confirm a pending order.
|
|
216
|
+
### GetCustomerOrders
|
|
233
217
|
|
|
234
218
|
```typescript
|
|
235
|
-
import {
|
|
219
|
+
import { GetCustomerOrders } from '@deliverart/sdk-js-order'
|
|
236
220
|
|
|
237
|
-
const
|
|
221
|
+
const orders = await sdk.call(
|
|
222
|
+
new GetCustomerOrders('123e4567-e89b-12d3-a456-426614174001', {
|
|
223
|
+
query: {
|
|
224
|
+
status: 'confirmed',
|
|
225
|
+
page: 1,
|
|
226
|
+
},
|
|
227
|
+
}),
|
|
228
|
+
)
|
|
238
229
|
```
|
|
239
230
|
|
|
240
|
-
|
|
241
|
-
- `orderId: string` (required)
|
|
231
|
+
Response: `Paginated<Order>`
|
|
242
232
|
|
|
243
|
-
|
|
233
|
+
### UpdateOrder
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
import { UpdateOrder } from '@deliverart/sdk-js-order'
|
|
237
|
+
|
|
238
|
+
const updated = await sdk.call(
|
|
239
|
+
new UpdateOrder('123e4567-e89b-12d3-a456-426614174003', {
|
|
240
|
+
notes: 'Updated notes',
|
|
241
|
+
deliveryTime: '2026-03-22T20:15:00+01:00',
|
|
242
|
+
}),
|
|
243
|
+
)
|
|
244
|
+
```
|
|
244
245
|
|
|
245
|
-
|
|
246
|
+
Response: `OrderDetails`
|
|
246
247
|
|
|
247
|
-
|
|
248
|
-
Reject a pending order.
|
|
248
|
+
### GetOrderRescheduleOptions
|
|
249
249
|
|
|
250
250
|
```typescript
|
|
251
|
-
import {
|
|
251
|
+
import { GetOrderRescheduleOptions } from '@deliverart/sdk-js-order'
|
|
252
252
|
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
253
|
+
const windows = await sdk.call(
|
|
254
|
+
new GetOrderRescheduleOptions('123e4567-e89b-12d3-a456-426614174003', {
|
|
255
|
+
query: {
|
|
256
|
+
date: '2026-03-22',
|
|
257
|
+
includeInvalid: true,
|
|
258
|
+
},
|
|
259
|
+
}),
|
|
260
|
+
)
|
|
256
261
|
```
|
|
257
262
|
|
|
258
|
-
|
|
259
|
-
- `
|
|
260
|
-
- `
|
|
263
|
+
Query params
|
|
264
|
+
- `date?: string`
|
|
265
|
+
- `searchFrom?: string`
|
|
266
|
+
- `includeInvalid?: boolean`
|
|
261
267
|
|
|
262
|
-
|
|
268
|
+
Response: `OrderRescheduleWindow[]`
|
|
263
269
|
|
|
264
|
-
|
|
270
|
+
Each option contains:
|
|
271
|
+
- `scheduledAt`
|
|
272
|
+
- `rangeStart`
|
|
273
|
+
- `rangeEnd`
|
|
274
|
+
- `status`
|
|
275
|
+
- `available`
|
|
276
|
+
- `invalidReason`
|
|
277
|
+
- `referenceBundles`
|
|
265
278
|
|
|
266
|
-
|
|
267
|
-
|
|
279
|
+
`status` can be:
|
|
280
|
+
- `keep_current_bundle`
|
|
281
|
+
- `create_new_bundle`
|
|
282
|
+
- `move_to_reference_bundle`
|
|
283
|
+
- `unavailable`
|
|
268
284
|
|
|
269
|
-
|
|
270
|
-
|
|
285
|
+
`invalidReason` can be:
|
|
286
|
+
- `store_closed`
|
|
287
|
+
- `no_capacity`
|
|
288
|
+
- `outside_lead_time`
|
|
289
|
+
- `journey_outside_window`
|
|
271
290
|
|
|
272
|
-
|
|
273
|
-
```
|
|
291
|
+
### Lifecycle and Payment Requests
|
|
274
292
|
|
|
275
|
-
|
|
276
|
-
|
|
293
|
+
```typescript
|
|
294
|
+
import {
|
|
295
|
+
AdvanceOrderPreparationStatus,
|
|
296
|
+
ConfirmOrder,
|
|
297
|
+
MarkOrderAsCollected,
|
|
298
|
+
MarkOrderAsRead,
|
|
299
|
+
PayOrder,
|
|
300
|
+
RejectOrder,
|
|
301
|
+
} from '@deliverart/sdk-js-order'
|
|
302
|
+
|
|
303
|
+
await sdk.call(new ConfirmOrder('123e4567-e89b-12d3-a456-426614174003'))
|
|
304
|
+
await sdk.call(new AdvanceOrderPreparationStatus('123e4567-e89b-12d3-a456-426614174003'))
|
|
305
|
+
await sdk.call(new MarkOrderAsRead('123e4567-e89b-12d3-a456-426614174003'))
|
|
306
|
+
await sdk.call(new MarkOrderAsCollected('123e4567-e89b-12d3-a456-426614174003'))
|
|
307
|
+
await sdk.call(new RejectOrder('123e4567-e89b-12d3-a456-426614174003'))
|
|
308
|
+
await sdk.call(new PayOrder('123e4567-e89b-12d3-a456-426614174003', 'cash'))
|
|
309
|
+
```
|
|
277
310
|
|
|
278
|
-
|
|
311
|
+
Available requests
|
|
312
|
+
- `ConfirmOrder`
|
|
313
|
+
- `RejectOrder`
|
|
314
|
+
- `AdvanceOrderPreparationStatus`
|
|
315
|
+
- `MarkOrderAsRead`
|
|
316
|
+
- `MarkOrderAsCollected`
|
|
317
|
+
- `PayOrder`
|
|
318
|
+
- `DeleteOrder`
|
|
319
|
+
- `GetOrderRescheduleOptions`
|
|
320
|
+
- `GenerateOrderBundle`
|
|
279
321
|
|
|
280
|
-
|
|
322
|
+
## Order Menu Items
|
|
281
323
|
|
|
282
|
-
|
|
283
|
-
Mark an order as read.
|
|
324
|
+
### GetOrderMenuItems
|
|
284
325
|
|
|
285
326
|
```typescript
|
|
286
|
-
import {
|
|
327
|
+
import { GetOrderMenuItems } from '@deliverart/sdk-js-order'
|
|
287
328
|
|
|
288
|
-
await sdk.call(
|
|
329
|
+
const items = await sdk.call(
|
|
330
|
+
new GetOrderMenuItems({
|
|
331
|
+
query: {
|
|
332
|
+
type: ['ITEM', 'BUNDLE'],
|
|
333
|
+
action: 'add',
|
|
334
|
+
'order[createdAt]': 'desc',
|
|
335
|
+
page: 1,
|
|
336
|
+
},
|
|
337
|
+
}),
|
|
338
|
+
)
|
|
289
339
|
```
|
|
290
340
|
|
|
291
|
-
|
|
292
|
-
- `orderId: string` (required)
|
|
341
|
+
Response: `Paginated<OrderMenuItem>`
|
|
293
342
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
---
|
|
297
|
-
|
|
298
|
-
#### DeleteOrder
|
|
299
|
-
Delete an order.
|
|
343
|
+
### GetOrderMenuItemDetails
|
|
300
344
|
|
|
301
345
|
```typescript
|
|
302
|
-
import {
|
|
346
|
+
import { GetOrderMenuItemDetails } from '@deliverart/sdk-js-order'
|
|
303
347
|
|
|
304
|
-
await sdk.call(
|
|
348
|
+
const item = await sdk.call(
|
|
349
|
+
new GetOrderMenuItemDetails('123e4567-e89b-12d3-a456-426614174004'),
|
|
350
|
+
)
|
|
305
351
|
```
|
|
306
352
|
|
|
307
|
-
|
|
308
|
-
- `orderId: string` (required)
|
|
353
|
+
Response: `OrderMenuItemDetails`
|
|
309
354
|
|
|
310
|
-
|
|
355
|
+
### GetOrderMenuItemModifiers
|
|
311
356
|
|
|
312
|
-
|
|
357
|
+
```typescript
|
|
358
|
+
import { GetOrderMenuItemModifiers } from '@deliverart/sdk-js-order'
|
|
313
359
|
|
|
314
|
-
|
|
315
|
-
|
|
360
|
+
const modifiers = await sdk.call(
|
|
361
|
+
new GetOrderMenuItemModifiers({
|
|
362
|
+
query: {
|
|
363
|
+
'order[createdAt]': 'desc',
|
|
364
|
+
page: 1,
|
|
365
|
+
},
|
|
366
|
+
}),
|
|
367
|
+
)
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Response: `Paginated<OrderMenuItemModifier>`
|
|
371
|
+
|
|
372
|
+
### GetOrderMenuItemModifierDetails
|
|
316
373
|
|
|
317
374
|
```typescript
|
|
318
|
-
import {
|
|
319
|
-
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
billingInfo: {
|
|
324
|
-
businessName: 'Acme Corp',
|
|
325
|
-
vat: 'IT12345678901',
|
|
326
|
-
taxCode: 'RSSMRA80A01H501U',
|
|
327
|
-
billingAddress: {
|
|
328
|
-
street: 'Via Fatturazione 10',
|
|
329
|
-
city: 'Milano',
|
|
330
|
-
postalCode: '20100',
|
|
331
|
-
country: 'IT'
|
|
332
|
-
},
|
|
333
|
-
billingData: {
|
|
334
|
-
recipientCode: 'ABCDEFG',
|
|
335
|
-
pec: 'billing@acmecorp.it'
|
|
336
|
-
}
|
|
337
|
-
},
|
|
338
|
-
address: {
|
|
339
|
-
street: 'Via Roma 1',
|
|
340
|
-
city: 'Milano',
|
|
341
|
-
postalCode: '20100',
|
|
342
|
-
country: 'IT'
|
|
343
|
-
},
|
|
344
|
-
items: [
|
|
345
|
-
{
|
|
346
|
-
menuItem: '/menu_items/1',
|
|
347
|
-
quantity: 2,
|
|
348
|
-
price: 1500
|
|
349
|
-
}
|
|
350
|
-
]
|
|
351
|
-
}));
|
|
352
|
-
|
|
353
|
-
console.log('Total fees:', fees.feeAmount);
|
|
354
|
-
fees.fees.forEach(fee => {
|
|
355
|
-
console.log(`${fee.key}: ${fee.amount}`);
|
|
356
|
-
});
|
|
375
|
+
import { GetOrderMenuItemModifierDetails } from '@deliverart/sdk-js-order'
|
|
376
|
+
|
|
377
|
+
const modifier = await sdk.call(
|
|
378
|
+
new GetOrderMenuItemModifierDetails('123e4567-e89b-12d3-a456-426614174005'),
|
|
379
|
+
)
|
|
357
380
|
```
|
|
358
381
|
|
|
359
|
-
|
|
360
|
-
- Same as CreateOrder but only requires minimal fields
|
|
361
|
-
- `billingInfo: OrderBillingInfo` (optional) - Billing information (includes billingAddress)
|
|
382
|
+
Response: `OrderMenuItemModifierDetails`
|
|
362
383
|
|
|
363
|
-
|
|
384
|
+
## Bundles
|
|
364
385
|
|
|
365
|
-
|
|
386
|
+
`Bundle` and `BundleDetails` are discriminated by `type`.
|
|
366
387
|
|
|
367
|
-
|
|
368
|
-
|
|
388
|
+
- `REGULAR`
|
|
389
|
+
- `FORCED`
|
|
369
390
|
|
|
370
|
-
|
|
371
|
-
|
|
391
|
+
Bundle read models also expose:
|
|
392
|
+
- `capacityUsed`
|
|
393
|
+
- `plannedStops`
|
|
394
|
+
- `routeDurationSeconds`
|
|
395
|
+
- `routeDistanceMeters`
|
|
396
|
+
- `slackSeconds`
|
|
397
|
+
- `plannerVersion`
|
|
372
398
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
399
|
+
### CreateBundle
|
|
400
|
+
|
|
401
|
+
```typescript
|
|
402
|
+
import { CreateBundle } from '@deliverart/sdk-js-order'
|
|
403
|
+
|
|
404
|
+
const bundle = await sdk.call(
|
|
405
|
+
new CreateBundle({
|
|
406
|
+
pointOfSale: '/point_of_sales/123e4567-e89b-12d3-a456-426614174000',
|
|
407
|
+
deliverable: true,
|
|
408
|
+
ready: false,
|
|
409
|
+
}),
|
|
410
|
+
)
|
|
378
411
|
```
|
|
379
412
|
|
|
380
|
-
|
|
381
|
-
|
|
413
|
+
Response: `BundleDetails`
|
|
414
|
+
|
|
415
|
+
### GenerateOrderBundle
|
|
382
416
|
|
|
383
417
|
```typescript
|
|
384
|
-
import {
|
|
418
|
+
import { GenerateOrderBundle } from '@deliverart/sdk-js-order'
|
|
385
419
|
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
420
|
+
const order = await sdk.call(
|
|
421
|
+
new GenerateOrderBundle('123e4567-e89b-12d3-a456-426614174003'),
|
|
422
|
+
)
|
|
389
423
|
```
|
|
390
424
|
|
|
391
|
-
|
|
392
|
-
Remove a menu item from an order.
|
|
425
|
+
Response: `OrderDetails`
|
|
393
426
|
|
|
394
|
-
|
|
395
|
-
import { DeleteOrderMenuItem } from '@deliverart/sdk-js-order';
|
|
427
|
+
Use this only for orders that currently have no `bundle`.
|
|
396
428
|
|
|
397
|
-
|
|
398
|
-
```
|
|
429
|
+
### GetBundles
|
|
399
430
|
|
|
400
|
-
|
|
431
|
+
```typescript
|
|
432
|
+
import { GetBundles } from '@deliverart/sdk-js-order'
|
|
401
433
|
|
|
402
|
-
|
|
434
|
+
const bundles = await sdk.call(
|
|
435
|
+
new GetBundles({
|
|
436
|
+
query: {
|
|
437
|
+
status: ['pending', 'busy'],
|
|
438
|
+
type: 'REGULAR',
|
|
439
|
+
'order[createdAt]': 'desc',
|
|
440
|
+
page: 1,
|
|
441
|
+
},
|
|
442
|
+
}),
|
|
443
|
+
)
|
|
444
|
+
```
|
|
403
445
|
|
|
404
|
-
|
|
446
|
+
Response: `Paginated<Bundle>`
|
|
405
447
|
|
|
406
|
-
|
|
407
|
-
Get list of bundles.
|
|
448
|
+
### GetBundleDetails
|
|
408
449
|
|
|
409
450
|
```typescript
|
|
410
|
-
import {
|
|
411
|
-
|
|
412
|
-
const
|
|
413
|
-
query: {
|
|
414
|
-
'status[]': ['pending', 'busy'],
|
|
415
|
-
page: 1
|
|
416
|
-
}
|
|
417
|
-
}));
|
|
451
|
+
import { GetBundleDetails } from '@deliverart/sdk-js-order'
|
|
452
|
+
|
|
453
|
+
const bundle = await sdk.call(new GetBundleDetails('123e4567-e89b-12d3-a456-426614174006'))
|
|
418
454
|
```
|
|
419
455
|
|
|
420
|
-
|
|
456
|
+
Response: `BundleDetails`
|
|
457
|
+
|
|
458
|
+
### GetBundlesFromPointOfSale
|
|
421
459
|
|
|
422
460
|
```typescript
|
|
423
|
-
import {
|
|
424
|
-
import {
|
|
425
|
-
CreateOrder,
|
|
426
|
-
GetOrders,
|
|
427
|
-
ConfirmOrder,
|
|
428
|
-
AdvanceOrderPreparationStatus,
|
|
429
|
-
CalculateOrderFees
|
|
430
|
-
} from '@deliverart/sdk-js-order';
|
|
431
|
-
|
|
432
|
-
async function orderWorkflow() {
|
|
433
|
-
// Calculate fees first
|
|
434
|
-
const fees = await sdk.call(new CalculateOrderFees({
|
|
435
|
-
pointOfSale: '/point_of_sales/123',
|
|
436
|
-
billingInfo: {
|
|
437
|
-
businessName: 'Acme Corp',
|
|
438
|
-
vat: 'IT12345678901',
|
|
439
|
-
taxCode: 'RSSMRA80A01H501U',
|
|
440
|
-
billingAddress: {
|
|
441
|
-
street: 'Via Fatturazione 10',
|
|
442
|
-
city: 'Milano',
|
|
443
|
-
postalCode: '20100',
|
|
444
|
-
country: 'IT'
|
|
445
|
-
},
|
|
446
|
-
billingData: {
|
|
447
|
-
recipientCode: 'ABCDEFG',
|
|
448
|
-
pec: 'billing@acmecorp.it'
|
|
449
|
-
}
|
|
450
|
-
},
|
|
451
|
-
items: [
|
|
452
|
-
{ menuItem: '/menu_items/1', quantity: 2, price: 1500 }
|
|
453
|
-
]
|
|
454
|
-
}));
|
|
455
|
-
|
|
456
|
-
console.log('Estimated fees:', fees.feeAmount);
|
|
457
|
-
|
|
458
|
-
// Create order
|
|
459
|
-
const order = await sdk.call(new CreateOrder({
|
|
460
|
-
type: 'delivery',
|
|
461
|
-
source: 'application',
|
|
462
|
-
pointOfSale: '/point_of_sales/123',
|
|
463
|
-
customerInfo: {
|
|
464
|
-
firstName: 'John',
|
|
465
|
-
lastName: 'Doe',
|
|
466
|
-
email: 'john@example.com',
|
|
467
|
-
phoneNumber: '+39123456789'
|
|
468
|
-
},
|
|
469
|
-
billingInfo: {
|
|
470
|
-
businessName: 'Acme Corp',
|
|
471
|
-
vat: 'IT12345678901',
|
|
472
|
-
taxCode: 'RSSMRA80A01H501U',
|
|
473
|
-
billingAddress: {
|
|
474
|
-
street: 'Via Fatturazione 10',
|
|
475
|
-
city: 'Milano',
|
|
476
|
-
postalCode: '20100',
|
|
477
|
-
country: 'IT'
|
|
478
|
-
},
|
|
479
|
-
billingData: {
|
|
480
|
-
recipientCode: 'ABCDEFG',
|
|
481
|
-
pec: 'billing@acmecorp.it'
|
|
482
|
-
}
|
|
483
|
-
},
|
|
484
|
-
address: {
|
|
485
|
-
street: 'Via Roma 1',
|
|
486
|
-
city: 'Milano',
|
|
487
|
-
postalCode: '20100',
|
|
488
|
-
country: 'IT'
|
|
489
|
-
},
|
|
490
|
-
items: [
|
|
491
|
-
{
|
|
492
|
-
menuItem: '/menu_items/1',
|
|
493
|
-
quantity: 2,
|
|
494
|
-
price: 1500
|
|
495
|
-
}
|
|
496
|
-
]
|
|
497
|
-
}));
|
|
461
|
+
import { GetBundlesFromPointOfSale } from '@deliverart/sdk-js-order'
|
|
498
462
|
|
|
499
|
-
|
|
463
|
+
const bundles = await sdk.call(
|
|
464
|
+
new GetBundlesFromPointOfSale('123e4567-e89b-12d3-a456-426614174000', {
|
|
465
|
+
query: {
|
|
466
|
+
ready: false,
|
|
467
|
+
page: 1,
|
|
468
|
+
},
|
|
469
|
+
}),
|
|
470
|
+
)
|
|
471
|
+
```
|
|
500
472
|
|
|
501
|
-
|
|
502
|
-
const confirmed = await sdk.call(new ConfirmOrder(order.id));
|
|
503
|
-
console.log('Order confirmed');
|
|
473
|
+
Response: `Paginated<Bundle>`
|
|
504
474
|
|
|
505
|
-
|
|
506
|
-
await sdk.call(new AdvanceOrderPreparationStatus(order.id));
|
|
507
|
-
console.log('Preparation started');
|
|
475
|
+
### UpdateBundle
|
|
508
476
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
query: {
|
|
512
|
-
'status[]': ['pending'],
|
|
513
|
-
'order[createdAt]': 'desc'
|
|
514
|
-
}
|
|
515
|
-
}));
|
|
477
|
+
```typescript
|
|
478
|
+
import { UpdateBundle } from '@deliverart/sdk-js-order'
|
|
516
479
|
|
|
517
|
-
|
|
518
|
-
|
|
480
|
+
const updated = await sdk.call(
|
|
481
|
+
new UpdateBundle('123e4567-e89b-12d3-a456-426614174006', {
|
|
482
|
+
ready: true,
|
|
483
|
+
}),
|
|
484
|
+
)
|
|
519
485
|
```
|
|
520
486
|
|
|
487
|
+
Response: `BundleDetails`
|
|
488
|
+
|
|
489
|
+
Available requests
|
|
490
|
+
- `CreateBundle`
|
|
491
|
+
- `GetBundles`
|
|
492
|
+
- `GetBundlesFromPointOfSale`
|
|
493
|
+
- `GetBundleDetails`
|
|
494
|
+
- `UpdateBundle`
|
|
495
|
+
- `DeleteBundle`
|
|
496
|
+
|
|
521
497
|
## License
|
|
522
498
|
|
|
523
499
|
MIT
|