@gofynd/fdk-client-javascript 1.4.5 → 1.4.7

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.
Files changed (79) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -2
  3. package/sdk/application/ApplicationClient.d.ts +2 -2
  4. package/sdk/application/ApplicationClient.js +2 -2
  5. package/sdk/application/Catalog/CatalogApplicationClient.d.ts +5 -5
  6. package/sdk/application/Catalog/CatalogApplicationClient.js +5 -5
  7. package/sdk/application/Catalog/CatalogApplicationModel.d.ts +6 -0
  8. package/sdk/application/Catalog/CatalogApplicationModel.js +6 -0
  9. package/sdk/application/Content/ContentApplicationModel.d.ts +2 -0
  10. package/sdk/application/Content/ContentApplicationModel.js +2 -0
  11. package/sdk/application/Logistic/LogisticApplicationModel.js +2 -2
  12. package/sdk/application/Order/OrderApplicationClient.d.ts +1 -1
  13. package/sdk/application/Order/OrderApplicationClient.js +1 -1
  14. package/sdk/application/Order/OrderApplicationModel.d.ts +70 -9
  15. package/sdk/application/Order/OrderApplicationModel.js +43 -7
  16. package/sdk/application/Order/OrderApplicationValidator.d.ts +2 -2
  17. package/sdk/application/Order/OrderApplicationValidator.js +1 -1
  18. package/sdk/application/Payment/PaymentApplicationModel.d.ts +18 -18
  19. package/sdk/application/Payment/PaymentApplicationModel.js +41 -35
  20. package/sdk/application/Webhook/WebhookApplicationClient.d.ts +22 -0
  21. package/sdk/application/Webhook/WebhookApplicationClient.js +115 -0
  22. package/sdk/application/Webhook/WebhookApplicationModel.d.ts +37 -0
  23. package/sdk/application/Webhook/WebhookApplicationModel.js +46 -0
  24. package/sdk/application/Webhook/WebhookApplicationValidator.d.ts +16 -0
  25. package/sdk/application/Webhook/WebhookApplicationValidator.js +19 -0
  26. package/sdk/application/index.d.ts +1 -1
  27. package/sdk/application/index.js +2 -2
  28. package/sdk/partner/Webhook/WebhookPartnerClient.d.ts +2 -2
  29. package/sdk/partner/Webhook/WebhookPartnerClient.js +2 -2
  30. package/sdk/partner/Webhook/WebhookPartnerModel.d.ts +23 -19
  31. package/sdk/partner/Webhook/WebhookPartnerModel.js +20 -23
  32. package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.d.ts +43 -0
  33. package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.js +257 -0
  34. package/sdk/platform/Analytics/AnalyticsPlatformApplicationValidator.d.ts +39 -0
  35. package/sdk/platform/Analytics/AnalyticsPlatformApplicationValidator.js +45 -0
  36. package/sdk/platform/Analytics/AnalyticsPlatformModel.d.ts +60 -0
  37. package/sdk/platform/Analytics/AnalyticsPlatformModel.js +57 -0
  38. package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +10 -0
  39. package/sdk/platform/Cart/CartPlatformApplicationClient.js +80 -0
  40. package/sdk/platform/Cart/CartPlatformApplicationValidator.d.ts +13 -1
  41. package/sdk/platform/Cart/CartPlatformApplicationValidator.js +12 -0
  42. package/sdk/platform/Cart/CartPlatformModel.d.ts +2 -0
  43. package/sdk/platform/Cart/CartPlatformModel.js +2 -0
  44. package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +34 -7
  45. package/sdk/platform/Catalog/CatalogPlatformClient.js +88 -13
  46. package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +120 -17
  47. package/sdk/platform/Catalog/CatalogPlatformModel.js +153 -27
  48. package/sdk/platform/Catalog/CatalogPlatformValidator.d.ts +71 -7
  49. package/sdk/platform/Catalog/CatalogPlatformValidator.js +32 -5
  50. package/sdk/platform/Content/ContentPlatformModel.d.ts +2 -0
  51. package/sdk/platform/Content/ContentPlatformModel.js +2 -0
  52. package/sdk/platform/Order/OrderPlatformClient.d.ts +11 -1
  53. package/sdk/platform/Order/OrderPlatformClient.js +82 -5
  54. package/sdk/platform/Order/OrderPlatformModel.d.ts +163 -15
  55. package/sdk/platform/Order/OrderPlatformModel.js +157 -55
  56. package/sdk/platform/Order/OrderPlatformValidator.d.ts +58 -17
  57. package/sdk/platform/Order/OrderPlatformValidator.js +28 -16
  58. package/sdk/platform/Payment/PaymentPlatformModel.d.ts +2 -2
  59. package/sdk/platform/Payment/PaymentPlatformModel.js +24 -18
  60. package/sdk/platform/PlatformApplicationClient.d.ts +2 -0
  61. package/sdk/platform/PlatformApplicationClient.js +4 -0
  62. package/sdk/platform/Webhook/WebhookPlatformClient.d.ts +24 -0
  63. package/sdk/platform/Webhook/WebhookPlatformClient.js +164 -0
  64. package/sdk/platform/Webhook/WebhookPlatformModel.d.ts +71 -18
  65. package/sdk/platform/Webhook/WebhookPlatformModel.js +76 -23
  66. package/sdk/platform/Webhook/WebhookPlatformValidator.d.ts +19 -1
  67. package/sdk/platform/Webhook/WebhookPlatformValidator.js +24 -0
  68. package/sdk/platform/index.d.ts +1 -0
  69. package/sdk/platform/index.js +2 -0
  70. package/sdk/public/Webhook/WebhookPublicClient.d.ts +2 -2
  71. package/sdk/public/Webhook/WebhookPublicClient.js +2 -2
  72. package/sdk/public/Webhook/WebhookPublicModel.d.ts +2 -0
  73. package/sdk/public/Webhook/WebhookPublicModel.js +3 -1
  74. package/sdk/application/PosCart/PosCartApplicationClient.d.ts +0 -323
  75. package/sdk/application/PosCart/PosCartApplicationClient.js +0 -2364
  76. package/sdk/application/PosCart/PosCartApplicationModel.d.ts +0 -1857
  77. package/sdk/application/PosCart/PosCartApplicationModel.js +0 -1906
  78. package/sdk/application/PosCart/PosCartApplicationValidator.d.ts +0 -483
  79. package/sdk/application/PosCart/PosCartApplicationValidator.js +0 -492
@@ -1,2364 +0,0 @@
1
- const ApplicationAPIClient = require("../ApplicationAPIClient");
2
- const {
3
- FDKClientValidationError,
4
- FDKResponseValidationError,
5
- } = require("../../common/FDKError");
6
- const constructUrl = require("../constructUrl");
7
- const Paginator = require("../../common/Paginator");
8
- const PosCartApplicationValidator = require("./PosCartApplicationValidator");
9
- const PosCartApplicationModel = require("./PosCartApplicationModel");
10
- const { Logger } = require("./../../common/Logger");
11
- const Joi = require("joi");
12
-
13
- class PosCart {
14
- constructor(_conf) {
15
- this._conf = _conf;
16
- this._relativeUrls = {
17
- addAddress: "/service/application/pos/cart/v1.0/address",
18
- addItems: "/service/application/pos/cart/v1.0/detail",
19
- applyCoupon: "/service/application/pos/cart/v1.0/coupon",
20
- applyRewardPoints: "/service/application/pos/cart/v1.0/redeem/points/",
21
- checkoutCart: "/service/application/pos/cart/v1.0/checkout",
22
- getAddressById: "/service/application/pos/cart/v1.0/address/{id}",
23
- getAddresses: "/service/application/pos/cart/v1.0/address",
24
- getAvailableDeliveryModes:
25
- "/service/application/pos/cart/v1.0/available-delivery-mode",
26
- getBulkDiscountOffers: "/service/application/pos/cart/v1.0/bulk-price",
27
- getCart: "/service/application/pos/cart/v1.0/detail",
28
- getCartLastModified: "/service/application/pos/cart/v1.0/detail",
29
- getCartShareLink: "/service/application/pos/cart/v1.0/share-cart",
30
- getCartSharedItems:
31
- "/service/application/pos/cart/v1.0/share-cart/{token}",
32
- getCoupons: "/service/application/pos/cart/v1.0/coupon",
33
- getItemCount: "/service/application/pos/cart/v1.0/basic",
34
- getShipments: "/service/application/pos/cart/v1.0/shipment",
35
- getStoreAddressByUid: "/service/application/pos/cart/v1.0/store-address",
36
- removeAddress: "/service/application/pos/cart/v1.0/address/{id}",
37
- removeCoupon: "/service/application/pos/cart/v1.0/coupon",
38
- selectAddress: "/service/application/pos/cart/v1.0/select-address",
39
- selectPaymentMode: "/service/application/pos/cart/v1.0/payment",
40
- updateAddress: "/service/application/pos/cart/v1.0/address/{id}",
41
- updateCart: "/service/application/pos/cart/v1.0/detail",
42
- updateCartMeta: "/service/application/pos/cart/v1.0/meta",
43
- updateCartWithSharedItems:
44
- "/service/application/pos/cart/v1.0/share-cart/{token}/{action}",
45
- updateShipments: "/service/application/pos/cart/v1.0/shipment",
46
- validateCouponForPayment:
47
- "/service/application/pos/cart/v1.0/payment/validate/",
48
- };
49
- this._urls = Object.entries(this._relativeUrls).reduce(
50
- (urls, [method, relativeUrl]) => {
51
- urls[method] = `${_conf.domain}${relativeUrl}`;
52
- return urls;
53
- },
54
- {}
55
- );
56
- }
57
-
58
- updateUrls(urls) {
59
- this._urls = {
60
- ...this._urls,
61
- ...urls,
62
- };
63
- }
64
-
65
- /**
66
- * @param {PosCartApplicationValidator.AddAddressParam} arg - Arg object.
67
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
68
- * @param {import("../ApplicationAPIClient").Options} - Options
69
- * @returns {Promise<PosCartApplicationModel.SaveAddressResponse>} - Success response
70
- * @name addAddress
71
- * @summary: Add new address
72
- * @description: Saves a new address for the user. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/addAddress/).
73
- */
74
- async addAddress(
75
- { body, requestHeaders } = { requestHeaders: {} },
76
- { responseHeaders } = { responseHeaders: false }
77
- ) {
78
- const { error } = PosCartApplicationValidator.addAddress().validate(
79
- { body },
80
- { abortEarly: false, allowUnknown: true }
81
- );
82
- if (error) {
83
- return Promise.reject(new FDKClientValidationError(error));
84
- }
85
-
86
- // Showing warrnings if extra unknown parameters are found
87
- const {
88
- error: warrning,
89
- } = PosCartApplicationValidator.addAddress().validate(
90
- { body },
91
- { abortEarly: false, allowUnknown: false }
92
- );
93
- if (warrning) {
94
- Logger({
95
- level: "WARN",
96
- message: `Parameter Validation warrnings for application > PosCart > addAddress \n ${warrning}`,
97
- });
98
- }
99
-
100
- const query_params = {};
101
-
102
- const xHeaders = {};
103
-
104
- const response = await ApplicationAPIClient.execute(
105
- this._conf,
106
- "post",
107
- constructUrl({
108
- url: this._urls["addAddress"],
109
- params: {},
110
- }),
111
- query_params,
112
- body,
113
- { ...xHeaders, ...requestHeaders },
114
- { responseHeaders }
115
- );
116
-
117
- let responseData = response;
118
- if (responseHeaders) {
119
- responseData = response[0];
120
- }
121
-
122
- const {
123
- error: res_error,
124
- } = PosCartApplicationModel.SaveAddressResponse().validate(responseData, {
125
- abortEarly: false,
126
- allowUnknown: true,
127
- });
128
-
129
- if (res_error) {
130
- if (this._conf.options.strictResponseCheck === true) {
131
- return Promise.reject(new FDKResponseValidationError(res_error));
132
- } else {
133
- Logger({
134
- level: "WARN",
135
- message: `Response Validation Warnings for application > PosCart > addAddress \n ${res_error}`,
136
- });
137
- }
138
- }
139
-
140
- return response;
141
- }
142
-
143
- /**
144
- * @param {PosCartApplicationValidator.AddItemsParam} arg - Arg object.
145
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
146
- * @param {import("../ApplicationAPIClient").Options} - Options
147
- * @returns {Promise<PosCartApplicationModel.AddCartDetailResponse>} -
148
- * Success response
149
- * @name addItems
150
- * @summary: Add to cart
151
- * @description: Adds selected items to the shopping cart. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/addItems/).
152
- */
153
- async addItems(
154
- { body, i, b, areaCode, buyNow, id, requestHeaders } = {
155
- requestHeaders: {},
156
- },
157
- { responseHeaders } = { responseHeaders: false }
158
- ) {
159
- const { error } = PosCartApplicationValidator.addItems().validate(
160
- { body, i, b, areaCode, buyNow, id },
161
- { abortEarly: false, allowUnknown: true }
162
- );
163
- if (error) {
164
- return Promise.reject(new FDKClientValidationError(error));
165
- }
166
-
167
- // Showing warrnings if extra unknown parameters are found
168
- const { error: warrning } = PosCartApplicationValidator.addItems().validate(
169
- { body, i, b, areaCode, buyNow, id },
170
- { abortEarly: false, allowUnknown: false }
171
- );
172
- if (warrning) {
173
- Logger({
174
- level: "WARN",
175
- message: `Parameter Validation warrnings for application > PosCart > addItems \n ${warrning}`,
176
- });
177
- }
178
-
179
- const query_params = {};
180
- query_params["i"] = i;
181
- query_params["b"] = b;
182
- query_params["area_code"] = areaCode;
183
- query_params["buy_now"] = buyNow;
184
- query_params["id"] = id;
185
-
186
- const xHeaders = {};
187
-
188
- const response = await ApplicationAPIClient.execute(
189
- this._conf,
190
- "post",
191
- constructUrl({
192
- url: this._urls["addItems"],
193
- params: {},
194
- }),
195
- query_params,
196
- body,
197
- { ...xHeaders, ...requestHeaders },
198
- { responseHeaders }
199
- );
200
-
201
- let responseData = response;
202
- if (responseHeaders) {
203
- responseData = response[0];
204
- }
205
-
206
- const {
207
- error: res_error,
208
- } = PosCartApplicationModel.AddCartDetailResponse().validate(responseData, {
209
- abortEarly: false,
210
- allowUnknown: true,
211
- });
212
-
213
- if (res_error) {
214
- if (this._conf.options.strictResponseCheck === true) {
215
- return Promise.reject(new FDKResponseValidationError(res_error));
216
- } else {
217
- Logger({
218
- level: "WARN",
219
- message: `Response Validation Warnings for application > PosCart > addItems \n ${res_error}`,
220
- });
221
- }
222
- }
223
-
224
- return response;
225
- }
226
-
227
- /**
228
- * @param {PosCartApplicationValidator.ApplyCouponParam} arg - Arg object.
229
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
230
- * @param {import("../ApplicationAPIClient").Options} - Options
231
- * @returns {Promise<PosCartApplicationModel.CartDetailResponse>} - Success response
232
- * @name applyCoupon
233
- * @summary: Apply coupon
234
- * @description: Applies a coupon code to get discounts on cart items. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/applyCoupon/).
235
- */
236
- async applyCoupon(
237
- { body, i, b, p, id, buyNow, requestHeaders } = { requestHeaders: {} },
238
- { responseHeaders } = { responseHeaders: false }
239
- ) {
240
- const { error } = PosCartApplicationValidator.applyCoupon().validate(
241
- { body, i, b, p, id, buyNow },
242
- { abortEarly: false, allowUnknown: true }
243
- );
244
- if (error) {
245
- return Promise.reject(new FDKClientValidationError(error));
246
- }
247
-
248
- // Showing warrnings if extra unknown parameters are found
249
- const {
250
- error: warrning,
251
- } = PosCartApplicationValidator.applyCoupon().validate(
252
- { body, i, b, p, id, buyNow },
253
- { abortEarly: false, allowUnknown: false }
254
- );
255
- if (warrning) {
256
- Logger({
257
- level: "WARN",
258
- message: `Parameter Validation warrnings for application > PosCart > applyCoupon \n ${warrning}`,
259
- });
260
- }
261
-
262
- const query_params = {};
263
- query_params["i"] = i;
264
- query_params["b"] = b;
265
- query_params["p"] = p;
266
- query_params["id"] = id;
267
- query_params["buy_now"] = buyNow;
268
-
269
- const xHeaders = {};
270
-
271
- const response = await ApplicationAPIClient.execute(
272
- this._conf,
273
- "post",
274
- constructUrl({
275
- url: this._urls["applyCoupon"],
276
- params: {},
277
- }),
278
- query_params,
279
- body,
280
- { ...xHeaders, ...requestHeaders },
281
- { responseHeaders }
282
- );
283
-
284
- let responseData = response;
285
- if (responseHeaders) {
286
- responseData = response[0];
287
- }
288
-
289
- const {
290
- error: res_error,
291
- } = PosCartApplicationModel.CartDetailResponse().validate(responseData, {
292
- abortEarly: false,
293
- allowUnknown: true,
294
- });
295
-
296
- if (res_error) {
297
- if (this._conf.options.strictResponseCheck === true) {
298
- return Promise.reject(new FDKResponseValidationError(res_error));
299
- } else {
300
- Logger({
301
- level: "WARN",
302
- message: `Response Validation Warnings for application > PosCart > applyCoupon \n ${res_error}`,
303
- });
304
- }
305
- }
306
-
307
- return response;
308
- }
309
-
310
- /**
311
- * @param {PosCartApplicationValidator.ApplyRewardPointsParam} arg - Arg object.
312
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
313
- * @param {import("../ApplicationAPIClient").Options} - Options
314
- * @returns {Promise<PosCartApplicationModel.CartDetailResponse>} - Success response
315
- * @name applyRewardPoints
316
- * @summary: Use reward points
317
- * @description: Applies user’s reward points to the cart. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/applyRewardPoints/).
318
- */
319
- async applyRewardPoints(
320
- { body, id, i, b, buyNow, requestHeaders } = { requestHeaders: {} },
321
- { responseHeaders } = { responseHeaders: false }
322
- ) {
323
- const { error } = PosCartApplicationValidator.applyRewardPoints().validate(
324
- { body, id, i, b, buyNow },
325
- { abortEarly: false, allowUnknown: true }
326
- );
327
- if (error) {
328
- return Promise.reject(new FDKClientValidationError(error));
329
- }
330
-
331
- // Showing warrnings if extra unknown parameters are found
332
- const {
333
- error: warrning,
334
- } = PosCartApplicationValidator.applyRewardPoints().validate(
335
- { body, id, i, b, buyNow },
336
- { abortEarly: false, allowUnknown: false }
337
- );
338
- if (warrning) {
339
- Logger({
340
- level: "WARN",
341
- message: `Parameter Validation warrnings for application > PosCart > applyRewardPoints \n ${warrning}`,
342
- });
343
- }
344
-
345
- const query_params = {};
346
- query_params["id"] = id;
347
- query_params["i"] = i;
348
- query_params["b"] = b;
349
- query_params["buy_now"] = buyNow;
350
-
351
- const xHeaders = {};
352
-
353
- const response = await ApplicationAPIClient.execute(
354
- this._conf,
355
- "post",
356
- constructUrl({
357
- url: this._urls["applyRewardPoints"],
358
- params: {},
359
- }),
360
- query_params,
361
- body,
362
- { ...xHeaders, ...requestHeaders },
363
- { responseHeaders }
364
- );
365
-
366
- let responseData = response;
367
- if (responseHeaders) {
368
- responseData = response[0];
369
- }
370
-
371
- const {
372
- error: res_error,
373
- } = PosCartApplicationModel.CartDetailResponse().validate(responseData, {
374
- abortEarly: false,
375
- allowUnknown: true,
376
- });
377
-
378
- if (res_error) {
379
- if (this._conf.options.strictResponseCheck === true) {
380
- return Promise.reject(new FDKResponseValidationError(res_error));
381
- } else {
382
- Logger({
383
- level: "WARN",
384
- message: `Response Validation Warnings for application > PosCart > applyRewardPoints \n ${res_error}`,
385
- });
386
- }
387
- }
388
-
389
- return response;
390
- }
391
-
392
- /**
393
- * @param {PosCartApplicationValidator.CheckoutCartParam} arg - Arg object.
394
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
395
- * @param {import("../ApplicationAPIClient").Options} - Options
396
- * @returns {Promise<PosCartApplicationModel.CartCheckoutResponse>} - Success response
397
- * @name checkoutCart
398
- * @summary: Checkout cart
399
- * @description: Initiates the checkout process for the cart. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/checkoutCart/).
400
- */
401
- async checkoutCart(
402
- { body, id, requestHeaders } = { requestHeaders: {} },
403
- { responseHeaders } = { responseHeaders: false }
404
- ) {
405
- const { error } = PosCartApplicationValidator.checkoutCart().validate(
406
- { body, id },
407
- { abortEarly: false, allowUnknown: true }
408
- );
409
- if (error) {
410
- return Promise.reject(new FDKClientValidationError(error));
411
- }
412
-
413
- // Showing warrnings if extra unknown parameters are found
414
- const {
415
- error: warrning,
416
- } = PosCartApplicationValidator.checkoutCart().validate(
417
- { body, id },
418
- { abortEarly: false, allowUnknown: false }
419
- );
420
- if (warrning) {
421
- Logger({
422
- level: "WARN",
423
- message: `Parameter Validation warrnings for application > PosCart > checkoutCart \n ${warrning}`,
424
- });
425
- }
426
-
427
- const query_params = {};
428
- query_params["id"] = id;
429
-
430
- const xHeaders = {};
431
-
432
- const response = await ApplicationAPIClient.execute(
433
- this._conf,
434
- "post",
435
- constructUrl({
436
- url: this._urls["checkoutCart"],
437
- params: {},
438
- }),
439
- query_params,
440
- body,
441
- { ...xHeaders, ...requestHeaders },
442
- { responseHeaders }
443
- );
444
-
445
- let responseData = response;
446
- if (responseHeaders) {
447
- responseData = response[0];
448
- }
449
-
450
- const {
451
- error: res_error,
452
- } = PosCartApplicationModel.CartCheckoutResponse().validate(responseData, {
453
- abortEarly: false,
454
- allowUnknown: true,
455
- });
456
-
457
- if (res_error) {
458
- if (this._conf.options.strictResponseCheck === true) {
459
- return Promise.reject(new FDKResponseValidationError(res_error));
460
- } else {
461
- Logger({
462
- level: "WARN",
463
- message: `Response Validation Warnings for application > PosCart > checkoutCart \n ${res_error}`,
464
- });
465
- }
466
- }
467
-
468
- return response;
469
- }
470
-
471
- /**
472
- * @param {PosCartApplicationValidator.GetAddressByIdParam} arg - Arg object.
473
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
474
- * @param {import("../ApplicationAPIClient").Options} - Options
475
- * @returns {Promise<PosCartApplicationModel.Address>} - Success response
476
- * @name getAddressById
477
- * @summary: Fetch address
478
- * @description: Retrieves a saved address using its ID. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/getAddressById/).
479
- */
480
- async getAddressById(
481
- {
482
- id,
483
- cartId,
484
- buyNow,
485
- mobileNo,
486
- checkoutMode,
487
- tags,
488
- isDefault,
489
- requestHeaders,
490
- } = { requestHeaders: {} },
491
- { responseHeaders } = { responseHeaders: false }
492
- ) {
493
- const { error } = PosCartApplicationValidator.getAddressById().validate(
494
- { id, cartId, buyNow, mobileNo, checkoutMode, tags, isDefault },
495
- { abortEarly: false, allowUnknown: true }
496
- );
497
- if (error) {
498
- return Promise.reject(new FDKClientValidationError(error));
499
- }
500
-
501
- // Showing warrnings if extra unknown parameters are found
502
- const {
503
- error: warrning,
504
- } = PosCartApplicationValidator.getAddressById().validate(
505
- { id, cartId, buyNow, mobileNo, checkoutMode, tags, isDefault },
506
- { abortEarly: false, allowUnknown: false }
507
- );
508
- if (warrning) {
509
- Logger({
510
- level: "WARN",
511
- message: `Parameter Validation warrnings for application > PosCart > getAddressById \n ${warrning}`,
512
- });
513
- }
514
-
515
- const query_params = {};
516
- query_params["cart_id"] = cartId;
517
- query_params["buy_now"] = buyNow;
518
- query_params["mobile_no"] = mobileNo;
519
- query_params["checkout_mode"] = checkoutMode;
520
- query_params["tags"] = tags;
521
- query_params["is_default"] = isDefault;
522
-
523
- const xHeaders = {};
524
-
525
- const response = await ApplicationAPIClient.execute(
526
- this._conf,
527
- "get",
528
- constructUrl({
529
- url: this._urls["getAddressById"],
530
- params: { id },
531
- }),
532
- query_params,
533
- undefined,
534
- { ...xHeaders, ...requestHeaders },
535
- { responseHeaders }
536
- );
537
-
538
- let responseData = response;
539
- if (responseHeaders) {
540
- responseData = response[0];
541
- }
542
-
543
- const {
544
- error: res_error,
545
- } = PosCartApplicationModel.Address().validate(responseData, {
546
- abortEarly: false,
547
- allowUnknown: true,
548
- });
549
-
550
- if (res_error) {
551
- if (this._conf.options.strictResponseCheck === true) {
552
- return Promise.reject(new FDKResponseValidationError(res_error));
553
- } else {
554
- Logger({
555
- level: "WARN",
556
- message: `Response Validation Warnings for application > PosCart > getAddressById \n ${res_error}`,
557
- });
558
- }
559
- }
560
-
561
- return response;
562
- }
563
-
564
- /**
565
- * @param {PosCartApplicationValidator.GetAddressesParam} arg - Arg object.
566
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
567
- * @param {import("../ApplicationAPIClient").Options} - Options
568
- * @returns {Promise<PosCartApplicationModel.GetAddressesResponse>} - Success response
569
- * @name getAddresses
570
- * @summary: Get saved addresses
571
- * @description: Retrieve all saved addresses for the user. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/getAddresses/).
572
- */
573
- async getAddresses(
574
- {
575
- cartId,
576
- buyNow,
577
- mobileNo,
578
- checkoutMode,
579
- tags,
580
- isDefault,
581
- requestHeaders,
582
- } = { requestHeaders: {} },
583
- { responseHeaders } = { responseHeaders: false }
584
- ) {
585
- const { error } = PosCartApplicationValidator.getAddresses().validate(
586
- { cartId, buyNow, mobileNo, checkoutMode, tags, isDefault },
587
- { abortEarly: false, allowUnknown: true }
588
- );
589
- if (error) {
590
- return Promise.reject(new FDKClientValidationError(error));
591
- }
592
-
593
- // Showing warrnings if extra unknown parameters are found
594
- const {
595
- error: warrning,
596
- } = PosCartApplicationValidator.getAddresses().validate(
597
- { cartId, buyNow, mobileNo, checkoutMode, tags, isDefault },
598
- { abortEarly: false, allowUnknown: false }
599
- );
600
- if (warrning) {
601
- Logger({
602
- level: "WARN",
603
- message: `Parameter Validation warrnings for application > PosCart > getAddresses \n ${warrning}`,
604
- });
605
- }
606
-
607
- const query_params = {};
608
- query_params["cart_id"] = cartId;
609
- query_params["buy_now"] = buyNow;
610
- query_params["mobile_no"] = mobileNo;
611
- query_params["checkout_mode"] = checkoutMode;
612
- query_params["tags"] = tags;
613
- query_params["is_default"] = isDefault;
614
-
615
- const xHeaders = {};
616
-
617
- const response = await ApplicationAPIClient.execute(
618
- this._conf,
619
- "get",
620
- constructUrl({
621
- url: this._urls["getAddresses"],
622
- params: {},
623
- }),
624
- query_params,
625
- undefined,
626
- { ...xHeaders, ...requestHeaders },
627
- { responseHeaders }
628
- );
629
-
630
- let responseData = response;
631
- if (responseHeaders) {
632
- responseData = response[0];
633
- }
634
-
635
- const {
636
- error: res_error,
637
- } = PosCartApplicationModel.GetAddressesResponse().validate(responseData, {
638
- abortEarly: false,
639
- allowUnknown: true,
640
- });
641
-
642
- if (res_error) {
643
- if (this._conf.options.strictResponseCheck === true) {
644
- return Promise.reject(new FDKResponseValidationError(res_error));
645
- } else {
646
- Logger({
647
- level: "WARN",
648
- message: `Response Validation Warnings for application > PosCart > getAddresses \n ${res_error}`,
649
- });
650
- }
651
- }
652
-
653
- return response;
654
- }
655
-
656
- /**
657
- * @param {PosCartApplicationValidator.GetAvailableDeliveryModesParam} arg
658
- * - Arg object.
659
- *
660
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
661
- * @param {import("../ApplicationAPIClient").Options} - Options
662
- * @returns {Promise<PosCartApplicationModel.CartDeliveryModesResponse>} -
663
- * Success response
664
- * @name getAvailableDeliveryModes
665
- * @summary: Delivery options
666
- * @description: Lists available delivery modes for the cart. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/getAvailableDeliveryModes/).
667
- */
668
- async getAvailableDeliveryModes(
669
- { areaCode, id, requestHeaders } = { requestHeaders: {} },
670
- { responseHeaders } = { responseHeaders: false }
671
- ) {
672
- const {
673
- error,
674
- } = PosCartApplicationValidator.getAvailableDeliveryModes().validate(
675
- { areaCode, id },
676
- { abortEarly: false, allowUnknown: true }
677
- );
678
- if (error) {
679
- return Promise.reject(new FDKClientValidationError(error));
680
- }
681
-
682
- // Showing warrnings if extra unknown parameters are found
683
- const {
684
- error: warrning,
685
- } = PosCartApplicationValidator.getAvailableDeliveryModes().validate(
686
- { areaCode, id },
687
- { abortEarly: false, allowUnknown: false }
688
- );
689
- if (warrning) {
690
- Logger({
691
- level: "WARN",
692
- message: `Parameter Validation warrnings for application > PosCart > getAvailableDeliveryModes \n ${warrning}`,
693
- });
694
- }
695
-
696
- const query_params = {};
697
- query_params["area_code"] = areaCode;
698
- query_params["id"] = id;
699
-
700
- const xHeaders = {};
701
-
702
- const response = await ApplicationAPIClient.execute(
703
- this._conf,
704
- "get",
705
- constructUrl({
706
- url: this._urls["getAvailableDeliveryModes"],
707
- params: {},
708
- }),
709
- query_params,
710
- undefined,
711
- { ...xHeaders, ...requestHeaders },
712
- { responseHeaders }
713
- );
714
-
715
- let responseData = response;
716
- if (responseHeaders) {
717
- responseData = response[0];
718
- }
719
-
720
- const {
721
- error: res_error,
722
- } = PosCartApplicationModel.CartDeliveryModesResponse().validate(
723
- responseData,
724
- { abortEarly: false, allowUnknown: true }
725
- );
726
-
727
- if (res_error) {
728
- if (this._conf.options.strictResponseCheck === true) {
729
- return Promise.reject(new FDKResponseValidationError(res_error));
730
- } else {
731
- Logger({
732
- level: "WARN",
733
- message: `Response Validation Warnings for application > PosCart > getAvailableDeliveryModes \n ${res_error}`,
734
- });
735
- }
736
- }
737
-
738
- return response;
739
- }
740
-
741
- /**
742
- * @param {PosCartApplicationValidator.GetBulkDiscountOffersParam} arg - Arg object.
743
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
744
- * @param {import("../ApplicationAPIClient").Options} - Options
745
- * @returns {Promise<PosCartApplicationModel.BulkPriceResponse>} - Success response
746
- * @name getBulkDiscountOffers
747
- * @summary: Bulk discounts
748
- * @description: Lists available bulk discount offers for cart items. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/getBulkDiscountOffers/).
749
- */
750
- async getBulkDiscountOffers(
751
- { itemId, articleId, uid, slug, requestHeaders } = { requestHeaders: {} },
752
- { responseHeaders } = { responseHeaders: false }
753
- ) {
754
- const {
755
- error,
756
- } = PosCartApplicationValidator.getBulkDiscountOffers().validate(
757
- { itemId, articleId, uid, slug },
758
- { abortEarly: false, allowUnknown: true }
759
- );
760
- if (error) {
761
- return Promise.reject(new FDKClientValidationError(error));
762
- }
763
-
764
- // Showing warrnings if extra unknown parameters are found
765
- const {
766
- error: warrning,
767
- } = PosCartApplicationValidator.getBulkDiscountOffers().validate(
768
- { itemId, articleId, uid, slug },
769
- { abortEarly: false, allowUnknown: false }
770
- );
771
- if (warrning) {
772
- Logger({
773
- level: "WARN",
774
- message: `Parameter Validation warrnings for application > PosCart > getBulkDiscountOffers \n ${warrning}`,
775
- });
776
- }
777
-
778
- const query_params = {};
779
- query_params["item_id"] = itemId;
780
- query_params["article_id"] = articleId;
781
- query_params["uid"] = uid;
782
- query_params["slug"] = slug;
783
-
784
- const xHeaders = {};
785
-
786
- const response = await ApplicationAPIClient.execute(
787
- this._conf,
788
- "get",
789
- constructUrl({
790
- url: this._urls["getBulkDiscountOffers"],
791
- params: {},
792
- }),
793
- query_params,
794
- undefined,
795
- { ...xHeaders, ...requestHeaders },
796
- { responseHeaders }
797
- );
798
-
799
- let responseData = response;
800
- if (responseHeaders) {
801
- responseData = response[0];
802
- }
803
-
804
- const {
805
- error: res_error,
806
- } = PosCartApplicationModel.BulkPriceResponse().validate(responseData, {
807
- abortEarly: false,
808
- allowUnknown: true,
809
- });
810
-
811
- if (res_error) {
812
- if (this._conf.options.strictResponseCheck === true) {
813
- return Promise.reject(new FDKResponseValidationError(res_error));
814
- } else {
815
- Logger({
816
- level: "WARN",
817
- message: `Response Validation Warnings for application > PosCart > getBulkDiscountOffers \n ${res_error}`,
818
- });
819
- }
820
- }
821
-
822
- return response;
823
- }
824
-
825
- /**
826
- * @param {PosCartApplicationValidator.GetCartParam} arg - Arg object.
827
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
828
- * @param {import("../ApplicationAPIClient").Options} - Options
829
- * @returns {Promise<PosCartApplicationModel.CartDetailResponse>} - Success response
830
- * @name getCart
831
- * @summary: Retrieve cart details
832
- * @description: Retrieve the current state and items in the shopping cart. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/getCart/).
833
- */
834
- async getCart(
835
- { id, i, b, c, assignCardId, areaCode, buyNow, requestHeaders } = {
836
- requestHeaders: {},
837
- },
838
- { responseHeaders } = { responseHeaders: false }
839
- ) {
840
- const { error } = PosCartApplicationValidator.getCart().validate(
841
- { id, i, b, c, assignCardId, areaCode, buyNow },
842
- { abortEarly: false, allowUnknown: true }
843
- );
844
- if (error) {
845
- return Promise.reject(new FDKClientValidationError(error));
846
- }
847
-
848
- // Showing warrnings if extra unknown parameters are found
849
- const { error: warrning } = PosCartApplicationValidator.getCart().validate(
850
- { id, i, b, c, assignCardId, areaCode, buyNow },
851
- { abortEarly: false, allowUnknown: false }
852
- );
853
- if (warrning) {
854
- Logger({
855
- level: "WARN",
856
- message: `Parameter Validation warrnings for application > PosCart > getCart \n ${warrning}`,
857
- });
858
- }
859
-
860
- const query_params = {};
861
- query_params["id"] = id;
862
- query_params["i"] = i;
863
- query_params["b"] = b;
864
- query_params["c"] = c;
865
- query_params["assign_card_id"] = assignCardId;
866
- query_params["area_code"] = areaCode;
867
- query_params["buy_now"] = buyNow;
868
-
869
- const xHeaders = {};
870
-
871
- const response = await ApplicationAPIClient.execute(
872
- this._conf,
873
- "get",
874
- constructUrl({
875
- url: this._urls["getCart"],
876
- params: {},
877
- }),
878
- query_params,
879
- undefined,
880
- { ...xHeaders, ...requestHeaders },
881
- { responseHeaders }
882
- );
883
-
884
- let responseData = response;
885
- if (responseHeaders) {
886
- responseData = response[0];
887
- }
888
-
889
- const {
890
- error: res_error,
891
- } = PosCartApplicationModel.CartDetailResponse().validate(responseData, {
892
- abortEarly: false,
893
- allowUnknown: true,
894
- });
895
-
896
- if (res_error) {
897
- if (this._conf.options.strictResponseCheck === true) {
898
- return Promise.reject(new FDKResponseValidationError(res_error));
899
- } else {
900
- Logger({
901
- level: "WARN",
902
- message: `Response Validation Warnings for application > PosCart > getCart \n ${res_error}`,
903
- });
904
- }
905
- }
906
-
907
- return response;
908
- }
909
-
910
- /**
911
- * @param {PosCartApplicationValidator.GetCartLastModifiedParam} arg - Arg object.
912
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
913
- * @param {import("../ApplicationAPIClient").Options} - Options
914
- * @returns {Promise<any>} - Success response
915
- * @name getCartLastModified
916
- * @summary: Cart modification time
917
- * @description: Gets the last modified timestamp for the cart. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/getCartLastModified/).
918
- */
919
- async getCartLastModified(
920
- { id, requestHeaders } = { requestHeaders: {} },
921
- { responseHeaders } = { responseHeaders: false }
922
- ) {
923
- const {
924
- error,
925
- } = PosCartApplicationValidator.getCartLastModified().validate(
926
- { id },
927
- { abortEarly: false, allowUnknown: true }
928
- );
929
- if (error) {
930
- return Promise.reject(new FDKClientValidationError(error));
931
- }
932
-
933
- // Showing warrnings if extra unknown parameters are found
934
- const {
935
- error: warrning,
936
- } = PosCartApplicationValidator.getCartLastModified().validate(
937
- { id },
938
- { abortEarly: false, allowUnknown: false }
939
- );
940
- if (warrning) {
941
- Logger({
942
- level: "WARN",
943
- message: `Parameter Validation warrnings for application > PosCart > getCartLastModified \n ${warrning}`,
944
- });
945
- }
946
-
947
- const query_params = {};
948
- query_params["id"] = id;
949
-
950
- const xHeaders = {};
951
-
952
- const response = await ApplicationAPIClient.execute(
953
- this._conf,
954
- "head",
955
- constructUrl({
956
- url: this._urls["getCartLastModified"],
957
- params: {},
958
- }),
959
- query_params,
960
- undefined,
961
- { ...xHeaders, ...requestHeaders },
962
- { responseHeaders }
963
- );
964
-
965
- let responseData = response;
966
- if (responseHeaders) {
967
- responseData = response[0];
968
- }
969
-
970
- const { error: res_error } = Joi.string()
971
- .allow("")
972
- .validate(responseData, { abortEarly: false, allowUnknown: true });
973
-
974
- if (res_error) {
975
- if (this._conf.options.strictResponseCheck === true) {
976
- return Promise.reject(new FDKResponseValidationError(res_error));
977
- } else {
978
- Logger({
979
- level: "WARN",
980
- message: `Response Validation Warnings for application > PosCart > getCartLastModified \n ${res_error}`,
981
- });
982
- }
983
- }
984
-
985
- return response;
986
- }
987
-
988
- /**
989
- * @param {PosCartApplicationValidator.GetCartShareLinkParam} arg - Arg object.
990
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
991
- * @param {import("../ApplicationAPIClient").Options} - Options
992
- * @returns {Promise<PosCartApplicationModel.GetShareCartLinkResponse>} -
993
- * Success response
994
- * @name getCartShareLink
995
- * @summary: Share cart link
996
- * @description: Generates a shareable link for the current cart. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/getCartShareLink/).
997
- */
998
- async getCartShareLink(
999
- { body, requestHeaders } = { requestHeaders: {} },
1000
- { responseHeaders } = { responseHeaders: false }
1001
- ) {
1002
- const { error } = PosCartApplicationValidator.getCartShareLink().validate(
1003
- { body },
1004
- { abortEarly: false, allowUnknown: true }
1005
- );
1006
- if (error) {
1007
- return Promise.reject(new FDKClientValidationError(error));
1008
- }
1009
-
1010
- // Showing warrnings if extra unknown parameters are found
1011
- const {
1012
- error: warrning,
1013
- } = PosCartApplicationValidator.getCartShareLink().validate(
1014
- { body },
1015
- { abortEarly: false, allowUnknown: false }
1016
- );
1017
- if (warrning) {
1018
- Logger({
1019
- level: "WARN",
1020
- message: `Parameter Validation warrnings for application > PosCart > getCartShareLink \n ${warrning}`,
1021
- });
1022
- }
1023
-
1024
- const query_params = {};
1025
-
1026
- const xHeaders = {};
1027
-
1028
- const response = await ApplicationAPIClient.execute(
1029
- this._conf,
1030
- "post",
1031
- constructUrl({
1032
- url: this._urls["getCartShareLink"],
1033
- params: {},
1034
- }),
1035
- query_params,
1036
- body,
1037
- { ...xHeaders, ...requestHeaders },
1038
- { responseHeaders }
1039
- );
1040
-
1041
- let responseData = response;
1042
- if (responseHeaders) {
1043
- responseData = response[0];
1044
- }
1045
-
1046
- const {
1047
- error: res_error,
1048
- } = PosCartApplicationModel.GetShareCartLinkResponse().validate(
1049
- responseData,
1050
- { abortEarly: false, allowUnknown: true }
1051
- );
1052
-
1053
- if (res_error) {
1054
- if (this._conf.options.strictResponseCheck === true) {
1055
- return Promise.reject(new FDKResponseValidationError(res_error));
1056
- } else {
1057
- Logger({
1058
- level: "WARN",
1059
- message: `Response Validation Warnings for application > PosCart > getCartShareLink \n ${res_error}`,
1060
- });
1061
- }
1062
- }
1063
-
1064
- return response;
1065
- }
1066
-
1067
- /**
1068
- * @param {PosCartApplicationValidator.GetCartSharedItemsParam} arg - Arg object.
1069
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
1070
- * @param {import("../ApplicationAPIClient").Options} - Options
1071
- * @returns {Promise<PosCartApplicationModel.SharedCartResponse>} - Success response
1072
- * @name getCartSharedItems
1073
- * @summary: Shared cart items
1074
- * @description: Retrieves items from a shared cart link. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/getCartSharedItems/).
1075
- */
1076
- async getCartSharedItems(
1077
- { token, requestHeaders } = { requestHeaders: {} },
1078
- { responseHeaders } = { responseHeaders: false }
1079
- ) {
1080
- const { error } = PosCartApplicationValidator.getCartSharedItems().validate(
1081
- { token },
1082
- { abortEarly: false, allowUnknown: true }
1083
- );
1084
- if (error) {
1085
- return Promise.reject(new FDKClientValidationError(error));
1086
- }
1087
-
1088
- // Showing warrnings if extra unknown parameters are found
1089
- const {
1090
- error: warrning,
1091
- } = PosCartApplicationValidator.getCartSharedItems().validate(
1092
- { token },
1093
- { abortEarly: false, allowUnknown: false }
1094
- );
1095
- if (warrning) {
1096
- Logger({
1097
- level: "WARN",
1098
- message: `Parameter Validation warrnings for application > PosCart > getCartSharedItems \n ${warrning}`,
1099
- });
1100
- }
1101
-
1102
- const query_params = {};
1103
-
1104
- const xHeaders = {};
1105
-
1106
- const response = await ApplicationAPIClient.execute(
1107
- this._conf,
1108
- "get",
1109
- constructUrl({
1110
- url: this._urls["getCartSharedItems"],
1111
- params: { token },
1112
- }),
1113
- query_params,
1114
- undefined,
1115
- { ...xHeaders, ...requestHeaders },
1116
- { responseHeaders }
1117
- );
1118
-
1119
- let responseData = response;
1120
- if (responseHeaders) {
1121
- responseData = response[0];
1122
- }
1123
-
1124
- const {
1125
- error: res_error,
1126
- } = PosCartApplicationModel.SharedCartResponse().validate(responseData, {
1127
- abortEarly: false,
1128
- allowUnknown: true,
1129
- });
1130
-
1131
- if (res_error) {
1132
- if (this._conf.options.strictResponseCheck === true) {
1133
- return Promise.reject(new FDKResponseValidationError(res_error));
1134
- } else {
1135
- Logger({
1136
- level: "WARN",
1137
- message: `Response Validation Warnings for application > PosCart > getCartSharedItems \n ${res_error}`,
1138
- });
1139
- }
1140
- }
1141
-
1142
- return response;
1143
- }
1144
-
1145
- /**
1146
- * @param {PosCartApplicationValidator.GetCouponsParam} arg - Arg object.
1147
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
1148
- * @param {import("../ApplicationAPIClient").Options} - Options
1149
- * @returns {Promise<PosCartApplicationModel.GetCouponResponse>} - Success response
1150
- * @name getCoupons
1151
- * @summary: List available coupons
1152
- * @description: Retrieve coupons that can be applied to the cart. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/getCoupons/).
1153
- */
1154
- async getCoupons(
1155
- { id, buyNow, requestHeaders } = { requestHeaders: {} },
1156
- { responseHeaders } = { responseHeaders: false }
1157
- ) {
1158
- const { error } = PosCartApplicationValidator.getCoupons().validate(
1159
- { id, buyNow },
1160
- { abortEarly: false, allowUnknown: true }
1161
- );
1162
- if (error) {
1163
- return Promise.reject(new FDKClientValidationError(error));
1164
- }
1165
-
1166
- // Showing warrnings if extra unknown parameters are found
1167
- const {
1168
- error: warrning,
1169
- } = PosCartApplicationValidator.getCoupons().validate(
1170
- { id, buyNow },
1171
- { abortEarly: false, allowUnknown: false }
1172
- );
1173
- if (warrning) {
1174
- Logger({
1175
- level: "WARN",
1176
- message: `Parameter Validation warrnings for application > PosCart > getCoupons \n ${warrning}`,
1177
- });
1178
- }
1179
-
1180
- const query_params = {};
1181
- query_params["id"] = id;
1182
- query_params["buy_now"] = buyNow;
1183
-
1184
- const xHeaders = {};
1185
-
1186
- const response = await ApplicationAPIClient.execute(
1187
- this._conf,
1188
- "get",
1189
- constructUrl({
1190
- url: this._urls["getCoupons"],
1191
- params: {},
1192
- }),
1193
- query_params,
1194
- undefined,
1195
- { ...xHeaders, ...requestHeaders },
1196
- { responseHeaders }
1197
- );
1198
-
1199
- let responseData = response;
1200
- if (responseHeaders) {
1201
- responseData = response[0];
1202
- }
1203
-
1204
- const {
1205
- error: res_error,
1206
- } = PosCartApplicationModel.GetCouponResponse().validate(responseData, {
1207
- abortEarly: false,
1208
- allowUnknown: true,
1209
- });
1210
-
1211
- if (res_error) {
1212
- if (this._conf.options.strictResponseCheck === true) {
1213
- return Promise.reject(new FDKResponseValidationError(res_error));
1214
- } else {
1215
- Logger({
1216
- level: "WARN",
1217
- message: `Response Validation Warnings for application > PosCart > getCoupons \n ${res_error}`,
1218
- });
1219
- }
1220
- }
1221
-
1222
- return response;
1223
- }
1224
-
1225
- /**
1226
- * @param {PosCartApplicationValidator.GetItemCountParam} arg - Arg object.
1227
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
1228
- * @param {import("../ApplicationAPIClient").Options} - Options
1229
- * @returns {Promise<PosCartApplicationModel.CartItemCountResponse>} -
1230
- * Success response
1231
- * @name getItemCount
1232
- * @summary: Count cart items
1233
- * @description: Gets the total number of items in the cart. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/getItemCount/).
1234
- */
1235
- async getItemCount(
1236
- { id, buyNow, requestHeaders } = { requestHeaders: {} },
1237
- { responseHeaders } = { responseHeaders: false }
1238
- ) {
1239
- const { error } = PosCartApplicationValidator.getItemCount().validate(
1240
- { id, buyNow },
1241
- { abortEarly: false, allowUnknown: true }
1242
- );
1243
- if (error) {
1244
- return Promise.reject(new FDKClientValidationError(error));
1245
- }
1246
-
1247
- // Showing warrnings if extra unknown parameters are found
1248
- const {
1249
- error: warrning,
1250
- } = PosCartApplicationValidator.getItemCount().validate(
1251
- { id, buyNow },
1252
- { abortEarly: false, allowUnknown: false }
1253
- );
1254
- if (warrning) {
1255
- Logger({
1256
- level: "WARN",
1257
- message: `Parameter Validation warrnings for application > PosCart > getItemCount \n ${warrning}`,
1258
- });
1259
- }
1260
-
1261
- const query_params = {};
1262
- query_params["id"] = id;
1263
- query_params["buy_now"] = buyNow;
1264
-
1265
- const xHeaders = {};
1266
-
1267
- const response = await ApplicationAPIClient.execute(
1268
- this._conf,
1269
- "get",
1270
- constructUrl({
1271
- url: this._urls["getItemCount"],
1272
- params: {},
1273
- }),
1274
- query_params,
1275
- undefined,
1276
- { ...xHeaders, ...requestHeaders },
1277
- { responseHeaders }
1278
- );
1279
-
1280
- let responseData = response;
1281
- if (responseHeaders) {
1282
- responseData = response[0];
1283
- }
1284
-
1285
- const {
1286
- error: res_error,
1287
- } = PosCartApplicationModel.CartItemCountResponse().validate(responseData, {
1288
- abortEarly: false,
1289
- allowUnknown: true,
1290
- });
1291
-
1292
- if (res_error) {
1293
- if (this._conf.options.strictResponseCheck === true) {
1294
- return Promise.reject(new FDKResponseValidationError(res_error));
1295
- } else {
1296
- Logger({
1297
- level: "WARN",
1298
- message: `Response Validation Warnings for application > PosCart > getItemCount \n ${res_error}`,
1299
- });
1300
- }
1301
- }
1302
-
1303
- return response;
1304
- }
1305
-
1306
- /**
1307
- * @param {PosCartApplicationValidator.GetShipmentsParam} arg - Arg object.
1308
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
1309
- * @param {import("../ApplicationAPIClient").Options} - Options
1310
- * @returns {Promise<PosCartApplicationModel.CartShipmentsResponse>} -
1311
- * Success response
1312
- * @name getShipments
1313
- * @summary: List shipments
1314
- * @description: Retrieve shipment details for items in the cart. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/getShipments/).
1315
- */
1316
- async getShipments(
1317
- {
1318
- pickAtStoreUid,
1319
- orderingStoreId,
1320
- p,
1321
- id,
1322
- addressId,
1323
- areaCode,
1324
- orderType,
1325
- requestHeaders,
1326
- } = { requestHeaders: {} },
1327
- { responseHeaders } = { responseHeaders: false }
1328
- ) {
1329
- const { error } = PosCartApplicationValidator.getShipments().validate(
1330
- {
1331
- pickAtStoreUid,
1332
- orderingStoreId,
1333
- p,
1334
- id,
1335
- addressId,
1336
- areaCode,
1337
- orderType,
1338
- },
1339
- { abortEarly: false, allowUnknown: true }
1340
- );
1341
- if (error) {
1342
- return Promise.reject(new FDKClientValidationError(error));
1343
- }
1344
-
1345
- // Showing warrnings if extra unknown parameters are found
1346
- const {
1347
- error: warrning,
1348
- } = PosCartApplicationValidator.getShipments().validate(
1349
- {
1350
- pickAtStoreUid,
1351
- orderingStoreId,
1352
- p,
1353
- id,
1354
- addressId,
1355
- areaCode,
1356
- orderType,
1357
- },
1358
- { abortEarly: false, allowUnknown: false }
1359
- );
1360
- if (warrning) {
1361
- Logger({
1362
- level: "WARN",
1363
- message: `Parameter Validation warrnings for application > PosCart > getShipments \n ${warrning}`,
1364
- });
1365
- }
1366
-
1367
- const query_params = {};
1368
- query_params["pick_at_store_uid"] = pickAtStoreUid;
1369
- query_params["ordering_store_id"] = orderingStoreId;
1370
- query_params["p"] = p;
1371
- query_params["id"] = id;
1372
- query_params["address_id"] = addressId;
1373
- query_params["area_code"] = areaCode;
1374
- query_params["order_type"] = orderType;
1375
-
1376
- const xHeaders = {};
1377
-
1378
- const response = await ApplicationAPIClient.execute(
1379
- this._conf,
1380
- "get",
1381
- constructUrl({
1382
- url: this._urls["getShipments"],
1383
- params: {},
1384
- }),
1385
- query_params,
1386
- undefined,
1387
- { ...xHeaders, ...requestHeaders },
1388
- { responseHeaders }
1389
- );
1390
-
1391
- let responseData = response;
1392
- if (responseHeaders) {
1393
- responseData = response[0];
1394
- }
1395
-
1396
- const {
1397
- error: res_error,
1398
- } = PosCartApplicationModel.CartShipmentsResponse().validate(responseData, {
1399
- abortEarly: false,
1400
- allowUnknown: true,
1401
- });
1402
-
1403
- if (res_error) {
1404
- if (this._conf.options.strictResponseCheck === true) {
1405
- return Promise.reject(new FDKResponseValidationError(res_error));
1406
- } else {
1407
- Logger({
1408
- level: "WARN",
1409
- message: `Response Validation Warnings for application > PosCart > getShipments \n ${res_error}`,
1410
- });
1411
- }
1412
- }
1413
-
1414
- return response;
1415
- }
1416
-
1417
- /**
1418
- * @param {PosCartApplicationValidator.GetStoreAddressByUidParam} arg - Arg object.
1419
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
1420
- * @param {import("../ApplicationAPIClient").Options} - Options
1421
- * @returns {Promise<PosCartApplicationModel.StoreDetailsResponse>} - Success response
1422
- * @name getStoreAddressByUid
1423
- * @summary: Store address
1424
- * @description: Gets the address of the store by its UID. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/getStoreAddressByUid/).
1425
- */
1426
- async getStoreAddressByUid(
1427
- { storeUid, requestHeaders } = { requestHeaders: {} },
1428
- { responseHeaders } = { responseHeaders: false }
1429
- ) {
1430
- const {
1431
- error,
1432
- } = PosCartApplicationValidator.getStoreAddressByUid().validate(
1433
- { storeUid },
1434
- { abortEarly: false, allowUnknown: true }
1435
- );
1436
- if (error) {
1437
- return Promise.reject(new FDKClientValidationError(error));
1438
- }
1439
-
1440
- // Showing warrnings if extra unknown parameters are found
1441
- const {
1442
- error: warrning,
1443
- } = PosCartApplicationValidator.getStoreAddressByUid().validate(
1444
- { storeUid },
1445
- { abortEarly: false, allowUnknown: false }
1446
- );
1447
- if (warrning) {
1448
- Logger({
1449
- level: "WARN",
1450
- message: `Parameter Validation warrnings for application > PosCart > getStoreAddressByUid \n ${warrning}`,
1451
- });
1452
- }
1453
-
1454
- const query_params = {};
1455
- query_params["store_uid"] = storeUid;
1456
-
1457
- const xHeaders = {};
1458
-
1459
- const response = await ApplicationAPIClient.execute(
1460
- this._conf,
1461
- "get",
1462
- constructUrl({
1463
- url: this._urls["getStoreAddressByUid"],
1464
- params: {},
1465
- }),
1466
- query_params,
1467
- undefined,
1468
- { ...xHeaders, ...requestHeaders },
1469
- { responseHeaders }
1470
- );
1471
-
1472
- let responseData = response;
1473
- if (responseHeaders) {
1474
- responseData = response[0];
1475
- }
1476
-
1477
- const {
1478
- error: res_error,
1479
- } = PosCartApplicationModel.StoreDetailsResponse().validate(responseData, {
1480
- abortEarly: false,
1481
- allowUnknown: true,
1482
- });
1483
-
1484
- if (res_error) {
1485
- if (this._conf.options.strictResponseCheck === true) {
1486
- return Promise.reject(new FDKResponseValidationError(res_error));
1487
- } else {
1488
- Logger({
1489
- level: "WARN",
1490
- message: `Response Validation Warnings for application > PosCart > getStoreAddressByUid \n ${res_error}`,
1491
- });
1492
- }
1493
- }
1494
-
1495
- return response;
1496
- }
1497
-
1498
- /**
1499
- * @param {PosCartApplicationValidator.RemoveAddressParam} arg - Arg object.
1500
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
1501
- * @param {import("../ApplicationAPIClient").Options} - Options
1502
- * @returns {Promise<PosCartApplicationModel.DeleteAddressResponse>} -
1503
- * Success response
1504
- * @name removeAddress
1505
- * @summary: Delete address
1506
- * @description: Removes a saved address from the user's profile. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/removeAddress/).
1507
- */
1508
- async removeAddress(
1509
- { id, requestHeaders } = { requestHeaders: {} },
1510
- { responseHeaders } = { responseHeaders: false }
1511
- ) {
1512
- const { error } = PosCartApplicationValidator.removeAddress().validate(
1513
- { id },
1514
- { abortEarly: false, allowUnknown: true }
1515
- );
1516
- if (error) {
1517
- return Promise.reject(new FDKClientValidationError(error));
1518
- }
1519
-
1520
- // Showing warrnings if extra unknown parameters are found
1521
- const {
1522
- error: warrning,
1523
- } = PosCartApplicationValidator.removeAddress().validate(
1524
- { id },
1525
- { abortEarly: false, allowUnknown: false }
1526
- );
1527
- if (warrning) {
1528
- Logger({
1529
- level: "WARN",
1530
- message: `Parameter Validation warrnings for application > PosCart > removeAddress \n ${warrning}`,
1531
- });
1532
- }
1533
-
1534
- const query_params = {};
1535
-
1536
- const xHeaders = {};
1537
-
1538
- const response = await ApplicationAPIClient.execute(
1539
- this._conf,
1540
- "delete",
1541
- constructUrl({
1542
- url: this._urls["removeAddress"],
1543
- params: { id },
1544
- }),
1545
- query_params,
1546
- undefined,
1547
- { ...xHeaders, ...requestHeaders },
1548
- { responseHeaders }
1549
- );
1550
-
1551
- let responseData = response;
1552
- if (responseHeaders) {
1553
- responseData = response[0];
1554
- }
1555
-
1556
- const {
1557
- error: res_error,
1558
- } = PosCartApplicationModel.DeleteAddressResponse().validate(responseData, {
1559
- abortEarly: false,
1560
- allowUnknown: true,
1561
- });
1562
-
1563
- if (res_error) {
1564
- if (this._conf.options.strictResponseCheck === true) {
1565
- return Promise.reject(new FDKResponseValidationError(res_error));
1566
- } else {
1567
- Logger({
1568
- level: "WARN",
1569
- message: `Response Validation Warnings for application > PosCart > removeAddress \n ${res_error}`,
1570
- });
1571
- }
1572
- }
1573
-
1574
- return response;
1575
- }
1576
-
1577
- /**
1578
- * @param {PosCartApplicationValidator.RemoveCouponParam} arg - Arg object.
1579
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
1580
- * @param {import("../ApplicationAPIClient").Options} - Options
1581
- * @returns {Promise<PosCartApplicationModel.CartDetailResponse>} - Success response
1582
- * @name removeCoupon
1583
- * @summary: Remove coupon
1584
- * @description: Removes an applied coupon from the cart. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/removeCoupon/).
1585
- */
1586
- async removeCoupon(
1587
- { id, buyNow, requestHeaders } = { requestHeaders: {} },
1588
- { responseHeaders } = { responseHeaders: false }
1589
- ) {
1590
- const { error } = PosCartApplicationValidator.removeCoupon().validate(
1591
- { id, buyNow },
1592
- { abortEarly: false, allowUnknown: true }
1593
- );
1594
- if (error) {
1595
- return Promise.reject(new FDKClientValidationError(error));
1596
- }
1597
-
1598
- // Showing warrnings if extra unknown parameters are found
1599
- const {
1600
- error: warrning,
1601
- } = PosCartApplicationValidator.removeCoupon().validate(
1602
- { id, buyNow },
1603
- { abortEarly: false, allowUnknown: false }
1604
- );
1605
- if (warrning) {
1606
- Logger({
1607
- level: "WARN",
1608
- message: `Parameter Validation warrnings for application > PosCart > removeCoupon \n ${warrning}`,
1609
- });
1610
- }
1611
-
1612
- const query_params = {};
1613
- query_params["id"] = id;
1614
- query_params["buy_now"] = buyNow;
1615
-
1616
- const xHeaders = {};
1617
-
1618
- const response = await ApplicationAPIClient.execute(
1619
- this._conf,
1620
- "delete",
1621
- constructUrl({
1622
- url: this._urls["removeCoupon"],
1623
- params: {},
1624
- }),
1625
- query_params,
1626
- undefined,
1627
- { ...xHeaders, ...requestHeaders },
1628
- { responseHeaders }
1629
- );
1630
-
1631
- let responseData = response;
1632
- if (responseHeaders) {
1633
- responseData = response[0];
1634
- }
1635
-
1636
- const {
1637
- error: res_error,
1638
- } = PosCartApplicationModel.CartDetailResponse().validate(responseData, {
1639
- abortEarly: false,
1640
- allowUnknown: true,
1641
- });
1642
-
1643
- if (res_error) {
1644
- if (this._conf.options.strictResponseCheck === true) {
1645
- return Promise.reject(new FDKResponseValidationError(res_error));
1646
- } else {
1647
- Logger({
1648
- level: "WARN",
1649
- message: `Response Validation Warnings for application > PosCart > removeCoupon \n ${res_error}`,
1650
- });
1651
- }
1652
- }
1653
-
1654
- return response;
1655
- }
1656
-
1657
- /**
1658
- * @param {PosCartApplicationValidator.SelectAddressParam} arg - Arg object.
1659
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
1660
- * @param {import("../ApplicationAPIClient").Options} - Options
1661
- * @returns {Promise<PosCartApplicationModel.CartDetailResponse>} - Success response
1662
- * @name selectAddress
1663
- * @summary: Choose delivery address
1664
- * @description: Selects an address for the cart's delivery. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/selectAddress/).
1665
- */
1666
- async selectAddress(
1667
- { body, cartId, buyNow, i, b, requestHeaders } = { requestHeaders: {} },
1668
- { responseHeaders } = { responseHeaders: false }
1669
- ) {
1670
- const { error } = PosCartApplicationValidator.selectAddress().validate(
1671
- { body, cartId, buyNow, i, b },
1672
- { abortEarly: false, allowUnknown: true }
1673
- );
1674
- if (error) {
1675
- return Promise.reject(new FDKClientValidationError(error));
1676
- }
1677
-
1678
- // Showing warrnings if extra unknown parameters are found
1679
- const {
1680
- error: warrning,
1681
- } = PosCartApplicationValidator.selectAddress().validate(
1682
- { body, cartId, buyNow, i, b },
1683
- { abortEarly: false, allowUnknown: false }
1684
- );
1685
- if (warrning) {
1686
- Logger({
1687
- level: "WARN",
1688
- message: `Parameter Validation warrnings for application > PosCart > selectAddress \n ${warrning}`,
1689
- });
1690
- }
1691
-
1692
- const query_params = {};
1693
- query_params["cart_id"] = cartId;
1694
- query_params["buy_now"] = buyNow;
1695
- query_params["i"] = i;
1696
- query_params["b"] = b;
1697
-
1698
- const xHeaders = {};
1699
-
1700
- const response = await ApplicationAPIClient.execute(
1701
- this._conf,
1702
- "post",
1703
- constructUrl({
1704
- url: this._urls["selectAddress"],
1705
- params: {},
1706
- }),
1707
- query_params,
1708
- body,
1709
- { ...xHeaders, ...requestHeaders },
1710
- { responseHeaders }
1711
- );
1712
-
1713
- let responseData = response;
1714
- if (responseHeaders) {
1715
- responseData = response[0];
1716
- }
1717
-
1718
- const {
1719
- error: res_error,
1720
- } = PosCartApplicationModel.CartDetailResponse().validate(responseData, {
1721
- abortEarly: false,
1722
- allowUnknown: true,
1723
- });
1724
-
1725
- if (res_error) {
1726
- if (this._conf.options.strictResponseCheck === true) {
1727
- return Promise.reject(new FDKResponseValidationError(res_error));
1728
- } else {
1729
- Logger({
1730
- level: "WARN",
1731
- message: `Response Validation Warnings for application > PosCart > selectAddress \n ${res_error}`,
1732
- });
1733
- }
1734
- }
1735
-
1736
- return response;
1737
- }
1738
-
1739
- /**
1740
- * @param {PosCartApplicationValidator.SelectPaymentModeParam} arg - Arg object.
1741
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
1742
- * @param {import("../ApplicationAPIClient").Options} - Options
1743
- * @returns {Promise<PosCartApplicationModel.CartDetailResponse>} - Success response
1744
- * @name selectPaymentMode
1745
- * @summary: Pick payment method
1746
- * @description: Chooses a payment mode for the checkout process. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/selectPaymentMode/).
1747
- */
1748
- async selectPaymentMode(
1749
- { body, id, buyNow, requestHeaders } = { requestHeaders: {} },
1750
- { responseHeaders } = { responseHeaders: false }
1751
- ) {
1752
- const { error } = PosCartApplicationValidator.selectPaymentMode().validate(
1753
- { body, id, buyNow },
1754
- { abortEarly: false, allowUnknown: true }
1755
- );
1756
- if (error) {
1757
- return Promise.reject(new FDKClientValidationError(error));
1758
- }
1759
-
1760
- // Showing warrnings if extra unknown parameters are found
1761
- const {
1762
- error: warrning,
1763
- } = PosCartApplicationValidator.selectPaymentMode().validate(
1764
- { body, id, buyNow },
1765
- { abortEarly: false, allowUnknown: false }
1766
- );
1767
- if (warrning) {
1768
- Logger({
1769
- level: "WARN",
1770
- message: `Parameter Validation warrnings for application > PosCart > selectPaymentMode \n ${warrning}`,
1771
- });
1772
- }
1773
-
1774
- const query_params = {};
1775
- query_params["id"] = id;
1776
- query_params["buy_now"] = buyNow;
1777
-
1778
- const xHeaders = {};
1779
-
1780
- const response = await ApplicationAPIClient.execute(
1781
- this._conf,
1782
- "put",
1783
- constructUrl({
1784
- url: this._urls["selectPaymentMode"],
1785
- params: {},
1786
- }),
1787
- query_params,
1788
- body,
1789
- { ...xHeaders, ...requestHeaders },
1790
- { responseHeaders }
1791
- );
1792
-
1793
- let responseData = response;
1794
- if (responseHeaders) {
1795
- responseData = response[0];
1796
- }
1797
-
1798
- const {
1799
- error: res_error,
1800
- } = PosCartApplicationModel.CartDetailResponse().validate(responseData, {
1801
- abortEarly: false,
1802
- allowUnknown: true,
1803
- });
1804
-
1805
- if (res_error) {
1806
- if (this._conf.options.strictResponseCheck === true) {
1807
- return Promise.reject(new FDKResponseValidationError(res_error));
1808
- } else {
1809
- Logger({
1810
- level: "WARN",
1811
- message: `Response Validation Warnings for application > PosCart > selectPaymentMode \n ${res_error}`,
1812
- });
1813
- }
1814
- }
1815
-
1816
- return response;
1817
- }
1818
-
1819
- /**
1820
- * @param {PosCartApplicationValidator.UpdateAddressParam} arg - Arg object.
1821
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
1822
- * @param {import("../ApplicationAPIClient").Options} - Options
1823
- * @returns {Promise<PosCartApplicationModel.UpdateAddressResponse>} -
1824
- * Success response
1825
- * @name updateAddress
1826
- * @summary: Update address
1827
- * @description: Modifies a saved address. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/updateAddress/).
1828
- */
1829
- async updateAddress(
1830
- { id, body, requestHeaders } = { requestHeaders: {} },
1831
- { responseHeaders } = { responseHeaders: false }
1832
- ) {
1833
- const { error } = PosCartApplicationValidator.updateAddress().validate(
1834
- { id, body },
1835
- { abortEarly: false, allowUnknown: true }
1836
- );
1837
- if (error) {
1838
- return Promise.reject(new FDKClientValidationError(error));
1839
- }
1840
-
1841
- // Showing warrnings if extra unknown parameters are found
1842
- const {
1843
- error: warrning,
1844
- } = PosCartApplicationValidator.updateAddress().validate(
1845
- { id, body },
1846
- { abortEarly: false, allowUnknown: false }
1847
- );
1848
- if (warrning) {
1849
- Logger({
1850
- level: "WARN",
1851
- message: `Parameter Validation warrnings for application > PosCart > updateAddress \n ${warrning}`,
1852
- });
1853
- }
1854
-
1855
- const query_params = {};
1856
-
1857
- const xHeaders = {};
1858
-
1859
- const response = await ApplicationAPIClient.execute(
1860
- this._conf,
1861
- "put",
1862
- constructUrl({
1863
- url: this._urls["updateAddress"],
1864
- params: { id },
1865
- }),
1866
- query_params,
1867
- body,
1868
- { ...xHeaders, ...requestHeaders },
1869
- { responseHeaders }
1870
- );
1871
-
1872
- let responseData = response;
1873
- if (responseHeaders) {
1874
- responseData = response[0];
1875
- }
1876
-
1877
- const {
1878
- error: res_error,
1879
- } = PosCartApplicationModel.UpdateAddressResponse().validate(responseData, {
1880
- abortEarly: false,
1881
- allowUnknown: true,
1882
- });
1883
-
1884
- if (res_error) {
1885
- if (this._conf.options.strictResponseCheck === true) {
1886
- return Promise.reject(new FDKResponseValidationError(res_error));
1887
- } else {
1888
- Logger({
1889
- level: "WARN",
1890
- message: `Response Validation Warnings for application > PosCart > updateAddress \n ${res_error}`,
1891
- });
1892
- }
1893
- }
1894
-
1895
- return response;
1896
- }
1897
-
1898
- /**
1899
- * @param {PosCartApplicationValidator.UpdateCartParam} arg - Arg object.
1900
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
1901
- * @param {import("../ApplicationAPIClient").Options} - Options
1902
- * @returns {Promise<PosCartApplicationModel.UpdateCartDetailResponse>} -
1903
- * Success response
1904
- * @name updateCart
1905
- * @summary: Update cart
1906
- * @description: Modifies items and quantities in the existing cart. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/updateCart/).
1907
- */
1908
- async updateCart(
1909
- { body, id, i, b, areaCode, buyNow, requestHeaders } = {
1910
- requestHeaders: {},
1911
- },
1912
- { responseHeaders } = { responseHeaders: false }
1913
- ) {
1914
- const { error } = PosCartApplicationValidator.updateCart().validate(
1915
- { body, id, i, b, areaCode, buyNow },
1916
- { abortEarly: false, allowUnknown: true }
1917
- );
1918
- if (error) {
1919
- return Promise.reject(new FDKClientValidationError(error));
1920
- }
1921
-
1922
- // Showing warrnings if extra unknown parameters are found
1923
- const {
1924
- error: warrning,
1925
- } = PosCartApplicationValidator.updateCart().validate(
1926
- { body, id, i, b, areaCode, buyNow },
1927
- { abortEarly: false, allowUnknown: false }
1928
- );
1929
- if (warrning) {
1930
- Logger({
1931
- level: "WARN",
1932
- message: `Parameter Validation warrnings for application > PosCart > updateCart \n ${warrning}`,
1933
- });
1934
- }
1935
-
1936
- const query_params = {};
1937
- query_params["id"] = id;
1938
- query_params["i"] = i;
1939
- query_params["b"] = b;
1940
- query_params["area_code"] = areaCode;
1941
- query_params["buy_now"] = buyNow;
1942
-
1943
- const xHeaders = {};
1944
-
1945
- const response = await ApplicationAPIClient.execute(
1946
- this._conf,
1947
- "put",
1948
- constructUrl({
1949
- url: this._urls["updateCart"],
1950
- params: {},
1951
- }),
1952
- query_params,
1953
- body,
1954
- { ...xHeaders, ...requestHeaders },
1955
- { responseHeaders }
1956
- );
1957
-
1958
- let responseData = response;
1959
- if (responseHeaders) {
1960
- responseData = response[0];
1961
- }
1962
-
1963
- const {
1964
- error: res_error,
1965
- } = PosCartApplicationModel.UpdateCartDetailResponse().validate(
1966
- responseData,
1967
- { abortEarly: false, allowUnknown: true }
1968
- );
1969
-
1970
- if (res_error) {
1971
- if (this._conf.options.strictResponseCheck === true) {
1972
- return Promise.reject(new FDKResponseValidationError(res_error));
1973
- } else {
1974
- Logger({
1975
- level: "WARN",
1976
- message: `Response Validation Warnings for application > PosCart > updateCart \n ${res_error}`,
1977
- });
1978
- }
1979
- }
1980
-
1981
- return response;
1982
- }
1983
-
1984
- /**
1985
- * @param {PosCartApplicationValidator.UpdateCartMetaParam} arg - Arg object.
1986
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
1987
- * @param {import("../ApplicationAPIClient").Options} - Options
1988
- * @returns {Promise<PosCartApplicationModel.CartMetaResponse>} - Success response
1989
- * @name updateCartMeta
1990
- * @summary: Update cart metadata
1991
- * @description: Adds or modifies metadata for the cart. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/updateCartMeta/).
1992
- */
1993
- async updateCartMeta(
1994
- { body, id, buyNow, requestHeaders } = { requestHeaders: {} },
1995
- { responseHeaders } = { responseHeaders: false }
1996
- ) {
1997
- const { error } = PosCartApplicationValidator.updateCartMeta().validate(
1998
- { body, id, buyNow },
1999
- { abortEarly: false, allowUnknown: true }
2000
- );
2001
- if (error) {
2002
- return Promise.reject(new FDKClientValidationError(error));
2003
- }
2004
-
2005
- // Showing warrnings if extra unknown parameters are found
2006
- const {
2007
- error: warrning,
2008
- } = PosCartApplicationValidator.updateCartMeta().validate(
2009
- { body, id, buyNow },
2010
- { abortEarly: false, allowUnknown: false }
2011
- );
2012
- if (warrning) {
2013
- Logger({
2014
- level: "WARN",
2015
- message: `Parameter Validation warrnings for application > PosCart > updateCartMeta \n ${warrning}`,
2016
- });
2017
- }
2018
-
2019
- const query_params = {};
2020
- query_params["id"] = id;
2021
- query_params["buy_now"] = buyNow;
2022
-
2023
- const xHeaders = {};
2024
-
2025
- const response = await ApplicationAPIClient.execute(
2026
- this._conf,
2027
- "put",
2028
- constructUrl({
2029
- url: this._urls["updateCartMeta"],
2030
- params: {},
2031
- }),
2032
- query_params,
2033
- body,
2034
- { ...xHeaders, ...requestHeaders },
2035
- { responseHeaders }
2036
- );
2037
-
2038
- let responseData = response;
2039
- if (responseHeaders) {
2040
- responseData = response[0];
2041
- }
2042
-
2043
- const {
2044
- error: res_error,
2045
- } = PosCartApplicationModel.CartMetaResponse().validate(responseData, {
2046
- abortEarly: false,
2047
- allowUnknown: true,
2048
- });
2049
-
2050
- if (res_error) {
2051
- if (this._conf.options.strictResponseCheck === true) {
2052
- return Promise.reject(new FDKResponseValidationError(res_error));
2053
- } else {
2054
- Logger({
2055
- level: "WARN",
2056
- message: `Response Validation Warnings for application > PosCart > updateCartMeta \n ${res_error}`,
2057
- });
2058
- }
2059
- }
2060
-
2061
- return response;
2062
- }
2063
-
2064
- /**
2065
- * @param {PosCartApplicationValidator.UpdateCartWithSharedItemsParam} arg
2066
- * - Arg object.
2067
- *
2068
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
2069
- * @param {import("../ApplicationAPIClient").Options} - Options
2070
- * @returns {Promise<PosCartApplicationModel.SharedCartResponse>} - Success response
2071
- * @name updateCartWithSharedItems
2072
- * @summary: Update with shared items
2073
- * @description: Updates the cart with items from a shared link. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/updateCartWithSharedItems/).
2074
- */
2075
- async updateCartWithSharedItems(
2076
- { token, action, requestHeaders } = { requestHeaders: {} },
2077
- { responseHeaders } = { responseHeaders: false }
2078
- ) {
2079
- const {
2080
- error,
2081
- } = PosCartApplicationValidator.updateCartWithSharedItems().validate(
2082
- { token, action },
2083
- { abortEarly: false, allowUnknown: true }
2084
- );
2085
- if (error) {
2086
- return Promise.reject(new FDKClientValidationError(error));
2087
- }
2088
-
2089
- // Showing warrnings if extra unknown parameters are found
2090
- const {
2091
- error: warrning,
2092
- } = PosCartApplicationValidator.updateCartWithSharedItems().validate(
2093
- { token, action },
2094
- { abortEarly: false, allowUnknown: false }
2095
- );
2096
- if (warrning) {
2097
- Logger({
2098
- level: "WARN",
2099
- message: `Parameter Validation warrnings for application > PosCart > updateCartWithSharedItems \n ${warrning}`,
2100
- });
2101
- }
2102
-
2103
- const query_params = {};
2104
-
2105
- const xHeaders = {};
2106
-
2107
- const response = await ApplicationAPIClient.execute(
2108
- this._conf,
2109
- "post",
2110
- constructUrl({
2111
- url: this._urls["updateCartWithSharedItems"],
2112
- params: { token, action },
2113
- }),
2114
- query_params,
2115
- undefined,
2116
- { ...xHeaders, ...requestHeaders },
2117
- { responseHeaders }
2118
- );
2119
-
2120
- let responseData = response;
2121
- if (responseHeaders) {
2122
- responseData = response[0];
2123
- }
2124
-
2125
- const {
2126
- error: res_error,
2127
- } = PosCartApplicationModel.SharedCartResponse().validate(responseData, {
2128
- abortEarly: false,
2129
- allowUnknown: true,
2130
- });
2131
-
2132
- if (res_error) {
2133
- if (this._conf.options.strictResponseCheck === true) {
2134
- return Promise.reject(new FDKResponseValidationError(res_error));
2135
- } else {
2136
- Logger({
2137
- level: "WARN",
2138
- message: `Response Validation Warnings for application > PosCart > updateCartWithSharedItems \n ${res_error}`,
2139
- });
2140
- }
2141
- }
2142
-
2143
- return response;
2144
- }
2145
-
2146
- /**
2147
- * @param {PosCartApplicationValidator.UpdateShipmentsParam} arg - Arg object.
2148
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
2149
- * @param {import("../ApplicationAPIClient").Options} - Options
2150
- * @returns {Promise<PosCartApplicationModel.CartShipmentsResponse>} -
2151
- * Success response
2152
- * @name updateShipments
2153
- * @summary: Update shipments
2154
- * @description: Modifies shipment details for items in the cart. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/updateShipments/).
2155
- */
2156
- async updateShipments(
2157
- { body, i, p, id, addressId, areaCode, orderType, requestHeaders } = {
2158
- requestHeaders: {},
2159
- },
2160
- { responseHeaders } = { responseHeaders: false }
2161
- ) {
2162
- const { error } = PosCartApplicationValidator.updateShipments().validate(
2163
- { body, i, p, id, addressId, areaCode, orderType },
2164
- { abortEarly: false, allowUnknown: true }
2165
- );
2166
- if (error) {
2167
- return Promise.reject(new FDKClientValidationError(error));
2168
- }
2169
-
2170
- // Showing warrnings if extra unknown parameters are found
2171
- const {
2172
- error: warrning,
2173
- } = PosCartApplicationValidator.updateShipments().validate(
2174
- { body, i, p, id, addressId, areaCode, orderType },
2175
- { abortEarly: false, allowUnknown: false }
2176
- );
2177
- if (warrning) {
2178
- Logger({
2179
- level: "WARN",
2180
- message: `Parameter Validation warrnings for application > PosCart > updateShipments \n ${warrning}`,
2181
- });
2182
- }
2183
-
2184
- const query_params = {};
2185
- query_params["i"] = i;
2186
- query_params["p"] = p;
2187
- query_params["id"] = id;
2188
- query_params["address_id"] = addressId;
2189
- query_params["area_code"] = areaCode;
2190
- query_params["order_type"] = orderType;
2191
-
2192
- const xHeaders = {};
2193
-
2194
- const response = await ApplicationAPIClient.execute(
2195
- this._conf,
2196
- "put",
2197
- constructUrl({
2198
- url: this._urls["updateShipments"],
2199
- params: {},
2200
- }),
2201
- query_params,
2202
- body,
2203
- { ...xHeaders, ...requestHeaders },
2204
- { responseHeaders }
2205
- );
2206
-
2207
- let responseData = response;
2208
- if (responseHeaders) {
2209
- responseData = response[0];
2210
- }
2211
-
2212
- const {
2213
- error: res_error,
2214
- } = PosCartApplicationModel.CartShipmentsResponse().validate(responseData, {
2215
- abortEarly: false,
2216
- allowUnknown: true,
2217
- });
2218
-
2219
- if (res_error) {
2220
- if (this._conf.options.strictResponseCheck === true) {
2221
- return Promise.reject(new FDKResponseValidationError(res_error));
2222
- } else {
2223
- Logger({
2224
- level: "WARN",
2225
- message: `Response Validation Warnings for application > PosCart > updateShipments \n ${res_error}`,
2226
- });
2227
- }
2228
- }
2229
-
2230
- return response;
2231
- }
2232
-
2233
- /**
2234
- * @param {PosCartApplicationValidator.ValidateCouponForPaymentParam} arg -
2235
- * Arg object.
2236
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
2237
- * @param {import("../ApplicationAPIClient").Options} - Options
2238
- * @returns {Promise<PosCartApplicationModel.PaymentCouponValidate>} -
2239
- * Success response
2240
- * @name validateCouponForPayment
2241
- * @summary: Validate coupon
2242
- * @description: Checks if a coupon is valid for the selected payment mode. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/poscart/validateCouponForPayment/).
2243
- */
2244
- async validateCouponForPayment(
2245
- {
2246
- id,
2247
- buyNow,
2248
- addressId,
2249
- paymentMode,
2250
- paymentIdentifier,
2251
- aggregatorName,
2252
- merchantCode,
2253
- iin,
2254
- network,
2255
- type,
2256
- cardId,
2257
- requestHeaders,
2258
- } = { requestHeaders: {} },
2259
- { responseHeaders } = { responseHeaders: false }
2260
- ) {
2261
- const {
2262
- error,
2263
- } = PosCartApplicationValidator.validateCouponForPayment().validate(
2264
- {
2265
- id,
2266
- buyNow,
2267
- addressId,
2268
- paymentMode,
2269
- paymentIdentifier,
2270
- aggregatorName,
2271
- merchantCode,
2272
- iin,
2273
- network,
2274
- type,
2275
- cardId,
2276
- },
2277
- { abortEarly: false, allowUnknown: true }
2278
- );
2279
- if (error) {
2280
- return Promise.reject(new FDKClientValidationError(error));
2281
- }
2282
-
2283
- // Showing warrnings if extra unknown parameters are found
2284
- const {
2285
- error: warrning,
2286
- } = PosCartApplicationValidator.validateCouponForPayment().validate(
2287
- {
2288
- id,
2289
- buyNow,
2290
- addressId,
2291
- paymentMode,
2292
- paymentIdentifier,
2293
- aggregatorName,
2294
- merchantCode,
2295
- iin,
2296
- network,
2297
- type,
2298
- cardId,
2299
- },
2300
- { abortEarly: false, allowUnknown: false }
2301
- );
2302
- if (warrning) {
2303
- Logger({
2304
- level: "WARN",
2305
- message: `Parameter Validation warrnings for application > PosCart > validateCouponForPayment \n ${warrning}`,
2306
- });
2307
- }
2308
-
2309
- const query_params = {};
2310
- query_params["id"] = id;
2311
- query_params["buy_now"] = buyNow;
2312
- query_params["address_id"] = addressId;
2313
- query_params["payment_mode"] = paymentMode;
2314
- query_params["payment_identifier"] = paymentIdentifier;
2315
- query_params["aggregator_name"] = aggregatorName;
2316
- query_params["merchant_code"] = merchantCode;
2317
- query_params["iin"] = iin;
2318
- query_params["network"] = network;
2319
- query_params["type"] = type;
2320
- query_params["card_id"] = cardId;
2321
-
2322
- const xHeaders = {};
2323
-
2324
- const response = await ApplicationAPIClient.execute(
2325
- this._conf,
2326
- "get",
2327
- constructUrl({
2328
- url: this._urls["validateCouponForPayment"],
2329
- params: {},
2330
- }),
2331
- query_params,
2332
- undefined,
2333
- { ...xHeaders, ...requestHeaders },
2334
- { responseHeaders }
2335
- );
2336
-
2337
- let responseData = response;
2338
- if (responseHeaders) {
2339
- responseData = response[0];
2340
- }
2341
-
2342
- const {
2343
- error: res_error,
2344
- } = PosCartApplicationModel.PaymentCouponValidate().validate(responseData, {
2345
- abortEarly: false,
2346
- allowUnknown: true,
2347
- });
2348
-
2349
- if (res_error) {
2350
- if (this._conf.options.strictResponseCheck === true) {
2351
- return Promise.reject(new FDKResponseValidationError(res_error));
2352
- } else {
2353
- Logger({
2354
- level: "WARN",
2355
- message: `Response Validation Warnings for application > PosCart > validateCouponForPayment \n ${res_error}`,
2356
- });
2357
- }
2358
- }
2359
-
2360
- return response;
2361
- }
2362
- }
2363
-
2364
- module.exports = PosCart;