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