@compassdigital/sdk.typescript 3.40.0 → 3.42.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 +11 -0
- package/lib/base.d.ts +6 -0
- package/lib/base.d.ts.map +1 -1
- package/lib/base.js +26 -18
- package/lib/base.js.map +1 -1
- package/lib/index.d.ts +77 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +79 -3
- package/lib/index.js.map +1 -1
- package/lib/interface/mealplan.d.ts +7 -1
- package/lib/interface/mealplan.d.ts.map +1 -1
- package/lib/interface/menu.d.ts +105 -3
- package/lib/interface/menu.d.ts.map +1 -1
- package/lib/interface/partner.d.ts +0 -1
- package/lib/interface/partner.d.ts.map +1 -1
- package/lib/interface/shoppingcart.d.ts +124 -67
- package/lib/interface/shoppingcart.d.ts.map +1 -1
- package/package.json +10 -5
- package/pipeline.yml +13 -0
- package/src/base.ts +30 -18
- package/src/index.ts +204 -9
- package/src/interface/mealplan.ts +12 -1
- package/src/interface/menu.ts +167 -5
- package/src/interface/partner.ts +0 -2
- package/src/interface/shoppingcart.ts +141 -72
- package/test/client.test.ts +31 -1
|
@@ -7,79 +7,134 @@ export interface Error {
|
|
|
7
7
|
code?: number;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export interface
|
|
11
|
-
|
|
10
|
+
export interface ItemsRequest {
|
|
11
|
+
items?: ItemRequest[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ItemRequest {
|
|
15
|
+
// item id
|
|
12
16
|
id: string;
|
|
13
|
-
|
|
17
|
+
quantity: Quantity;
|
|
18
|
+
options?: ModifierGroupRequest[];
|
|
14
19
|
_index?: string;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
meta?: {
|
|
21
|
+
brand?: string;
|
|
22
|
+
brand_label?: Label;
|
|
23
|
+
menu?: string;
|
|
24
|
+
[index: string]: any;
|
|
19
25
|
};
|
|
26
|
+
special_instructions?: string;
|
|
27
|
+
amount_off_exclusions?: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ItemResponse {
|
|
31
|
+
// can be cdl item id or stringified timestamp
|
|
32
|
+
id: string;
|
|
33
|
+
description?: Label;
|
|
34
|
+
// index based on cdl id or stringified timestamp
|
|
35
|
+
_index?: string;
|
|
36
|
+
quantity: Quantity;
|
|
37
|
+
unit?: number;
|
|
38
|
+
price?: Price;
|
|
20
39
|
// Final item price after LTO/Bundle/BOGO etc is applied on the item.
|
|
21
40
|
sale_price?: {
|
|
22
41
|
active?: boolean;
|
|
23
|
-
amount?:
|
|
42
|
+
amount?: MonetaryValue;
|
|
24
43
|
};
|
|
25
44
|
// Subtotal of the item including all options
|
|
26
45
|
_subtotal?: {
|
|
27
|
-
amount?:
|
|
46
|
+
amount?: MonetaryValue;
|
|
28
47
|
};
|
|
29
48
|
// Promo applied to this item
|
|
30
49
|
_promo?: {
|
|
31
|
-
amount?:
|
|
50
|
+
amount?: MonetaryValue;
|
|
51
|
+
};
|
|
52
|
+
// discount applied to this item
|
|
53
|
+
_discount?: {
|
|
54
|
+
amount?: MonetaryValue;
|
|
32
55
|
};
|
|
33
56
|
meta?: {
|
|
34
57
|
// menu id
|
|
35
58
|
menu?: string;
|
|
36
59
|
// brand id
|
|
37
60
|
brand?: string;
|
|
61
|
+
brand_label?: Label;
|
|
62
|
+
taxes?: string[];
|
|
63
|
+
menu_tax_tags?: string[];
|
|
64
|
+
orderable?: boolean;
|
|
65
|
+
volante_id?: string;
|
|
38
66
|
[index: string]: any;
|
|
39
67
|
};
|
|
40
|
-
options?:
|
|
41
|
-
id?: string;
|
|
42
|
-
label?: {
|
|
43
|
-
en?: string;
|
|
44
|
-
};
|
|
45
|
-
meta?: any;
|
|
46
|
-
items?: {
|
|
47
|
-
// option
|
|
48
|
-
id?: string;
|
|
49
|
-
label?: {
|
|
50
|
-
en?: string;
|
|
51
|
-
};
|
|
52
|
-
// index
|
|
53
|
-
_index?: string;
|
|
54
|
-
meta?: any;
|
|
55
|
-
quantity?: number;
|
|
56
|
-
amount_off_exclusions?: string[];
|
|
57
|
-
}[];
|
|
58
|
-
}[];
|
|
68
|
+
options?: ModifierGroupResponse[];
|
|
59
69
|
// Details about discount like BOGO, LTO, Bundle etc.
|
|
60
70
|
item_discount?: any;
|
|
61
71
|
// user specified instructions for the item
|
|
62
72
|
special_instructions?: string;
|
|
63
73
|
amount_off_exclusions?: string[];
|
|
64
74
|
added_on?: string;
|
|
65
|
-
|
|
75
|
+
meal_value?: IntegerValue;
|
|
76
|
+
category?: Label;
|
|
66
77
|
}
|
|
67
78
|
|
|
68
|
-
export interface
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
export interface ModifierGroupRequest {
|
|
80
|
+
label?: Label;
|
|
81
|
+
items?: ModifierRequest[];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface ModifierGroupResponse {
|
|
85
|
+
id?: string;
|
|
86
|
+
label?: Label;
|
|
87
|
+
meta?: {
|
|
88
|
+
taxes?: string[];
|
|
89
|
+
original_label?: Label;
|
|
90
|
+
[index: string]: any;
|
|
91
|
+
};
|
|
92
|
+
items?: ModifierResponse[];
|
|
93
|
+
is?: {
|
|
94
|
+
disabled?: boolean;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface ModifierRequest {
|
|
99
|
+
// option/modifier
|
|
100
|
+
id?: string;
|
|
101
|
+
label?: Label;
|
|
102
|
+
_index?: string;
|
|
103
|
+
quantity?: Quantity;
|
|
104
|
+
amount_off_exclusions?: string[];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface ModifierResponse {
|
|
108
|
+
// option/modifier
|
|
109
|
+
id?: string;
|
|
110
|
+
price?: Price;
|
|
111
|
+
quantity?: Quantity;
|
|
112
|
+
label?: Label;
|
|
113
|
+
// index
|
|
114
|
+
_index?: string;
|
|
115
|
+
meta?: {
|
|
116
|
+
sort_number?: number;
|
|
117
|
+
original_label?: Label;
|
|
118
|
+
taxes?: string[];
|
|
77
119
|
[index: string]: any;
|
|
78
120
|
};
|
|
121
|
+
amount_off_exclusions?: string[];
|
|
122
|
+
is?: {
|
|
123
|
+
disabled?: boolean;
|
|
124
|
+
};
|
|
79
125
|
}
|
|
80
126
|
|
|
81
|
-
export interface
|
|
82
|
-
|
|
127
|
+
export interface Taxes {
|
|
128
|
+
amount?: MonetaryValue;
|
|
129
|
+
rate?: MonetaryValue;
|
|
130
|
+
breakdown?: {
|
|
131
|
+
taxable_amount?: MonetaryValue;
|
|
132
|
+
tax_collectable?: MonetaryValue;
|
|
133
|
+
combined_tax_rate?: MonetaryValue;
|
|
134
|
+
gst?: MonetaryValue;
|
|
135
|
+
pst?: MonetaryValue;
|
|
136
|
+
[index: string]: any;
|
|
137
|
+
};
|
|
83
138
|
}
|
|
84
139
|
|
|
85
140
|
export interface Promo {
|
|
@@ -89,7 +144,7 @@ export interface Promo {
|
|
|
89
144
|
|
|
90
145
|
export interface BadgePay {
|
|
91
146
|
id?: string;
|
|
92
|
-
total?:
|
|
147
|
+
total?: MonetaryValue;
|
|
93
148
|
tender?: string;
|
|
94
149
|
name?: string;
|
|
95
150
|
}
|
|
@@ -99,26 +154,25 @@ export interface Payment {
|
|
|
99
154
|
mealplan?: {
|
|
100
155
|
id?: string;
|
|
101
156
|
tender?: string;
|
|
102
|
-
total?:
|
|
157
|
+
total?: MonetaryValue;
|
|
103
158
|
};
|
|
104
159
|
credit_card?: {
|
|
105
160
|
card_type?: string;
|
|
106
161
|
last4?: string;
|
|
107
|
-
total?:
|
|
162
|
+
total?: MonetaryValue;
|
|
108
163
|
};
|
|
109
164
|
digital_wallet_pay?: {
|
|
110
165
|
wallet_type?: string;
|
|
111
|
-
total?:
|
|
166
|
+
total?: MonetaryValue;
|
|
112
167
|
};
|
|
113
168
|
meal_swipes?: {
|
|
114
169
|
id?: string;
|
|
115
170
|
tender?: string;
|
|
116
171
|
tender_type?: string;
|
|
117
172
|
tender_name?: string;
|
|
118
|
-
swipes?:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
total?: number;
|
|
173
|
+
swipes?: MonetaryValue;
|
|
174
|
+
rate?: MonetaryValue;
|
|
175
|
+
total?: MonetaryValue;
|
|
122
176
|
};
|
|
123
177
|
meal_exchange?: {
|
|
124
178
|
id?: string;
|
|
@@ -174,23 +228,23 @@ export interface ShoppingCartResponse {
|
|
|
174
228
|
// brand
|
|
175
229
|
brand?: string;
|
|
176
230
|
date?: any;
|
|
177
|
-
items?:
|
|
231
|
+
items?: ItemResponse[];
|
|
178
232
|
sub_total?: {
|
|
179
|
-
amount?:
|
|
233
|
+
amount?: MonetaryValue;
|
|
180
234
|
};
|
|
181
235
|
promo?: {
|
|
182
236
|
code?: string;
|
|
183
|
-
amount_off?:
|
|
184
|
-
percent_off?:
|
|
185
|
-
amount?:
|
|
237
|
+
amount_off?: MonetaryValue;
|
|
238
|
+
percent_off?: MonetaryValue;
|
|
239
|
+
amount?: MonetaryValue;
|
|
186
240
|
app?: string;
|
|
187
241
|
};
|
|
188
242
|
//@deprecated
|
|
189
243
|
loyalty?: {
|
|
190
244
|
coupon?: {
|
|
191
245
|
code?: string;
|
|
192
|
-
amount_off?:
|
|
193
|
-
amount?:
|
|
246
|
+
amount_off?: MonetaryValue;
|
|
247
|
+
amount?: MonetaryValue;
|
|
194
248
|
name?: string;
|
|
195
249
|
};
|
|
196
250
|
// Points to be earned for this shopping cart total
|
|
@@ -198,34 +252,34 @@ export interface ShoppingCartResponse {
|
|
|
198
252
|
};
|
|
199
253
|
discount?: {
|
|
200
254
|
code?: string;
|
|
201
|
-
amount_off?:
|
|
202
|
-
percent_off?:
|
|
203
|
-
amount?:
|
|
255
|
+
amount_off?: MonetaryValue;
|
|
256
|
+
percent_off?: MonetaryValue;
|
|
257
|
+
amount?: MonetaryValue;
|
|
204
258
|
};
|
|
205
259
|
payment_method?: {
|
|
206
260
|
email?: string;
|
|
207
261
|
mealplan?: {
|
|
208
262
|
id?: string;
|
|
209
263
|
tender?: string;
|
|
210
|
-
total?:
|
|
264
|
+
total?: MonetaryValue;
|
|
211
265
|
};
|
|
212
266
|
credit_card?: {
|
|
213
267
|
card_type?: string;
|
|
214
268
|
last4?: string;
|
|
215
|
-
total?:
|
|
269
|
+
total?: MonetaryValue;
|
|
216
270
|
};
|
|
217
271
|
digital_wallet_pay?: {
|
|
218
272
|
wallet_type?: string;
|
|
219
|
-
total?:
|
|
273
|
+
total?: MonetaryValue;
|
|
220
274
|
};
|
|
221
275
|
meal_swipes?: {
|
|
222
276
|
id?: string;
|
|
223
277
|
tender?: string;
|
|
224
278
|
tender_type?: string;
|
|
225
279
|
tender_name?: string;
|
|
226
|
-
swipes?:
|
|
227
|
-
rate?:
|
|
228
|
-
total?:
|
|
280
|
+
swipes?: MonetaryValue;
|
|
281
|
+
rate?: MonetaryValue;
|
|
282
|
+
total?: MonetaryValue;
|
|
229
283
|
};
|
|
230
284
|
meal_exchange?: {
|
|
231
285
|
id?: string;
|
|
@@ -233,10 +287,10 @@ export interface ShoppingCartResponse {
|
|
|
233
287
|
};
|
|
234
288
|
badge_pay?: BadgePay;
|
|
235
289
|
};
|
|
236
|
-
taxes?:
|
|
290
|
+
taxes?: Taxes;
|
|
237
291
|
total?: {
|
|
238
|
-
amount?:
|
|
239
|
-
meals?:
|
|
292
|
+
amount?: MonetaryValue;
|
|
293
|
+
meals?: MonetaryValue;
|
|
240
294
|
};
|
|
241
295
|
exemptions?: {
|
|
242
296
|
tax?: boolean;
|
|
@@ -246,10 +300,10 @@ export interface ShoppingCartResponse {
|
|
|
246
300
|
id?: string;
|
|
247
301
|
};
|
|
248
302
|
service_fee?: {
|
|
249
|
-
amount?:
|
|
303
|
+
amount?: MonetaryValue;
|
|
250
304
|
};
|
|
251
305
|
delivery_fee?: {
|
|
252
|
-
amount?:
|
|
306
|
+
amount?: MonetaryValue;
|
|
253
307
|
};
|
|
254
308
|
is?: {
|
|
255
309
|
// Shoppingcart Type: delivery, pickup
|
|
@@ -270,6 +324,21 @@ export interface ShoppingCartResponse {
|
|
|
270
324
|
|
|
271
325
|
export type ShoppingCart = ShoppingCartResponse;
|
|
272
326
|
|
|
327
|
+
export interface Label {
|
|
328
|
+
en?: string;
|
|
329
|
+
fr?: string;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export interface Price {
|
|
333
|
+
amount?: MonetaryValue;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export type MonetaryValue = number;
|
|
337
|
+
|
|
338
|
+
export type IntegerValue = number;
|
|
339
|
+
|
|
340
|
+
export type Quantity = IntegerValue;
|
|
341
|
+
|
|
273
342
|
// POST /shoppingcart/ - Create a new ShoppingCart
|
|
274
343
|
|
|
275
344
|
export type PostShoppingcartCartBody = ShoppingCartRequest;
|
|
@@ -287,7 +356,7 @@ export interface PutShoppingcartCartItemsPath {
|
|
|
287
356
|
id: string;
|
|
288
357
|
}
|
|
289
358
|
|
|
290
|
-
export type PutShoppingcartCartItemsBody =
|
|
359
|
+
export type PutShoppingcartCartItemsBody = ItemsRequest;
|
|
291
360
|
|
|
292
361
|
export type PutShoppingcartCartItemsResponse = ShoppingCartResponse;
|
|
293
362
|
|
|
@@ -302,7 +371,7 @@ export interface DeleteShoppingcartCartItemsPath {
|
|
|
302
371
|
id: string;
|
|
303
372
|
}
|
|
304
373
|
|
|
305
|
-
export type DeleteShoppingcartCartItemsBody =
|
|
374
|
+
export type DeleteShoppingcartCartItemsBody = ItemsRequest;
|
|
306
375
|
|
|
307
376
|
export type DeleteShoppingcartCartItemsResponse = ShoppingCartResponse;
|
|
308
377
|
|
package/test/client.test.ts
CHANGED
|
@@ -199,5 +199,35 @@ describe("ServiceClient", () => {
|
|
|
199
199
|
const promise = api.get_task("").combine(500);
|
|
200
200
|
expect(promise).rejects.toThrow();
|
|
201
201
|
});
|
|
202
|
+
|
|
203
|
+
test("method should throw custom error", async () => {
|
|
204
|
+
const err = new Error("my error");
|
|
205
|
+
const api = new ServiceClient({
|
|
206
|
+
intercept: interceptor(400, "{}"),
|
|
207
|
+
throws: err,
|
|
208
|
+
});
|
|
209
|
+
const promise = api.get_task("");
|
|
210
|
+
expect(promise).rejects.toThrow(err);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test("combine and should work with custom error", async () => {
|
|
214
|
+
const api = new ServiceClient({
|
|
215
|
+
intercept: interceptor(400, "{}"),
|
|
216
|
+
throws: new Error("custom"),
|
|
217
|
+
});
|
|
218
|
+
const res = await api.get_task("{}").combine(400);
|
|
219
|
+
expect(res.ok).toBe(false);
|
|
220
|
+
expect(res.err).toBeInstanceOf(ServiceError);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
test("ignore and should work with custom error", async () => {
|
|
224
|
+
const err = new Error("custom");
|
|
225
|
+
const api = new ServiceClient({
|
|
226
|
+
intercept: interceptor(400, "{}"),
|
|
227
|
+
throws: err,
|
|
228
|
+
});
|
|
229
|
+
const res = await api.get_task("{}").ignore(400);
|
|
230
|
+
expect(res).toBeNull();
|
|
231
|
+
});
|
|
202
232
|
});
|
|
203
|
-
});
|
|
233
|
+
});
|