@gofynd/fdk-client-javascript 1.1.2 → 1.1.4

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 (120) hide show
  1. package/README.md +2 -2
  2. package/index.d.ts +7 -7
  3. package/index.js +12 -12
  4. package/package.json +1 -1
  5. package/sdk/application/ApplicationClient.d.ts +20 -20
  6. package/sdk/application/ApplicationClient.js +26 -26
  7. package/sdk/application/Cart/CartApplicationClient.d.ts +36 -6
  8. package/sdk/application/Cart/CartApplicationClient.js +105 -10
  9. package/sdk/application/Cart/CartApplicationModel.d.ts +9 -0
  10. package/sdk/application/Cart/CartApplicationModel.js +105 -1
  11. package/sdk/application/Cart/CartApplicationValidator.d.ts +1 -0
  12. package/sdk/application/Cart/CartApplicationValidator.js +15 -1
  13. package/sdk/application/Catalog/CatalogApplicationModel.d.ts +1 -0
  14. package/sdk/application/Catalog/CatalogApplicationModel.js +13 -0
  15. package/sdk/application/Common/CommonApplicationModel.js +4 -0
  16. package/sdk/application/Configuration/ConfigurationApplicationClient.d.ts +14 -10
  17. package/sdk/application/Configuration/ConfigurationApplicationClient.js +16 -10
  18. package/sdk/application/Configuration/ConfigurationApplicationModel.js +6 -5
  19. package/sdk/application/Configuration/ConfigurationApplicationValidator.js +1 -0
  20. package/sdk/application/Content/ContentApplicationModel.js +3 -1
  21. package/sdk/application/Lead/LeadApplicationModel.js +4 -1
  22. package/sdk/application/Logistic/LogisticApplicationModel.js +3 -2
  23. package/sdk/application/Order/OrderApplicationClient.d.ts +2 -2
  24. package/sdk/application/Order/OrderApplicationClient.js +2 -2
  25. package/sdk/application/Order/OrderApplicationModel.js +18 -8
  26. package/sdk/application/Payment/PaymentApplicationClient.d.ts +35 -0
  27. package/sdk/application/Payment/PaymentApplicationClient.js +200 -0
  28. package/sdk/application/Payment/PaymentApplicationModel.d.ts +4 -0
  29. package/sdk/application/Payment/PaymentApplicationModel.js +58 -7
  30. package/sdk/application/Payment/PaymentApplicationValidator.d.ts +3 -0
  31. package/sdk/application/Payment/PaymentApplicationValidator.js +19 -0
  32. package/sdk/application/PosCart/PosCartApplicationClient.d.ts +16 -3
  33. package/sdk/application/PosCart/PosCartApplicationClient.js +39 -6
  34. package/sdk/application/PosCart/PosCartApplicationModel.d.ts +6 -0
  35. package/sdk/application/PosCart/PosCartApplicationModel.js +63 -1
  36. package/sdk/application/PosCart/PosCartApplicationValidator.js +6 -0
  37. package/sdk/application/index.d.ts +10 -10
  38. package/sdk/application/index.js +13 -13
  39. package/sdk/common/Constant.d.ts +5 -0
  40. package/sdk/common/Constant.js +5 -0
  41. package/sdk/partner/OAuthClient.js +1 -1
  42. package/sdk/platform/Billing/BillingPlatformModel.js +6 -1
  43. package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +491 -2
  44. package/sdk/platform/Cart/CartPlatformApplicationClient.js +2661 -337
  45. package/sdk/platform/Cart/CartPlatformApplicationValidator.d.ts +32 -0
  46. package/sdk/platform/Cart/CartPlatformApplicationValidator.js +269 -0
  47. package/sdk/platform/Cart/CartPlatformModel.d.ts +58 -0
  48. package/sdk/platform/Cart/CartPlatformModel.js +652 -3
  49. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.d.ts +8 -2
  50. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.js +10 -0
  51. package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.js +1 -0
  52. package/sdk/platform/Catalog/CatalogPlatformClient.js +2 -2
  53. package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +1 -0
  54. package/sdk/platform/Catalog/CatalogPlatformModel.js +43 -31
  55. package/sdk/platform/Common/CommonPlatformModel.js +4 -0
  56. package/sdk/platform/Communication/CommunicationPlatformModel.d.ts +1 -0
  57. package/sdk/platform/Communication/CommunicationPlatformModel.js +9 -0
  58. package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.d.ts +2 -2
  59. package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.js +2 -2
  60. package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.js +5 -4
  61. package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.d.ts +99 -78
  62. package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.js +99 -78
  63. package/sdk/platform/Configuration/ConfigurationPlatformClient.d.ts +87 -71
  64. package/sdk/platform/Configuration/ConfigurationPlatformClient.js +87 -71
  65. package/sdk/platform/Configuration/ConfigurationPlatformModel.d.ts +2 -0
  66. package/sdk/platform/Configuration/ConfigurationPlatformModel.js +34 -7
  67. package/sdk/platform/Content/ContentPlatformModel.js +3 -1
  68. package/sdk/platform/Finance/FinancePlatformClient.d.ts +135 -0
  69. package/sdk/platform/Finance/FinancePlatformClient.js +853 -0
  70. package/sdk/platform/Finance/FinancePlatformModel.d.ts +51 -0
  71. package/sdk/platform/Finance/FinancePlatformModel.js +342 -0
  72. package/sdk/platform/Finance/FinancePlatformValidator.d.ts +16 -0
  73. package/sdk/platform/Finance/FinancePlatformValidator.js +84 -0
  74. package/sdk/platform/Order/OrderPlatformApplicationClient.d.ts +11 -1
  75. package/sdk/platform/Order/OrderPlatformApplicationClient.js +66 -2
  76. package/sdk/platform/Order/OrderPlatformApplicationValidator.d.ts +1 -0
  77. package/sdk/platform/Order/OrderPlatformApplicationValidator.js +6 -0
  78. package/sdk/platform/Order/OrderPlatformClient.d.ts +161 -79
  79. package/sdk/platform/Order/OrderPlatformClient.js +546 -114
  80. package/sdk/platform/Order/OrderPlatformModel.d.ts +42 -6
  81. package/sdk/platform/Order/OrderPlatformModel.js +569 -159
  82. package/sdk/platform/Order/OrderPlatformValidator.d.ts +6 -0
  83. package/sdk/platform/Order/OrderPlatformValidator.js +52 -9
  84. package/sdk/platform/Partner/PartnerPlatformApplicationClient.d.ts +22 -0
  85. package/sdk/platform/Partner/PartnerPlatformApplicationClient.js +127 -0
  86. package/sdk/platform/Partner/PartnerPlatformApplicationValidator.d.ts +2 -0
  87. package/sdk/platform/Partner/PartnerPlatformApplicationValidator.js +13 -0
  88. package/sdk/platform/Partner/PartnerPlatformClient.d.ts +145 -0
  89. package/sdk/platform/Partner/PartnerPlatformClient.js +799 -0
  90. package/sdk/platform/Partner/PartnerPlatformModel.d.ts +39 -0
  91. package/sdk/platform/Partner/PartnerPlatformModel.js +367 -0
  92. package/sdk/platform/Partner/PartnerPlatformValidator.d.ts +14 -0
  93. package/sdk/platform/Partner/PartnerPlatformValidator.js +87 -0
  94. package/sdk/platform/Payment/PaymentPlatformApplicationClient.d.ts +221 -0
  95. package/sdk/platform/Payment/PaymentPlatformApplicationClient.js +1476 -190
  96. package/sdk/platform/Payment/PaymentPlatformApplicationValidator.d.ts +20 -0
  97. package/sdk/platform/Payment/PaymentPlatformApplicationValidator.js +126 -0
  98. package/sdk/platform/Payment/PaymentPlatformModel.d.ts +48 -0
  99. package/sdk/platform/Payment/PaymentPlatformModel.js +452 -7
  100. package/sdk/platform/PlatformApplicationClient.d.ts +1249 -937
  101. package/sdk/platform/PlatformApplicationClient.js +1366 -1033
  102. package/sdk/platform/PlatformClient.d.ts +10979 -8771
  103. package/sdk/platform/PlatformClient.js +11874 -9197
  104. package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationClient.d.ts +134 -0
  105. package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationClient.js +852 -0
  106. package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationValidator.d.ts +16 -0
  107. package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationValidator.js +81 -0
  108. package/sdk/platform/Serviceability/ServiceabilityPlatformClient.d.ts +223 -0
  109. package/sdk/platform/Serviceability/ServiceabilityPlatformClient.js +1296 -0
  110. package/sdk/platform/Serviceability/ServiceabilityPlatformModel.d.ts +97 -0
  111. package/sdk/platform/Serviceability/ServiceabilityPlatformModel.js +778 -0
  112. package/sdk/platform/Serviceability/ServiceabilityPlatformValidator.d.ts +21 -0
  113. package/sdk/platform/Serviceability/ServiceabilityPlatformValidator.js +130 -0
  114. package/sdk/platform/index.d.ts +16 -14
  115. package/sdk/platform/index.js +22 -18
  116. package/sdk/public/Configuration/ConfigurationPublicModel.js +5 -0
  117. package/sdk/public/PublicClient.d.ts +2 -2
  118. package/sdk/public/PublicClient.js +4 -4
  119. package/sdk/public/index.d.ts +1 -1
  120. package/sdk/public/index.js +2 -2
@@ -12,6 +12,67 @@ class Cart {
12
12
  this.applicationId = applicationId;
13
13
  }
14
14
 
15
+ /**
16
+ * @param {Object} arg - Arg object.
17
+ * @param {PlatformAddress} arg.body
18
+ * @returns {Promise<SaveAddressResponse>} - Success response
19
+ * @summary: Add address to an account
20
+ * @description: Use this API to add an address to an account.
21
+ */
22
+ async addAddress({ body } = {}) {
23
+ const { error } = CartValidator.addAddress().validate(
24
+ {
25
+ body,
26
+ },
27
+ { abortEarly: false, allowUnknown: true }
28
+ );
29
+ if (error) {
30
+ return Promise.reject(new FDKClientValidationError(error));
31
+ }
32
+
33
+ // Showing warrnings if extra unknown parameters are found
34
+ const { error: warrning } = CartValidator.addAddress().validate(
35
+ {
36
+ body,
37
+ },
38
+ { abortEarly: false, allowUnknown: false }
39
+ );
40
+ if (warrning) {
41
+ Logger({
42
+ level: "WARN",
43
+ message: "Parameter Validation warrnings for addAddress",
44
+ });
45
+ Logger({ level: "WARN", message: warrning });
46
+ }
47
+
48
+ const query_params = {};
49
+
50
+ const response = await PlatformAPIClient.execute(
51
+ this.config,
52
+ "post",
53
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/address`,
54
+ query_params,
55
+ body
56
+ );
57
+
58
+ const {
59
+ error: res_error,
60
+ } = CartModel.SaveAddressResponse().validate(response, {
61
+ abortEarly: false,
62
+ allowUnknown: false,
63
+ });
64
+
65
+ if (res_error) {
66
+ Logger({
67
+ level: "WARN",
68
+ message: "Response Validation Warnnings for addAddress",
69
+ });
70
+ Logger({ level: "WARN", message: res_error });
71
+ }
72
+
73
+ return response;
74
+ }
75
+
15
76
  /**
16
77
  * @param {Object} arg - Arg object.
17
78
  * @param {string} arg.cartId - Current Cart _id
@@ -80,6 +141,148 @@ class Cart {
80
141
  return response;
81
142
  }
82
143
 
144
+ /**
145
+ * @param {Object} arg - Arg object.
146
+ * @param {PriceAdjustmentAdd} arg.body
147
+ * @returns {Promise<PriceAdjustmentResponse>} - Success response
148
+ * @summary: Create new price adjustment
149
+ * @description: Create new price adjustment
150
+ */
151
+ async addPriceAdjustment({ body } = {}) {
152
+ const { error } = CartValidator.addPriceAdjustment().validate(
153
+ {
154
+ body,
155
+ },
156
+ { abortEarly: false, allowUnknown: true }
157
+ );
158
+ if (error) {
159
+ return Promise.reject(new FDKClientValidationError(error));
160
+ }
161
+
162
+ // Showing warrnings if extra unknown parameters are found
163
+ const { error: warrning } = CartValidator.addPriceAdjustment().validate(
164
+ {
165
+ body,
166
+ },
167
+ { abortEarly: false, allowUnknown: false }
168
+ );
169
+ if (warrning) {
170
+ Logger({
171
+ level: "WARN",
172
+ message: "Parameter Validation warrnings for addPriceAdjustment",
173
+ });
174
+ Logger({ level: "WARN", message: warrning });
175
+ }
176
+
177
+ const query_params = {};
178
+
179
+ const response = await PlatformAPIClient.execute(
180
+ this.config,
181
+ "post",
182
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/price-adjustment`,
183
+ query_params,
184
+ body
185
+ );
186
+
187
+ const {
188
+ error: res_error,
189
+ } = CartModel.PriceAdjustmentResponse().validate(response, {
190
+ abortEarly: false,
191
+ allowUnknown: false,
192
+ });
193
+
194
+ if (res_error) {
195
+ Logger({
196
+ level: "WARN",
197
+ message: "Response Validation Warnnings for addPriceAdjustment",
198
+ });
199
+ Logger({ level: "WARN", message: res_error });
200
+ }
201
+
202
+ return response;
203
+ }
204
+
205
+ /**
206
+ * @param {Object} arg - Arg object.
207
+ * @param {boolean} [arg.i] -
208
+ * @param {boolean} [arg.b] -
209
+ * @param {boolean} [arg.p] -
210
+ * @param {string} [arg.id] -
211
+ * @param {boolean} [arg.buyNow] -
212
+ * @param {ApplyCouponRequest} arg.body
213
+ * @returns {Promise<CartDetailResponse>} - Success response
214
+ * @summary: Apply Coupon for platform pos user
215
+ * @description: Use this API to apply coupons on items in the cart.
216
+ */
217
+ async applyCoupon({ body, i, b, p, id, buyNow } = {}) {
218
+ const { error } = CartValidator.applyCoupon().validate(
219
+ {
220
+ body,
221
+ i,
222
+ b,
223
+ p,
224
+ id,
225
+ buyNow,
226
+ },
227
+ { abortEarly: false, allowUnknown: true }
228
+ );
229
+ if (error) {
230
+ return Promise.reject(new FDKClientValidationError(error));
231
+ }
232
+
233
+ // Showing warrnings if extra unknown parameters are found
234
+ const { error: warrning } = CartValidator.applyCoupon().validate(
235
+ {
236
+ body,
237
+ i,
238
+ b,
239
+ p,
240
+ id,
241
+ buyNow,
242
+ },
243
+ { abortEarly: false, allowUnknown: false }
244
+ );
245
+ if (warrning) {
246
+ Logger({
247
+ level: "WARN",
248
+ message: "Parameter Validation warrnings for applyCoupon",
249
+ });
250
+ Logger({ level: "WARN", message: warrning });
251
+ }
252
+
253
+ const query_params = {};
254
+ query_params["i"] = i;
255
+ query_params["b"] = b;
256
+ query_params["p"] = p;
257
+ query_params["id"] = id;
258
+ query_params["buy_now"] = buyNow;
259
+
260
+ const response = await PlatformAPIClient.execute(
261
+ this.config,
262
+ "post",
263
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/platform-pos-coupon`,
264
+ query_params,
265
+ body
266
+ );
267
+
268
+ const {
269
+ error: res_error,
270
+ } = CartModel.CartDetailResponse().validate(response, {
271
+ abortEarly: false,
272
+ allowUnknown: false,
273
+ });
274
+
275
+ if (res_error) {
276
+ Logger({
277
+ level: "WARN",
278
+ message: "Response Validation Warnnings for applyCoupon",
279
+ });
280
+ Logger({ level: "WARN", message: res_error });
281
+ }
282
+
283
+ return response;
284
+ }
285
+
83
286
  /**
84
287
  * @param {Object} arg - Arg object.
85
288
  * @param {OpenApiCartServiceabilityRequest} arg.body
@@ -383,6 +586,71 @@ class Cart {
383
586
  return response;
384
587
  }
385
588
 
589
+ /**
590
+ * @param {Object} arg - Arg object.
591
+ * @param {string} [arg.id] - The unique identifier of the cart.
592
+ * @param {DeleteCartRequest} arg.body
593
+ * @returns {Promise<DeleteCartDetailResponse>} - Success response
594
+ * @summary: Delete cart once user made successful checkout
595
+ * @description: Use this API to delete the cart.
596
+ */
597
+ async deleteCart({ body, id } = {}) {
598
+ const { error } = CartValidator.deleteCart().validate(
599
+ {
600
+ body,
601
+ id,
602
+ },
603
+ { abortEarly: false, allowUnknown: true }
604
+ );
605
+ if (error) {
606
+ return Promise.reject(new FDKClientValidationError(error));
607
+ }
608
+
609
+ // Showing warrnings if extra unknown parameters are found
610
+ const { error: warrning } = CartValidator.deleteCart().validate(
611
+ {
612
+ body,
613
+ id,
614
+ },
615
+ { abortEarly: false, allowUnknown: false }
616
+ );
617
+ if (warrning) {
618
+ Logger({
619
+ level: "WARN",
620
+ message: "Parameter Validation warrnings for deleteCart",
621
+ });
622
+ Logger({ level: "WARN", message: warrning });
623
+ }
624
+
625
+ const query_params = {};
626
+ query_params["id"] = id;
627
+
628
+ const response = await PlatformAPIClient.execute(
629
+ this.config,
630
+ "put",
631
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/cart_archive`,
632
+ query_params,
633
+ body
634
+ );
635
+
636
+ const {
637
+ error: res_error,
638
+ } = CartModel.DeleteCartDetailResponse().validate(response, {
639
+ abortEarly: false,
640
+ allowUnknown: false,
641
+ });
642
+
643
+ if (res_error) {
644
+ Logger({
645
+ level: "WARN",
646
+ message: "Response Validation Warnnings for deleteCart",
647
+ });
648
+ Logger({ level: "WARN", message: res_error });
649
+ }
650
+
651
+ return response;
652
+ }
653
+
386
654
  /**
387
655
  * @param {Object} arg - Arg object.
388
656
  * @param {OpenapiCartDetailsRequest} arg.body
@@ -720,14 +988,37 @@ class Cart {
720
988
  /**
721
989
  * @param {Object} arg - Arg object.
722
990
  * @param {string} arg.id -
723
- * @returns {Promise<CouponUpdate>} - Success response
724
- * @summary: Get with single coupon details or coupon list
725
- * @description: Get single coupon details with `id` in path param
991
+ * @param {string} [arg.cartId] -
992
+ * @param {boolean} [arg.buyNow] -
993
+ * @param {string} [arg.mobileNo] -
994
+ * @param {string} [arg.checkoutMode] -
995
+ * @param {string} [arg.tags] -
996
+ * @param {boolean} [arg.isDefault] -
997
+ * @param {string} [arg.userId] -
998
+ * @returns {Promise<PlatformAddress>} - Success response
999
+ * @summary: Fetch a single address by its ID
1000
+ * @description: Use this API to get an addresses using its ID. If successful, returns a Address resource in the response body specified in `PlatformAddress`. Attibutes listed below are optional <ul> <li> <font color="monochrome">mobile_no</font></li> <li> <font color="monochrome">checkout_mode</font></li> <li> <font color="monochrome">tags</font></li> <li> <font color="monochrome">default</font></li> </ul>
726
1001
  */
727
- async getCouponById({ id } = {}) {
728
- const { error } = CartValidator.getCouponById().validate(
1002
+ async getAddressById({
1003
+ id,
1004
+ cartId,
1005
+ buyNow,
1006
+ mobileNo,
1007
+ checkoutMode,
1008
+ tags,
1009
+ isDefault,
1010
+ userId,
1011
+ } = {}) {
1012
+ const { error } = CartValidator.getAddressById().validate(
729
1013
  {
730
1014
  id,
1015
+ cartId,
1016
+ buyNow,
1017
+ mobileNo,
1018
+ checkoutMode,
1019
+ tags,
1020
+ isDefault,
1021
+ userId,
731
1022
  },
732
1023
  { abortEarly: false, allowUnknown: true }
733
1024
  );
@@ -736,39 +1027,53 @@ class Cart {
736
1027
  }
737
1028
 
738
1029
  // Showing warrnings if extra unknown parameters are found
739
- const { error: warrning } = CartValidator.getCouponById().validate(
1030
+ const { error: warrning } = CartValidator.getAddressById().validate(
740
1031
  {
741
1032
  id,
1033
+ cartId,
1034
+ buyNow,
1035
+ mobileNo,
1036
+ checkoutMode,
1037
+ tags,
1038
+ isDefault,
1039
+ userId,
742
1040
  },
743
1041
  { abortEarly: false, allowUnknown: false }
744
1042
  );
745
1043
  if (warrning) {
746
1044
  Logger({
747
1045
  level: "WARN",
748
- message: "Parameter Validation warrnings for getCouponById",
1046
+ message: "Parameter Validation warrnings for getAddressById",
749
1047
  });
750
1048
  Logger({ level: "WARN", message: warrning });
751
1049
  }
752
1050
 
753
1051
  const query_params = {};
1052
+ query_params["cart_id"] = cartId;
1053
+ query_params["buy_now"] = buyNow;
1054
+ query_params["mobile_no"] = mobileNo;
1055
+ query_params["checkout_mode"] = checkoutMode;
1056
+ query_params["tags"] = tags;
1057
+ query_params["is_default"] = isDefault;
1058
+ query_params["user_id"] = userId;
754
1059
 
755
1060
  const response = await PlatformAPIClient.execute(
756
1061
  this.config,
757
1062
  "get",
758
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon/${id}`,
1063
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/address/${id}`,
759
1064
  query_params,
760
1065
  undefined
761
1066
  );
762
1067
 
763
- const { error: res_error } = CartModel.CouponUpdate().validate(response, {
764
- abortEarly: false,
765
- allowUnknown: false,
766
- });
1068
+ const { error: res_error } = CartModel.PlatformAddress().validate(
1069
+ response,
1070
+ { abortEarly: false, allowUnknown: false }
1071
+ );
767
1072
 
768
1073
  if (res_error) {
769
1074
  Logger({
770
1075
  level: "WARN",
771
- message: "Response Validation Warnnings for getCouponById",
1076
+ message: "Response Validation Warnnings for getAddressById",
772
1077
  });
773
1078
  Logger({ level: "WARN", message: res_error });
774
1079
  }
@@ -778,15 +1083,35 @@ class Cart {
778
1083
 
779
1084
  /**
780
1085
  * @param {Object} arg - Arg object.
781
- * @param {string} [arg.code] -
782
- * @returns {Promise<Object>} - Success response
783
- * @summary: Check if coupon is already created with coupon code
784
- * @description: Check if sent coupon code is already existing coupon code. As coupon code is to be unique.
1086
+ * @param {string} [arg.cartId] -
1087
+ * @param {boolean} [arg.buyNow] -
1088
+ * @param {string} [arg.mobileNo] -
1089
+ * @param {string} [arg.checkoutMode] -
1090
+ * @param {string} [arg.tags] -
1091
+ * @param {boolean} [arg.isDefault] -
1092
+ * @param {string} [arg.userId] -
1093
+ * @returns {Promise<PlatformGetAddressesResponse>} - Success response
1094
+ * @summary: Fetch address
1095
+ * @description: Use this API to get all the addresses associated with an account. If successful, returns a Address resource in the response body specified in GetAddressesResponse.attibutes listed below are optional <ul> <li> <font color="monochrome">uid</font></li> <li> <font color="monochrome">address_id</font></li> <li> <font color="monochrome">mobile_no</font></li> <li> <font color="monochrome">checkout_mode</font></li> <li> <font color="monochrome">tags</font></li> <li> <font color="monochrome">default</font></li> </ul>
785
1096
  */
786
- async getCouponCodeExists({ code } = {}) {
787
- const { error } = CartValidator.getCouponCodeExists().validate(
1097
+ async getAddresses({
1098
+ cartId,
1099
+ buyNow,
1100
+ mobileNo,
1101
+ checkoutMode,
1102
+ tags,
1103
+ isDefault,
1104
+ userId,
1105
+ } = {}) {
1106
+ const { error } = CartValidator.getAddresses().validate(
788
1107
  {
789
- code,
1108
+ cartId,
1109
+ buyNow,
1110
+ mobileNo,
1111
+ checkoutMode,
1112
+ tags,
1113
+ isDefault,
1114
+ userId,
790
1115
  },
791
1116
  { abortEarly: false, allowUnknown: true }
792
1117
  );
@@ -795,32 +1120,46 @@ class Cart {
795
1120
  }
796
1121
 
797
1122
  // Showing warrnings if extra unknown parameters are found
798
- const { error: warrning } = CartValidator.getCouponCodeExists().validate(
1123
+ const { error: warrning } = CartValidator.getAddresses().validate(
799
1124
  {
800
- code,
1125
+ cartId,
1126
+ buyNow,
1127
+ mobileNo,
1128
+ checkoutMode,
1129
+ tags,
1130
+ isDefault,
1131
+ userId,
801
1132
  },
802
1133
  { abortEarly: false, allowUnknown: false }
803
1134
  );
804
1135
  if (warrning) {
805
1136
  Logger({
806
1137
  level: "WARN",
807
- message: "Parameter Validation warrnings for getCouponCodeExists",
1138
+ message: "Parameter Validation warrnings for getAddresses",
808
1139
  });
809
1140
  Logger({ level: "WARN", message: warrning });
810
1141
  }
811
1142
 
812
1143
  const query_params = {};
813
- query_params["code"] = code;
1144
+ query_params["cart_id"] = cartId;
1145
+ query_params["buy_now"] = buyNow;
1146
+ query_params["mobile_no"] = mobileNo;
1147
+ query_params["checkout_mode"] = checkoutMode;
1148
+ query_params["tags"] = tags;
1149
+ query_params["is_default"] = isDefault;
1150
+ query_params["user_id"] = userId;
814
1151
 
815
1152
  const response = await PlatformAPIClient.execute(
816
1153
  this.config,
817
1154
  "get",
818
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon_code_exists`,
1155
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/address`,
819
1156
  query_params,
820
1157
  undefined
821
1158
  );
822
1159
 
823
- const { error: res_error } = Joi.any().validate(response, {
1160
+ const {
1161
+ error: res_error,
1162
+ } = CartModel.PlatformGetAddressesResponse().validate(response, {
824
1163
  abortEarly: false,
825
1164
  allowUnknown: false,
826
1165
  });
@@ -828,7 +1167,7 @@ class Cart {
828
1167
  if (res_error) {
829
1168
  Logger({
830
1169
  level: "WARN",
831
- message: "Response Validation Warnnings for getCouponCodeExists",
1170
+ message: "Response Validation Warnnings for getAddresses",
832
1171
  });
833
1172
  Logger({ level: "WARN", message: res_error });
834
1173
  }
@@ -838,13 +1177,18 @@ class Cart {
838
1177
 
839
1178
  /**
840
1179
  * @param {Object} arg - Arg object.
841
- * @returns {Promise<Object>} - Success response
842
- * @summary: Get coupon options enums with display values
843
- * @description: Get coupon enum values for fields in valid coupon object. Used for front end to create, update and filter coupon lists via fields
1180
+ * @param {string} [arg.id] -
1181
+ * @param {boolean} [arg.buyNow] -
1182
+ * @returns {Promise<GetCouponResponse>} - Success response
1183
+ * @summary: Fetch Coupon
1184
+ * @description: Use this API to get a list of available coupons along with their details.
844
1185
  */
845
- async getCouponOptionValues({} = {}) {
846
- const { error } = CartValidator.getCouponOptionValues().validate(
847
- {},
1186
+ async getAppCoupons({ id, buyNow } = {}) {
1187
+ const { error } = CartValidator.getAppCoupons().validate(
1188
+ {
1189
+ id,
1190
+ buyNow,
1191
+ },
848
1192
  { abortEarly: false, allowUnknown: true }
849
1193
  );
850
1194
  if (error) {
@@ -852,29 +1196,36 @@ class Cart {
852
1196
  }
853
1197
 
854
1198
  // Showing warrnings if extra unknown parameters are found
855
- const { error: warrning } = CartValidator.getCouponOptionValues().validate(
856
- {},
1199
+ const { error: warrning } = CartValidator.getAppCoupons().validate(
1200
+ {
1201
+ id,
1202
+ buyNow,
1203
+ },
857
1204
  { abortEarly: false, allowUnknown: false }
858
1205
  );
859
1206
  if (warrning) {
860
1207
  Logger({
861
1208
  level: "WARN",
862
- message: "Parameter Validation warrnings for getCouponOptionValues",
1209
+ message: "Parameter Validation warrnings for getAppCoupons",
863
1210
  });
864
1211
  Logger({ level: "WARN", message: warrning });
865
1212
  }
866
1213
 
867
1214
  const query_params = {};
1215
+ query_params["id"] = id;
1216
+ query_params["buy_now"] = buyNow;
868
1217
 
869
1218
  const response = await PlatformAPIClient.execute(
870
1219
  this.config,
871
1220
  "get",
872
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon_options`,
1221
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/platform-pos-coupon`,
873
1222
  query_params,
874
1223
  undefined
875
1224
  );
876
1225
 
877
- const { error: res_error } = Joi.any().validate(response, {
1226
+ const {
1227
+ error: res_error,
1228
+ } = CartModel.GetCouponResponse().validate(response, {
878
1229
  abortEarly: false,
879
1230
  allowUnknown: false,
880
1231
  });
@@ -882,7 +1233,7 @@ class Cart {
882
1233
  if (res_error) {
883
1234
  Logger({
884
1235
  level: "WARN",
885
- message: "Response Validation Warnnings for getCouponOptionValues",
1236
+ message: "Response Validation Warnnings for getAppCoupons",
886
1237
  });
887
1238
  Logger({ level: "WARN", message: res_error });
888
1239
  }
@@ -892,38 +1243,17 @@ class Cart {
892
1243
 
893
1244
  /**
894
1245
  * @param {Object} arg - Arg object.
895
- * @param {number} [arg.pageNo] -
896
- * @param {number} [arg.pageSize] -
897
- * @param {boolean} [arg.isArchived] -
898
- * @param {string} [arg.title] -
899
- * @param {boolean} [arg.isPublic] -
900
- * @param {boolean} [arg.isDisplay] -
901
- * @param {string} [arg.typeSlug] -
902
- * @param {string} [arg.code] -
903
- * @returns {Promise<CouponsResponse>} - Success response
904
- * @summary: Get with single coupon details or coupon list
905
- * @description: Get coupon list with pagination
1246
+ * @param {string} arg.areaCode -
1247
+ * @param {string} [arg.id] -
1248
+ * @returns {Promise<CartDeliveryModesResponse>} - Success response
1249
+ * @summary: Get available delivery modes for cart
1250
+ * @description: Use this API to get the delivery modes (home-delivery/store-pickup) along with a list of pickup stores available for a given cart at a given PIN Code. User can then view the address of a pickup store with the help of store-address API.
906
1251
  */
907
- async getCoupons({
908
- pageNo,
909
- pageSize,
910
- isArchived,
911
- title,
912
- isPublic,
913
- isDisplay,
914
- typeSlug,
915
- code,
916
- } = {}) {
917
- const { error } = CartValidator.getCoupons().validate(
1252
+ async getAvailableDeliveryModes({ areaCode, id } = {}) {
1253
+ const { error } = CartValidator.getAvailableDeliveryModes().validate(
918
1254
  {
919
- pageNo,
920
- pageSize,
921
- isArchived,
922
- title,
923
- isPublic,
924
- isDisplay,
925
- typeSlug,
926
- code,
1255
+ areaCode,
1256
+ id,
927
1257
  },
928
1258
  { abortEarly: false, allowUnknown: true }
929
1259
  );
@@ -932,54 +1262,46 @@ class Cart {
932
1262
  }
933
1263
 
934
1264
  // Showing warrnings if extra unknown parameters are found
935
- const { error: warrning } = CartValidator.getCoupons().validate(
1265
+ const {
1266
+ error: warrning,
1267
+ } = CartValidator.getAvailableDeliveryModes().validate(
936
1268
  {
937
- pageNo,
938
- pageSize,
939
- isArchived,
940
- title,
941
- isPublic,
942
- isDisplay,
943
- typeSlug,
944
- code,
1269
+ areaCode,
1270
+ id,
945
1271
  },
946
1272
  { abortEarly: false, allowUnknown: false }
947
1273
  );
948
1274
  if (warrning) {
949
1275
  Logger({
950
1276
  level: "WARN",
951
- message: "Parameter Validation warrnings for getCoupons",
1277
+ message: "Parameter Validation warrnings for getAvailableDeliveryModes",
952
1278
  });
953
1279
  Logger({ level: "WARN", message: warrning });
954
1280
  }
955
1281
 
956
1282
  const query_params = {};
957
- query_params["page_no"] = pageNo;
958
- query_params["page_size"] = pageSize;
959
- query_params["is_archived"] = isArchived;
960
- query_params["title"] = title;
961
- query_params["is_public"] = isPublic;
962
- query_params["is_display"] = isDisplay;
963
- query_params["type_slug"] = typeSlug;
964
- query_params["code"] = code;
1283
+ query_params["area_code"] = areaCode;
1284
+ query_params["id"] = id;
965
1285
 
966
1286
  const response = await PlatformAPIClient.execute(
967
1287
  this.config,
968
1288
  "get",
969
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon`,
1289
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/available-delivery-mode`,
970
1290
  query_params,
971
1291
  undefined
972
1292
  );
973
1293
 
974
- const { error: res_error } = CartModel.CouponsResponse().validate(
975
- response,
976
- { abortEarly: false, allowUnknown: false }
977
- );
1294
+ const {
1295
+ error: res_error,
1296
+ } = CartModel.CartDeliveryModesResponse().validate(response, {
1297
+ abortEarly: false,
1298
+ allowUnknown: false,
1299
+ });
978
1300
 
979
1301
  if (res_error) {
980
1302
  Logger({
981
1303
  level: "WARN",
982
- message: "Response Validation Warnnings for getCoupons",
1304
+ message: "Response Validation Warnnings for getAvailableDeliveryModes",
983
1305
  });
984
1306
  Logger({ level: "WARN", message: res_error });
985
1307
  }
@@ -989,69 +1311,25 @@ class Cart {
989
1311
 
990
1312
  /**
991
1313
  * @param {Object} arg - Arg object.
992
- * @param {string} arg.companyId - Current company id
993
- * @param {string} arg.applicationId - Current Application _id
994
- * @param {number} [arg.pageSize] -
995
- * @param {boolean} [arg.isArchived] -
996
- * @param {string} [arg.title] -
997
- * @param {boolean} [arg.isPublic] -
998
- * @param {boolean} [arg.isDisplay] -
999
- * @param {string} [arg.typeSlug] -
1000
- * @param {string} [arg.code] -
1001
- * @summary: Get with single coupon details or coupon list
1002
- * @description: Get coupon list with pagination
1003
- */
1004
- getCouponsPaginator({
1005
- companyId,
1006
- applicationId,
1007
- pageSize,
1008
- isArchived,
1009
- title,
1010
- isPublic,
1011
- isDisplay,
1012
- typeSlug,
1013
- code,
1014
- } = {}) {
1015
- const paginator = new Paginator();
1016
- const callback = async () => {
1017
- const pageId = paginator.nextId;
1018
- const pageNo = paginator.pageNo;
1019
- const pageType = "number";
1020
- const data = await this.getCoupons({
1021
- companyId: companyId,
1022
- applicationId: applicationId,
1023
- pageNo: pageNo,
1024
- pageSize: pageSize,
1025
- isArchived: isArchived,
1026
- title: title,
1027
- isPublic: isPublic,
1028
- isDisplay: isDisplay,
1029
- typeSlug: typeSlug,
1030
- code: code,
1031
- });
1032
- paginator.setPaginator({
1033
- hasNext: data.page.has_next ? true : false,
1034
- nextId: data.page.next_id,
1035
- });
1036
- return data;
1037
- };
1038
- paginator.setCallback(callback.bind(this));
1039
- return paginator;
1040
- }
1041
-
1042
- /**
1043
- * @param {Object} arg - Arg object.
1044
- * @param {string} [arg.entityType] - Entity_type as coupon or promotion
1045
- * @param {boolean} [arg.isHidden] - Show Promo Coupon Config or not
1046
- * @returns {Promise<ActivePromosResponse>} - Success response
1047
- * @summary: Fetch all promos that are set as active
1048
- * @description: Use this API to get list of all the active promos/coupons.
1314
+ * @param {string} [arg.id] -
1315
+ * @param {string} [arg.userId] -
1316
+ * @param {boolean} [arg.i] -
1317
+ * @param {boolean} [arg.b] -
1318
+ * @param {number} [arg.assignCardId] -
1319
+ * @param {boolean} [arg.buyNow] -
1320
+ * @returns {Promise<CartDetailResponse>} - Success response
1321
+ * @summary: Fetch all items added to the customer cart using cart id
1322
+ * @description: Use this API to get details of all the items added to a cart.
1049
1323
  */
1050
- async getPromosCouponConfig({ entityType, isHidden } = {}) {
1051
- const { error } = CartValidator.getPromosCouponConfig().validate(
1324
+ async getCart({ id, userId, i, b, assignCardId, buyNow } = {}) {
1325
+ const { error } = CartValidator.getCart().validate(
1052
1326
  {
1053
- entityType,
1054
- isHidden,
1327
+ id,
1328
+ userId,
1329
+ i,
1330
+ b,
1331
+ assignCardId,
1332
+ buyNow,
1055
1333
  },
1056
1334
  { abortEarly: false, allowUnknown: true }
1057
1335
  );
@@ -1060,36 +1338,44 @@ class Cart {
1060
1338
  }
1061
1339
 
1062
1340
  // Showing warrnings if extra unknown parameters are found
1063
- const { error: warrning } = CartValidator.getPromosCouponConfig().validate(
1341
+ const { error: warrning } = CartValidator.getCart().validate(
1064
1342
  {
1065
- entityType,
1066
- isHidden,
1343
+ id,
1344
+ userId,
1345
+ i,
1346
+ b,
1347
+ assignCardId,
1348
+ buyNow,
1067
1349
  },
1068
1350
  { abortEarly: false, allowUnknown: false }
1069
1351
  );
1070
1352
  if (warrning) {
1071
1353
  Logger({
1072
1354
  level: "WARN",
1073
- message: "Parameter Validation warrnings for getPromosCouponConfig",
1355
+ message: "Parameter Validation warrnings for getCart",
1074
1356
  });
1075
1357
  Logger({ level: "WARN", message: warrning });
1076
1358
  }
1077
1359
 
1078
1360
  const query_params = {};
1079
- query_params["entity_type"] = entityType;
1080
- query_params["is_hidden"] = isHidden;
1361
+ query_params["id"] = id;
1362
+ query_params["user_id"] = userId;
1363
+ query_params["i"] = i;
1364
+ query_params["b"] = b;
1365
+ query_params["assign_card_id"] = assignCardId;
1366
+ query_params["buy_now"] = buyNow;
1081
1367
 
1082
1368
  const response = await PlatformAPIClient.execute(
1083
1369
  this.config,
1084
1370
  "get",
1085
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promo-coupons`,
1371
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/detail`,
1086
1372
  query_params,
1087
1373
  undefined
1088
1374
  );
1089
1375
 
1090
1376
  const {
1091
1377
  error: res_error,
1092
- } = CartModel.ActivePromosResponse().validate(response, {
1378
+ } = CartModel.CartDetailResponse().validate(response, {
1093
1379
  abortEarly: false,
1094
1380
  allowUnknown: false,
1095
1381
  });
@@ -1097,7 +1383,7 @@ class Cart {
1097
1383
  if (res_error) {
1098
1384
  Logger({
1099
1385
  level: "WARN",
1100
- message: "Response Validation Warnnings for getPromosCouponConfig",
1386
+ message: "Response Validation Warnnings for getCart",
1101
1387
  });
1102
1388
  Logger({ level: "WARN", message: res_error });
1103
1389
  }
@@ -1107,15 +1393,19 @@ class Cart {
1107
1393
 
1108
1394
  /**
1109
1395
  * @param {Object} arg - Arg object.
1110
- * @param {string} arg.id -
1111
- * @returns {Promise<PromotionUpdate>} - Success response
1112
- * @summary: Get with single promotion details or promotion list
1113
- * @description: Get single promotion details with `id` in path param
1396
+ * @param {string} [arg.fromDate] -
1397
+ * @param {string} [arg.toDate] -
1398
+ * @param {string} [arg.filterOn] -
1399
+ * @returns {Promise<MultiCartResponse>} - Success response
1400
+ * @summary: Get cart list for store os user
1401
+ * @description: Get all carts for the store os user which is created for customer
1114
1402
  */
1115
- async getPromotionById({ id } = {}) {
1116
- const { error } = CartValidator.getPromotionById().validate(
1403
+ async getCartList({ fromDate, toDate, filterOn } = {}) {
1404
+ const { error } = CartValidator.getCartList().validate(
1117
1405
  {
1118
- id,
1406
+ fromDate,
1407
+ toDate,
1408
+ filterOn,
1119
1409
  },
1120
1410
  { abortEarly: false, allowUnknown: true }
1121
1411
  );
@@ -1124,39 +1414,46 @@ class Cart {
1124
1414
  }
1125
1415
 
1126
1416
  // Showing warrnings if extra unknown parameters are found
1127
- const { error: warrning } = CartValidator.getPromotionById().validate(
1417
+ const { error: warrning } = CartValidator.getCartList().validate(
1128
1418
  {
1129
- id,
1419
+ fromDate,
1420
+ toDate,
1421
+ filterOn,
1130
1422
  },
1131
1423
  { abortEarly: false, allowUnknown: false }
1132
1424
  );
1133
1425
  if (warrning) {
1134
1426
  Logger({
1135
1427
  level: "WARN",
1136
- message: "Parameter Validation warrnings for getPromotionById",
1428
+ message: "Parameter Validation warrnings for getCartList",
1137
1429
  });
1138
1430
  Logger({ level: "WARN", message: warrning });
1139
1431
  }
1140
1432
 
1141
1433
  const query_params = {};
1434
+ query_params["from_date"] = fromDate;
1435
+ query_params["to_date"] = toDate;
1436
+ query_params["filter_on"] = filterOn;
1142
1437
 
1143
1438
  const response = await PlatformAPIClient.execute(
1144
1439
  this.config,
1145
1440
  "get",
1146
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion/${id}`,
1441
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/cart-list`,
1147
1442
  query_params,
1148
1443
  undefined
1149
1444
  );
1150
1445
 
1151
- const { error: res_error } = CartModel.PromotionUpdate().validate(
1152
- response,
1153
- { abortEarly: false, allowUnknown: false }
1154
- );
1446
+ const {
1447
+ error: res_error,
1448
+ } = CartModel.MultiCartResponse().validate(response, {
1449
+ abortEarly: false,
1450
+ allowUnknown: false,
1451
+ });
1155
1452
 
1156
1453
  if (res_error) {
1157
1454
  Logger({
1158
1455
  level: "WARN",
1159
- message: "Response Validation Warnnings for getPromotionById",
1456
+ message: "Response Validation Warnnings for getCartList",
1160
1457
  });
1161
1458
  Logger({ level: "WARN", message: res_error });
1162
1459
  }
@@ -1166,15 +1463,15 @@ class Cart {
1166
1463
 
1167
1464
  /**
1168
1465
  * @param {Object} arg - Arg object.
1169
- * @param {string} [arg.code] -
1170
- * @returns {Promise<Object>} - Success response
1171
- * @summary: Check if promotion is already created with promotion code
1172
- * @description: Check if sent promotion code is already existing promotion code. As promotion code is to be unique.
1466
+ * @param {GetShareCartLinkRequest} arg.body
1467
+ * @returns {Promise<GetShareCartLinkResponse>} - Success response
1468
+ * @summary: Generate token for sharing the cart
1469
+ * @description: Use this API to generate a shared cart snapshot and return a shortlink token. The link can be shared with other users for getting the same items in their cart.
1173
1470
  */
1174
- async getPromotionCodeExists({ code } = {}) {
1175
- const { error } = CartValidator.getPromotionCodeExists().validate(
1471
+ async getCartShareLink({ body } = {}) {
1472
+ const { error } = CartValidator.getCartShareLink().validate(
1176
1473
  {
1177
- code,
1474
+ body,
1178
1475
  },
1179
1476
  { abortEarly: false, allowUnknown: true }
1180
1477
  );
@@ -1183,32 +1480,33 @@ class Cart {
1183
1480
  }
1184
1481
 
1185
1482
  // Showing warrnings if extra unknown parameters are found
1186
- const { error: warrning } = CartValidator.getPromotionCodeExists().validate(
1483
+ const { error: warrning } = CartValidator.getCartShareLink().validate(
1187
1484
  {
1188
- code,
1485
+ body,
1189
1486
  },
1190
1487
  { abortEarly: false, allowUnknown: false }
1191
1488
  );
1192
1489
  if (warrning) {
1193
1490
  Logger({
1194
1491
  level: "WARN",
1195
- message: "Parameter Validation warrnings for getPromotionCodeExists",
1492
+ message: "Parameter Validation warrnings for getCartShareLink",
1196
1493
  });
1197
1494
  Logger({ level: "WARN", message: warrning });
1198
1495
  }
1199
1496
 
1200
1497
  const query_params = {};
1201
- query_params["code"] = code;
1202
1498
 
1203
1499
  const response = await PlatformAPIClient.execute(
1204
1500
  this.config,
1205
- "get",
1206
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion_code_exists`,
1501
+ "post",
1502
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/share-cart`,
1207
1503
  query_params,
1208
- undefined
1504
+ body
1209
1505
  );
1210
1506
 
1211
- const { error: res_error } = Joi.any().validate(response, {
1507
+ const {
1508
+ error: res_error,
1509
+ } = CartModel.GetShareCartLinkResponse().validate(response, {
1212
1510
  abortEarly: false,
1213
1511
  allowUnknown: false,
1214
1512
  });
@@ -1216,7 +1514,7 @@ class Cart {
1216
1514
  if (res_error) {
1217
1515
  Logger({
1218
1516
  level: "WARN",
1219
- message: "Response Validation Warnnings for getPromotionCodeExists",
1517
+ message: "Response Validation Warnnings for getCartShareLink",
1220
1518
  });
1221
1519
  Logger({ level: "WARN", message: res_error });
1222
1520
  }
@@ -1226,38 +1524,15 @@ class Cart {
1226
1524
 
1227
1525
  /**
1228
1526
  * @param {Object} arg - Arg object.
1229
- * @param {number} [arg.pageNo] -
1230
- * @param {number} [arg.pageSize] -
1231
- * @param {string} [arg.q] -
1232
- * @param {boolean} [arg.isActive] -
1233
- * @param {string} [arg.promoGroup] -
1234
- * @param {string} [arg.promotionType] -
1235
- * @param {string} [arg.fpPanel] -
1236
- * @param {string} [arg.promotionId] -
1237
- * @returns {Promise<PromotionsResponse>} - Success response
1238
- * @summary: Get promotion list
1239
- * @description: Get promotion list with pagination
1527
+ * @param {string} arg.token - Token of the shared short link
1528
+ * @returns {Promise<SharedCartResponse>} - Success response
1529
+ * @summary: Get details of a shared cart
1530
+ * @description: Use this API to get the shared cart details as per the token generated using the share-cart API.
1240
1531
  */
1241
- async getPromotions({
1242
- pageNo,
1243
- pageSize,
1244
- q,
1245
- isActive,
1246
- promoGroup,
1247
- promotionType,
1248
- fpPanel,
1249
- promotionId,
1250
- } = {}) {
1251
- const { error } = CartValidator.getPromotions().validate(
1532
+ async getCartSharedItems({ token } = {}) {
1533
+ const { error } = CartValidator.getCartSharedItems().validate(
1252
1534
  {
1253
- pageNo,
1254
- pageSize,
1255
- q,
1256
- isActive,
1257
- promoGroup,
1258
- promotionType,
1259
- fpPanel,
1260
- promotionId,
1535
+ token,
1261
1536
  },
1262
1537
  { abortEarly: false, allowUnknown: true }
1263
1538
  );
@@ -1266,48 +1541,33 @@ class Cart {
1266
1541
  }
1267
1542
 
1268
1543
  // Showing warrnings if extra unknown parameters are found
1269
- const { error: warrning } = CartValidator.getPromotions().validate(
1544
+ const { error: warrning } = CartValidator.getCartSharedItems().validate(
1270
1545
  {
1271
- pageNo,
1272
- pageSize,
1273
- q,
1274
- isActive,
1275
- promoGroup,
1276
- promotionType,
1277
- fpPanel,
1278
- promotionId,
1546
+ token,
1279
1547
  },
1280
1548
  { abortEarly: false, allowUnknown: false }
1281
1549
  );
1282
1550
  if (warrning) {
1283
1551
  Logger({
1284
1552
  level: "WARN",
1285
- message: "Parameter Validation warrnings for getPromotions",
1553
+ message: "Parameter Validation warrnings for getCartSharedItems",
1286
1554
  });
1287
1555
  Logger({ level: "WARN", message: warrning });
1288
1556
  }
1289
1557
 
1290
1558
  const query_params = {};
1291
- query_params["page_no"] = pageNo;
1292
- query_params["page_size"] = pageSize;
1293
- query_params["q"] = q;
1294
- query_params["is_active"] = isActive;
1295
- query_params["promo_group"] = promoGroup;
1296
- query_params["promotion_type"] = promotionType;
1297
- query_params["fp_panel"] = fpPanel;
1298
- query_params["promotion_id"] = promotionId;
1299
1559
 
1300
1560
  const response = await PlatformAPIClient.execute(
1301
1561
  this.config,
1302
1562
  "get",
1303
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion`,
1563
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/share-cart/${token}`,
1304
1564
  query_params,
1305
1565
  undefined
1306
1566
  );
1307
1567
 
1308
1568
  const {
1309
1569
  error: res_error,
1310
- } = CartModel.PromotionsResponse().validate(response, {
1570
+ } = CartModel.SharedCartResponse().validate(response, {
1311
1571
  abortEarly: false,
1312
1572
  allowUnknown: false,
1313
1573
  });
@@ -1315,7 +1575,7 @@ class Cart {
1315
1575
  if (res_error) {
1316
1576
  Logger({
1317
1577
  level: "WARN",
1318
- message: "Response Validation Warnnings for getPromotions",
1578
+ message: "Response Validation Warnnings for getCartSharedItems",
1319
1579
  });
1320
1580
  Logger({ level: "WARN", message: res_error });
1321
1581
  }
@@ -1325,66 +1585,1867 @@ class Cart {
1325
1585
 
1326
1586
  /**
1327
1587
  * @param {Object} arg - Arg object.
1328
- * @param {string} arg.companyId - Current company id
1329
- * @param {string} arg.applicationId - Current Application _id
1588
+ * @param {string} arg.id -
1589
+ * @returns {Promise<CouponUpdate>} - Success response
1590
+ * @summary: Get with single coupon details or coupon list
1591
+ * @description: Get single coupon details with `id` in path param
1592
+ */
1593
+ async getCouponById({ id } = {}) {
1594
+ const { error } = CartValidator.getCouponById().validate(
1595
+ {
1596
+ id,
1597
+ },
1598
+ { abortEarly: false, allowUnknown: true }
1599
+ );
1600
+ if (error) {
1601
+ return Promise.reject(new FDKClientValidationError(error));
1602
+ }
1603
+
1604
+ // Showing warrnings if extra unknown parameters are found
1605
+ const { error: warrning } = CartValidator.getCouponById().validate(
1606
+ {
1607
+ id,
1608
+ },
1609
+ { abortEarly: false, allowUnknown: false }
1610
+ );
1611
+ if (warrning) {
1612
+ Logger({
1613
+ level: "WARN",
1614
+ message: "Parameter Validation warrnings for getCouponById",
1615
+ });
1616
+ Logger({ level: "WARN", message: warrning });
1617
+ }
1618
+
1619
+ const query_params = {};
1620
+
1621
+ const response = await PlatformAPIClient.execute(
1622
+ this.config,
1623
+ "get",
1624
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon/${id}`,
1625
+ query_params,
1626
+ undefined
1627
+ );
1628
+
1629
+ const { error: res_error } = CartModel.CouponUpdate().validate(response, {
1630
+ abortEarly: false,
1631
+ allowUnknown: false,
1632
+ });
1633
+
1634
+ if (res_error) {
1635
+ Logger({
1636
+ level: "WARN",
1637
+ message: "Response Validation Warnnings for getCouponById",
1638
+ });
1639
+ Logger({ level: "WARN", message: res_error });
1640
+ }
1641
+
1642
+ return response;
1643
+ }
1644
+
1645
+ /**
1646
+ * @param {Object} arg - Arg object.
1647
+ * @param {string} [arg.code] -
1648
+ * @returns {Promise<Object>} - Success response
1649
+ * @summary: Check if coupon is already created with coupon code
1650
+ * @description: Check if sent coupon code is already existing coupon code. As coupon code is to be unique.
1651
+ */
1652
+ async getCouponCodeExists({ code } = {}) {
1653
+ const { error } = CartValidator.getCouponCodeExists().validate(
1654
+ {
1655
+ code,
1656
+ },
1657
+ { abortEarly: false, allowUnknown: true }
1658
+ );
1659
+ if (error) {
1660
+ return Promise.reject(new FDKClientValidationError(error));
1661
+ }
1662
+
1663
+ // Showing warrnings if extra unknown parameters are found
1664
+ const { error: warrning } = CartValidator.getCouponCodeExists().validate(
1665
+ {
1666
+ code,
1667
+ },
1668
+ { abortEarly: false, allowUnknown: false }
1669
+ );
1670
+ if (warrning) {
1671
+ Logger({
1672
+ level: "WARN",
1673
+ message: "Parameter Validation warrnings for getCouponCodeExists",
1674
+ });
1675
+ Logger({ level: "WARN", message: warrning });
1676
+ }
1677
+
1678
+ const query_params = {};
1679
+ query_params["code"] = code;
1680
+
1681
+ const response = await PlatformAPIClient.execute(
1682
+ this.config,
1683
+ "get",
1684
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon_code_exists`,
1685
+ query_params,
1686
+ undefined
1687
+ );
1688
+
1689
+ const { error: res_error } = Joi.any().validate(response, {
1690
+ abortEarly: false,
1691
+ allowUnknown: false,
1692
+ });
1693
+
1694
+ if (res_error) {
1695
+ Logger({
1696
+ level: "WARN",
1697
+ message: "Response Validation Warnnings for getCouponCodeExists",
1698
+ });
1699
+ Logger({ level: "WARN", message: res_error });
1700
+ }
1701
+
1702
+ return response;
1703
+ }
1704
+
1705
+ /**
1706
+ * @param {Object} arg - Arg object.
1707
+ * @returns {Promise<Object>} - Success response
1708
+ * @summary: Get coupon options enums with display values
1709
+ * @description: Get coupon enum values for fields in valid coupon object. Used for front end to create, update and filter coupon lists via fields
1710
+ */
1711
+ async getCouponOptionValues({} = {}) {
1712
+ const { error } = CartValidator.getCouponOptionValues().validate(
1713
+ {},
1714
+ { abortEarly: false, allowUnknown: true }
1715
+ );
1716
+ if (error) {
1717
+ return Promise.reject(new FDKClientValidationError(error));
1718
+ }
1719
+
1720
+ // Showing warrnings if extra unknown parameters are found
1721
+ const { error: warrning } = CartValidator.getCouponOptionValues().validate(
1722
+ {},
1723
+ { abortEarly: false, allowUnknown: false }
1724
+ );
1725
+ if (warrning) {
1726
+ Logger({
1727
+ level: "WARN",
1728
+ message: "Parameter Validation warrnings for getCouponOptionValues",
1729
+ });
1730
+ Logger({ level: "WARN", message: warrning });
1731
+ }
1732
+
1733
+ const query_params = {};
1734
+
1735
+ const response = await PlatformAPIClient.execute(
1736
+ this.config,
1737
+ "get",
1738
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon_options`,
1739
+ query_params,
1740
+ undefined
1741
+ );
1742
+
1743
+ const { error: res_error } = Joi.any().validate(response, {
1744
+ abortEarly: false,
1745
+ allowUnknown: false,
1746
+ });
1747
+
1748
+ if (res_error) {
1749
+ Logger({
1750
+ level: "WARN",
1751
+ message: "Response Validation Warnnings for getCouponOptionValues",
1752
+ });
1753
+ Logger({ level: "WARN", message: res_error });
1754
+ }
1755
+
1756
+ return response;
1757
+ }
1758
+
1759
+ /**
1760
+ * @param {Object} arg - Arg object.
1761
+ * @param {number} [arg.pageNo] -
1330
1762
  * @param {number} [arg.pageSize] -
1331
- * @param {string} [arg.q] -
1332
- * @param {boolean} [arg.isActive] -
1333
- * @param {string} [arg.promoGroup] -
1334
- * @param {string} [arg.promotionType] -
1335
- * @param {string} [arg.fpPanel] -
1336
- * @param {string} [arg.promotionId] -
1337
- * @summary: Get promotion list
1338
- * @description: Get promotion list with pagination
1763
+ * @param {boolean} [arg.isArchived] -
1764
+ * @param {string} [arg.title] -
1765
+ * @param {boolean} [arg.isPublic] -
1766
+ * @param {boolean} [arg.isDisplay] -
1767
+ * @param {string} [arg.typeSlug] -
1768
+ * @param {string} [arg.code] -
1769
+ * @returns {Promise<CouponsResponse>} - Success response
1770
+ * @summary: Get with single coupon details or coupon list
1771
+ * @description: Get coupon list with pagination
1339
1772
  */
1340
- getPromotionsPaginator({
1341
- companyId,
1342
- applicationId,
1773
+ async getCoupons({
1774
+ pageNo,
1343
1775
  pageSize,
1344
- q,
1345
- isActive,
1346
- promoGroup,
1347
- promotionType,
1348
- fpPanel,
1349
- promotionId,
1776
+ isArchived,
1777
+ title,
1778
+ isPublic,
1779
+ isDisplay,
1780
+ typeSlug,
1781
+ code,
1350
1782
  } = {}) {
1351
- const paginator = new Paginator();
1352
- const callback = async () => {
1353
- const pageId = paginator.nextId;
1354
- const pageNo = paginator.pageNo;
1355
- const pageType = "number";
1356
- const data = await this.getPromotions({
1357
- companyId: companyId,
1358
- applicationId: applicationId,
1359
- pageNo: pageNo,
1360
- pageSize: pageSize,
1361
- q: q,
1362
- isActive: isActive,
1363
- promoGroup: promoGroup,
1364
- promotionType: promotionType,
1365
- fpPanel: fpPanel,
1366
- promotionId: promotionId,
1367
- });
1368
- paginator.setPaginator({
1369
- hasNext: data.page.has_next ? true : false,
1370
- nextId: data.page.next_id,
1783
+ const { error } = CartValidator.getCoupons().validate(
1784
+ {
1785
+ pageNo,
1786
+ pageSize,
1787
+ isArchived,
1788
+ title,
1789
+ isPublic,
1790
+ isDisplay,
1791
+ typeSlug,
1792
+ code,
1793
+ },
1794
+ { abortEarly: false, allowUnknown: true }
1795
+ );
1796
+ if (error) {
1797
+ return Promise.reject(new FDKClientValidationError(error));
1798
+ }
1799
+
1800
+ // Showing warrnings if extra unknown parameters are found
1801
+ const { error: warrning } = CartValidator.getCoupons().validate(
1802
+ {
1803
+ pageNo,
1804
+ pageSize,
1805
+ isArchived,
1806
+ title,
1807
+ isPublic,
1808
+ isDisplay,
1809
+ typeSlug,
1810
+ code,
1811
+ },
1812
+ { abortEarly: false, allowUnknown: false }
1813
+ );
1814
+ if (warrning) {
1815
+ Logger({
1816
+ level: "WARN",
1817
+ message: "Parameter Validation warrnings for getCoupons",
1818
+ });
1819
+ Logger({ level: "WARN", message: warrning });
1820
+ }
1821
+
1822
+ const query_params = {};
1823
+ query_params["page_no"] = pageNo;
1824
+ query_params["page_size"] = pageSize;
1825
+ query_params["is_archived"] = isArchived;
1826
+ query_params["title"] = title;
1827
+ query_params["is_public"] = isPublic;
1828
+ query_params["is_display"] = isDisplay;
1829
+ query_params["type_slug"] = typeSlug;
1830
+ query_params["code"] = code;
1831
+
1832
+ const response = await PlatformAPIClient.execute(
1833
+ this.config,
1834
+ "get",
1835
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon`,
1836
+ query_params,
1837
+ undefined
1838
+ );
1839
+
1840
+ const { error: res_error } = CartModel.CouponsResponse().validate(
1841
+ response,
1842
+ { abortEarly: false, allowUnknown: false }
1843
+ );
1844
+
1845
+ if (res_error) {
1846
+ Logger({
1847
+ level: "WARN",
1848
+ message: "Response Validation Warnnings for getCoupons",
1849
+ });
1850
+ Logger({ level: "WARN", message: res_error });
1851
+ }
1852
+
1853
+ return response;
1854
+ }
1855
+
1856
+ /**
1857
+ * @param {Object} arg - Arg object.
1858
+ * @param {string} arg.companyId - Current company id
1859
+ * @param {string} arg.applicationId - Current Application _id
1860
+ * @param {number} [arg.pageSize] -
1861
+ * @param {boolean} [arg.isArchived] -
1862
+ * @param {string} [arg.title] -
1863
+ * @param {boolean} [arg.isPublic] -
1864
+ * @param {boolean} [arg.isDisplay] -
1865
+ * @param {string} [arg.typeSlug] -
1866
+ * @param {string} [arg.code] -
1867
+ * @summary: Get with single coupon details or coupon list
1868
+ * @description: Get coupon list with pagination
1869
+ */
1870
+ getCouponsPaginator({
1871
+ companyId,
1872
+ applicationId,
1873
+ pageSize,
1874
+ isArchived,
1875
+ title,
1876
+ isPublic,
1877
+ isDisplay,
1878
+ typeSlug,
1879
+ code,
1880
+ } = {}) {
1881
+ const paginator = new Paginator();
1882
+ const callback = async () => {
1883
+ const pageId = paginator.nextId;
1884
+ const pageNo = paginator.pageNo;
1885
+ const pageType = "number";
1886
+ const data = await this.getCoupons({
1887
+ companyId: companyId,
1888
+ applicationId: applicationId,
1889
+ pageNo: pageNo,
1890
+ pageSize: pageSize,
1891
+ isArchived: isArchived,
1892
+ title: title,
1893
+ isPublic: isPublic,
1894
+ isDisplay: isDisplay,
1895
+ typeSlug: typeSlug,
1896
+ code: code,
1897
+ });
1898
+ paginator.setPaginator({
1899
+ hasNext: data.page.has_next ? true : false,
1900
+ nextId: data.page.next_id,
1901
+ });
1902
+ return data;
1903
+ };
1904
+ paginator.setCallback(callback.bind(this));
1905
+ return paginator;
1906
+ }
1907
+
1908
+ /**
1909
+ * @param {Object} arg - Arg object.
1910
+ * @param {string} [arg.id] - The unique identifier of the cart.
1911
+ * @param {boolean} [arg.buyNow] -
1912
+ * @returns {Promise<CartItemCountResponse>} - Success response
1913
+ * @summary: Count items in the customer's cart
1914
+ * @description: Use this API to get the total number of items present in cart.
1915
+ */
1916
+ async getItemCount({ id, buyNow } = {}) {
1917
+ const { error } = CartValidator.getItemCount().validate(
1918
+ {
1919
+ id,
1920
+ buyNow,
1921
+ },
1922
+ { abortEarly: false, allowUnknown: true }
1923
+ );
1924
+ if (error) {
1925
+ return Promise.reject(new FDKClientValidationError(error));
1926
+ }
1927
+
1928
+ // Showing warrnings if extra unknown parameters are found
1929
+ const { error: warrning } = CartValidator.getItemCount().validate(
1930
+ {
1931
+ id,
1932
+ buyNow,
1933
+ },
1934
+ { abortEarly: false, allowUnknown: false }
1935
+ );
1936
+ if (warrning) {
1937
+ Logger({
1938
+ level: "WARN",
1939
+ message: "Parameter Validation warrnings for getItemCount",
1940
+ });
1941
+ Logger({ level: "WARN", message: warrning });
1942
+ }
1943
+
1944
+ const query_params = {};
1945
+ query_params["id"] = id;
1946
+ query_params["buy_now"] = buyNow;
1947
+
1948
+ const response = await PlatformAPIClient.execute(
1949
+ this.config,
1950
+ "get",
1951
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/basic`,
1952
+ query_params,
1953
+ undefined
1954
+ );
1955
+
1956
+ const {
1957
+ error: res_error,
1958
+ } = CartModel.CartItemCountResponse().validate(response, {
1959
+ abortEarly: false,
1960
+ allowUnknown: false,
1961
+ });
1962
+
1963
+ if (res_error) {
1964
+ Logger({
1965
+ level: "WARN",
1966
+ message: "Response Validation Warnnings for getItemCount",
1967
+ });
1968
+ Logger({ level: "WARN", message: res_error });
1969
+ }
1970
+
1971
+ return response;
1972
+ }
1973
+
1974
+ /**
1975
+ * @param {Object} arg - Arg object.
1976
+ * @param {string} [arg.entityType] - Entity_type as promotion or coupon
1977
+ * @param {boolean} [arg.isHidden] - Promo-coupon config shown or not
1978
+ * @returns {Promise<ActivePromosResponse>} - Success response
1979
+ * @summary: Fetch all promos that are set as active
1980
+ * @description: Use this API to get list of all the active promos/coupons.
1981
+ */
1982
+ async getPromosCouponConfig({ entityType, isHidden } = {}) {
1983
+ const { error } = CartValidator.getPromosCouponConfig().validate(
1984
+ {
1985
+ entityType,
1986
+ isHidden,
1987
+ },
1988
+ { abortEarly: false, allowUnknown: true }
1989
+ );
1990
+ if (error) {
1991
+ return Promise.reject(new FDKClientValidationError(error));
1992
+ }
1993
+
1994
+ // Showing warrnings if extra unknown parameters are found
1995
+ const { error: warrning } = CartValidator.getPromosCouponConfig().validate(
1996
+ {
1997
+ entityType,
1998
+ isHidden,
1999
+ },
2000
+ { abortEarly: false, allowUnknown: false }
2001
+ );
2002
+ if (warrning) {
2003
+ Logger({
2004
+ level: "WARN",
2005
+ message: "Parameter Validation warrnings for getPromosCouponConfig",
2006
+ });
2007
+ Logger({ level: "WARN", message: warrning });
2008
+ }
2009
+
2010
+ const query_params = {};
2011
+ query_params["entity_type"] = entityType;
2012
+ query_params["is_hidden"] = isHidden;
2013
+
2014
+ const response = await PlatformAPIClient.execute(
2015
+ this.config,
2016
+ "get",
2017
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promo-coupons`,
2018
+ query_params,
2019
+ undefined
2020
+ );
2021
+
2022
+ const {
2023
+ error: res_error,
2024
+ } = CartModel.ActivePromosResponse().validate(response, {
2025
+ abortEarly: false,
2026
+ allowUnknown: false,
2027
+ });
2028
+
2029
+ if (res_error) {
2030
+ Logger({
2031
+ level: "WARN",
2032
+ message: "Response Validation Warnnings for getPromosCouponConfig",
2033
+ });
2034
+ Logger({ level: "WARN", message: res_error });
2035
+ }
2036
+
2037
+ return response;
2038
+ }
2039
+
2040
+ /**
2041
+ * @param {Object} arg - Arg object.
2042
+ * @param {string} arg.id -
2043
+ * @returns {Promise<PromotionUpdate>} - Success response
2044
+ * @summary: Get with single promotion details or promotion list
2045
+ * @description: Get single promotion details with `id` in path param
2046
+ */
2047
+ async getPromotionById({ id } = {}) {
2048
+ const { error } = CartValidator.getPromotionById().validate(
2049
+ {
2050
+ id,
2051
+ },
2052
+ { abortEarly: false, allowUnknown: true }
2053
+ );
2054
+ if (error) {
2055
+ return Promise.reject(new FDKClientValidationError(error));
2056
+ }
2057
+
2058
+ // Showing warrnings if extra unknown parameters are found
2059
+ const { error: warrning } = CartValidator.getPromotionById().validate(
2060
+ {
2061
+ id,
2062
+ },
2063
+ { abortEarly: false, allowUnknown: false }
2064
+ );
2065
+ if (warrning) {
2066
+ Logger({
2067
+ level: "WARN",
2068
+ message: "Parameter Validation warrnings for getPromotionById",
2069
+ });
2070
+ Logger({ level: "WARN", message: warrning });
2071
+ }
2072
+
2073
+ const query_params = {};
2074
+
2075
+ const response = await PlatformAPIClient.execute(
2076
+ this.config,
2077
+ "get",
2078
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion/${id}`,
2079
+ query_params,
2080
+ undefined
2081
+ );
2082
+
2083
+ const { error: res_error } = CartModel.PromotionUpdate().validate(
2084
+ response,
2085
+ { abortEarly: false, allowUnknown: false }
2086
+ );
2087
+
2088
+ if (res_error) {
2089
+ Logger({
2090
+ level: "WARN",
2091
+ message: "Response Validation Warnnings for getPromotionById",
2092
+ });
2093
+ Logger({ level: "WARN", message: res_error });
2094
+ }
2095
+
2096
+ return response;
2097
+ }
2098
+
2099
+ /**
2100
+ * @param {Object} arg - Arg object.
2101
+ * @param {string} [arg.code] -
2102
+ * @returns {Promise<Object>} - Success response
2103
+ * @summary: Check if promotion is already created with promotion code
2104
+ * @description: Check if sent promotion code is already existing promotion code. As promotion code is to be unique.
2105
+ */
2106
+ async getPromotionCodeExists({ code } = {}) {
2107
+ const { error } = CartValidator.getPromotionCodeExists().validate(
2108
+ {
2109
+ code,
2110
+ },
2111
+ { abortEarly: false, allowUnknown: true }
2112
+ );
2113
+ if (error) {
2114
+ return Promise.reject(new FDKClientValidationError(error));
2115
+ }
2116
+
2117
+ // Showing warrnings if extra unknown parameters are found
2118
+ const { error: warrning } = CartValidator.getPromotionCodeExists().validate(
2119
+ {
2120
+ code,
2121
+ },
2122
+ { abortEarly: false, allowUnknown: false }
2123
+ );
2124
+ if (warrning) {
2125
+ Logger({
2126
+ level: "WARN",
2127
+ message: "Parameter Validation warrnings for getPromotionCodeExists",
2128
+ });
2129
+ Logger({ level: "WARN", message: warrning });
2130
+ }
2131
+
2132
+ const query_params = {};
2133
+ query_params["code"] = code;
2134
+
2135
+ const response = await PlatformAPIClient.execute(
2136
+ this.config,
2137
+ "get",
2138
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion_code_exists`,
2139
+ query_params,
2140
+ undefined
2141
+ );
2142
+
2143
+ const { error: res_error } = Joi.any().validate(response, {
2144
+ abortEarly: false,
2145
+ allowUnknown: false,
2146
+ });
2147
+
2148
+ if (res_error) {
2149
+ Logger({
2150
+ level: "WARN",
2151
+ message: "Response Validation Warnnings for getPromotionCodeExists",
2152
+ });
2153
+ Logger({ level: "WARN", message: res_error });
2154
+ }
2155
+
2156
+ return response;
2157
+ }
2158
+
2159
+ /**
2160
+ * @param {Object} arg - Arg object.
2161
+ * @param {number} [arg.pageNo] -
2162
+ * @param {number} [arg.pageSize] -
2163
+ * @param {string} [arg.q] -
2164
+ * @param {boolean} [arg.isActive] -
2165
+ * @param {string} [arg.promoGroup] -
2166
+ * @param {string} [arg.promotionType] -
2167
+ * @param {string} [arg.fpPanel] -
2168
+ * @param {string} [arg.promotionId] -
2169
+ * @returns {Promise<PromotionsResponse>} - Success response
2170
+ * @summary: Get promotion list
2171
+ * @description: Get promotion list with pagination
2172
+ */
2173
+ async getPromotions({
2174
+ pageNo,
2175
+ pageSize,
2176
+ q,
2177
+ isActive,
2178
+ promoGroup,
2179
+ promotionType,
2180
+ fpPanel,
2181
+ promotionId,
2182
+ } = {}) {
2183
+ const { error } = CartValidator.getPromotions().validate(
2184
+ {
2185
+ pageNo,
2186
+ pageSize,
2187
+ q,
2188
+ isActive,
2189
+ promoGroup,
2190
+ promotionType,
2191
+ fpPanel,
2192
+ promotionId,
2193
+ },
2194
+ { abortEarly: false, allowUnknown: true }
2195
+ );
2196
+ if (error) {
2197
+ return Promise.reject(new FDKClientValidationError(error));
2198
+ }
2199
+
2200
+ // Showing warrnings if extra unknown parameters are found
2201
+ const { error: warrning } = CartValidator.getPromotions().validate(
2202
+ {
2203
+ pageNo,
2204
+ pageSize,
2205
+ q,
2206
+ isActive,
2207
+ promoGroup,
2208
+ promotionType,
2209
+ fpPanel,
2210
+ promotionId,
2211
+ },
2212
+ { abortEarly: false, allowUnknown: false }
2213
+ );
2214
+ if (warrning) {
2215
+ Logger({
2216
+ level: "WARN",
2217
+ message: "Parameter Validation warrnings for getPromotions",
2218
+ });
2219
+ Logger({ level: "WARN", message: warrning });
2220
+ }
2221
+
2222
+ const query_params = {};
2223
+ query_params["page_no"] = pageNo;
2224
+ query_params["page_size"] = pageSize;
2225
+ query_params["q"] = q;
2226
+ query_params["is_active"] = isActive;
2227
+ query_params["promo_group"] = promoGroup;
2228
+ query_params["promotion_type"] = promotionType;
2229
+ query_params["fp_panel"] = fpPanel;
2230
+ query_params["promotion_id"] = promotionId;
2231
+
2232
+ const response = await PlatformAPIClient.execute(
2233
+ this.config,
2234
+ "get",
2235
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion`,
2236
+ query_params,
2237
+ undefined
2238
+ );
2239
+
2240
+ const {
2241
+ error: res_error,
2242
+ } = CartModel.PromotionsResponse().validate(response, {
2243
+ abortEarly: false,
2244
+ allowUnknown: false,
2245
+ });
2246
+
2247
+ if (res_error) {
2248
+ Logger({
2249
+ level: "WARN",
2250
+ message: "Response Validation Warnnings for getPromotions",
2251
+ });
2252
+ Logger({ level: "WARN", message: res_error });
2253
+ }
2254
+
2255
+ return response;
2256
+ }
2257
+
2258
+ /**
2259
+ * @param {Object} arg - Arg object.
2260
+ * @param {string} arg.companyId - Current company id
2261
+ * @param {string} arg.applicationId - Current Application _id
2262
+ * @param {number} [arg.pageSize] -
2263
+ * @param {string} [arg.q] -
2264
+ * @param {boolean} [arg.isActive] -
2265
+ * @param {string} [arg.promoGroup] -
2266
+ * @param {string} [arg.promotionType] -
2267
+ * @param {string} [arg.fpPanel] -
2268
+ * @param {string} [arg.promotionId] -
2269
+ * @summary: Get promotion list
2270
+ * @description: Get promotion list with pagination
2271
+ */
2272
+ getPromotionsPaginator({
2273
+ companyId,
2274
+ applicationId,
2275
+ pageSize,
2276
+ q,
2277
+ isActive,
2278
+ promoGroup,
2279
+ promotionType,
2280
+ fpPanel,
2281
+ promotionId,
2282
+ } = {}) {
2283
+ const paginator = new Paginator();
2284
+ const callback = async () => {
2285
+ const pageId = paginator.nextId;
2286
+ const pageNo = paginator.pageNo;
2287
+ const pageType = "number";
2288
+ const data = await this.getPromotions({
2289
+ companyId: companyId,
2290
+ applicationId: applicationId,
2291
+ pageNo: pageNo,
2292
+ pageSize: pageSize,
2293
+ q: q,
2294
+ isActive: isActive,
2295
+ promoGroup: promoGroup,
2296
+ promotionType: promotionType,
2297
+ fpPanel: fpPanel,
2298
+ promotionId: promotionId,
2299
+ });
2300
+ paginator.setPaginator({
2301
+ hasNext: data.page.has_next ? true : false,
2302
+ nextId: data.page.next_id,
2303
+ });
2304
+ return data;
2305
+ };
2306
+ paginator.setCallback(callback.bind(this));
2307
+ return paginator;
2308
+ }
2309
+
2310
+ /**
2311
+ * @param {Object} arg - Arg object.
2312
+ * @param {number} [arg.pickAtStoreUid] -
2313
+ * @param {number} [arg.orderingStoreId] -
2314
+ * @param {boolean} [arg.i] - This is a boolean value. Select `true` to
2315
+ * retrieve all the items added in the cart.
2316
+ * @param {boolean} [arg.p] - This is a boolean value. Select `true` for
2317
+ * getting a payment option in response.
2318
+ * @param {string} [arg.id] - The unique identifier of the cart
2319
+ * @param {string} [arg.addressId] - ID allotted to the selected address
2320
+ * @param {string} [arg.areaCode] - The PIN Code of the destination address,
2321
+ * e.g. 400059
2322
+ * @param {string} [arg.orderType] - The order type of shipment HomeDelivery
2323
+ * - If the customer wants the order home-delivered PickAtStore - If the
2324
+ * customer wants the handover of an order at the store itself.
2325
+ * @returns {Promise<PlatformCartShipmentsResponse>} - Success response
2326
+ * @summary: Get delivery date and options before checkout
2327
+ * @description: Use this API to get shipment details, expected delivery date, items and price breakup of the shipment.
2328
+ */
2329
+ async getShipments({
2330
+ pickAtStoreUid,
2331
+ orderingStoreId,
2332
+ i,
2333
+ p,
2334
+ id,
2335
+ addressId,
2336
+ areaCode,
2337
+ orderType,
2338
+ } = {}) {
2339
+ const { error } = CartValidator.getShipments().validate(
2340
+ {
2341
+ pickAtStoreUid,
2342
+ orderingStoreId,
2343
+ i,
2344
+ p,
2345
+ id,
2346
+ addressId,
2347
+ areaCode,
2348
+ orderType,
2349
+ },
2350
+ { abortEarly: false, allowUnknown: true }
2351
+ );
2352
+ if (error) {
2353
+ return Promise.reject(new FDKClientValidationError(error));
2354
+ }
2355
+
2356
+ // Showing warrnings if extra unknown parameters are found
2357
+ const { error: warrning } = CartValidator.getShipments().validate(
2358
+ {
2359
+ pickAtStoreUid,
2360
+ orderingStoreId,
2361
+ i,
2362
+ p,
2363
+ id,
2364
+ addressId,
2365
+ areaCode,
2366
+ orderType,
2367
+ },
2368
+ { abortEarly: false, allowUnknown: false }
2369
+ );
2370
+ if (warrning) {
2371
+ Logger({
2372
+ level: "WARN",
2373
+ message: "Parameter Validation warrnings for getShipments",
2374
+ });
2375
+ Logger({ level: "WARN", message: warrning });
2376
+ }
2377
+
2378
+ const query_params = {};
2379
+ query_params["pick_at_store_uid"] = pickAtStoreUid;
2380
+ query_params["ordering_store_id"] = orderingStoreId;
2381
+ query_params["i"] = i;
2382
+ query_params["p"] = p;
2383
+ query_params["id"] = id;
2384
+ query_params["address_id"] = addressId;
2385
+ query_params["area_code"] = areaCode;
2386
+ query_params["order_type"] = orderType;
2387
+
2388
+ const response = await PlatformAPIClient.execute(
2389
+ this.config,
2390
+ "get",
2391
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/shipment`,
2392
+ query_params,
2393
+ undefined
2394
+ );
2395
+
2396
+ const {
2397
+ error: res_error,
2398
+ } = CartModel.PlatformCartShipmentsResponse().validate(response, {
2399
+ abortEarly: false,
2400
+ allowUnknown: false,
2401
+ });
2402
+
2403
+ if (res_error) {
2404
+ Logger({
2405
+ level: "WARN",
2406
+ message: "Response Validation Warnnings for getShipments",
2407
+ });
2408
+ Logger({ level: "WARN", message: res_error });
2409
+ }
2410
+
2411
+ return response;
2412
+ }
2413
+
2414
+ /**
2415
+ * @param {Object} arg - Arg object.
2416
+ * @param {number} arg.storeUid -
2417
+ * @returns {Promise<StoreDetailsResponse>} - Success response
2418
+ * @summary: Get list of stores for give uids
2419
+ * @description: Use this API to get the store details by entering the unique identifier of the pickup stores shown in the response of available-delivery-mode API.
2420
+ */
2421
+ async getStoreAddressByUid({ storeUid } = {}) {
2422
+ const { error } = CartValidator.getStoreAddressByUid().validate(
2423
+ {
2424
+ storeUid,
2425
+ },
2426
+ { abortEarly: false, allowUnknown: true }
2427
+ );
2428
+ if (error) {
2429
+ return Promise.reject(new FDKClientValidationError(error));
2430
+ }
2431
+
2432
+ // Showing warrnings if extra unknown parameters are found
2433
+ const { error: warrning } = CartValidator.getStoreAddressByUid().validate(
2434
+ {
2435
+ storeUid,
2436
+ },
2437
+ { abortEarly: false, allowUnknown: false }
2438
+ );
2439
+ if (warrning) {
2440
+ Logger({
2441
+ level: "WARN",
2442
+ message: "Parameter Validation warrnings for getStoreAddressByUid",
2443
+ });
2444
+ Logger({ level: "WARN", message: warrning });
2445
+ }
2446
+
2447
+ const query_params = {};
2448
+ query_params["store_uid"] = storeUid;
2449
+
2450
+ const response = await PlatformAPIClient.execute(
2451
+ this.config,
2452
+ "get",
2453
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/store-address`,
2454
+ query_params,
2455
+ undefined
2456
+ );
2457
+
2458
+ const {
2459
+ error: res_error,
2460
+ } = CartModel.StoreDetailsResponse().validate(response, {
2461
+ abortEarly: false,
2462
+ allowUnknown: false,
2463
+ });
2464
+
2465
+ if (res_error) {
2466
+ Logger({
2467
+ level: "WARN",
2468
+ message: "Response Validation Warnnings for getStoreAddressByUid",
2469
+ });
2470
+ Logger({ level: "WARN", message: res_error });
2471
+ }
2472
+
2473
+ return response;
2474
+ }
2475
+
2476
+ /**
2477
+ * @param {Object} arg - Arg object.
2478
+ * @param {OverrideCheckoutReq} arg.body
2479
+ * @returns {Promise<OverrideCheckoutResponse>} - Success response
2480
+ * @summary: Create Fynd order with overriding cart details
2481
+ * @description: Generate Fynd order while overriding cart details sent with provided `cart_items`
2482
+ */
2483
+ async overrideCart({ body } = {}) {
2484
+ const { error } = CartValidator.overrideCart().validate(
2485
+ {
2486
+ body,
2487
+ },
2488
+ { abortEarly: false, allowUnknown: true }
2489
+ );
2490
+ if (error) {
2491
+ return Promise.reject(new FDKClientValidationError(error));
2492
+ }
2493
+
2494
+ // Showing warrnings if extra unknown parameters are found
2495
+ const { error: warrning } = CartValidator.overrideCart().validate(
2496
+ {
2497
+ body,
2498
+ },
2499
+ { abortEarly: false, allowUnknown: false }
2500
+ );
2501
+ if (warrning) {
2502
+ Logger({
2503
+ level: "WARN",
2504
+ message: "Parameter Validation warrnings for overrideCart",
2505
+ });
2506
+ Logger({ level: "WARN", message: warrning });
2507
+ }
2508
+
2509
+ const query_params = {};
2510
+
2511
+ const response = await PlatformAPIClient.execute(
2512
+ this.config,
2513
+ "post",
2514
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/checkout/over-ride`,
2515
+ query_params,
2516
+ body
2517
+ );
2518
+
2519
+ const {
2520
+ error: res_error,
2521
+ } = CartModel.OverrideCheckoutResponse().validate(response, {
2522
+ abortEarly: false,
2523
+ allowUnknown: false,
2524
+ });
2525
+
2526
+ if (res_error) {
2527
+ Logger({
2528
+ level: "WARN",
2529
+ message: "Response Validation Warnnings for overrideCart",
2530
+ });
2531
+ Logger({ level: "WARN", message: res_error });
2532
+ }
2533
+
2534
+ return response;
2535
+ }
2536
+
2537
+ /**
2538
+ * @param {Object} arg - Arg object.
2539
+ * @param {boolean} [arg.i] -
2540
+ * @param {boolean} [arg.b] -
2541
+ * @param {boolean} [arg.buyNow] -
2542
+ * @param {string} [arg.id] -
2543
+ * @param {PlatformAddCartRequest} arg.body
2544
+ * @returns {Promise<AddCartDetailResponse>} - Success response
2545
+ * @summary: Add items to cart
2546
+ * @description: Use this API to add items to the cart.
2547
+ */
2548
+ async platformAddItems({ body, i, b, buyNow, id } = {}) {
2549
+ const { error } = CartValidator.platformAddItems().validate(
2550
+ {
2551
+ body,
2552
+ i,
2553
+ b,
2554
+ buyNow,
2555
+ id,
2556
+ },
2557
+ { abortEarly: false, allowUnknown: true }
2558
+ );
2559
+ if (error) {
2560
+ return Promise.reject(new FDKClientValidationError(error));
2561
+ }
2562
+
2563
+ // Showing warrnings if extra unknown parameters are found
2564
+ const { error: warrning } = CartValidator.platformAddItems().validate(
2565
+ {
2566
+ body,
2567
+ i,
2568
+ b,
2569
+ buyNow,
2570
+ id,
2571
+ },
2572
+ { abortEarly: false, allowUnknown: false }
2573
+ );
2574
+ if (warrning) {
2575
+ Logger({
2576
+ level: "WARN",
2577
+ message: "Parameter Validation warrnings for platformAddItems",
2578
+ });
2579
+ Logger({ level: "WARN", message: warrning });
2580
+ }
2581
+
2582
+ const query_params = {};
2583
+ query_params["i"] = i;
2584
+ query_params["b"] = b;
2585
+ query_params["buy_now"] = buyNow;
2586
+ query_params["id"] = id;
2587
+
2588
+ const response = await PlatformAPIClient.execute(
2589
+ this.config,
2590
+ "post",
2591
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/detail`,
2592
+ query_params,
2593
+ body
2594
+ );
2595
+
2596
+ const {
2597
+ error: res_error,
2598
+ } = CartModel.AddCartDetailResponse().validate(response, {
2599
+ abortEarly: false,
2600
+ allowUnknown: false,
2601
+ });
2602
+
2603
+ if (res_error) {
2604
+ Logger({
2605
+ level: "WARN",
2606
+ message: "Response Validation Warnnings for platformAddItems",
2607
+ });
2608
+ Logger({ level: "WARN", message: res_error });
2609
+ }
2610
+
2611
+ return response;
2612
+ }
2613
+
2614
+ /**
2615
+ * @param {Object} arg - Arg object.
2616
+ * @param {string} [arg.id] -
2617
+ * @param {PlatformCartCheckoutDetailRequest} arg.body
2618
+ * @returns {Promise<CartCheckoutResponse>} - Success response
2619
+ * @summary: Checkout all items in the cart
2620
+ * @description: Use this API to checkout all items in the cart for payment and order generation. For COD, order will be generated directly, whereas for other checkout modes, user will be redirected to a payment gateway.
2621
+ */
2622
+ async platformCheckoutCart({ body, id } = {}) {
2623
+ const { error } = CartValidator.platformCheckoutCart().validate(
2624
+ {
2625
+ body,
2626
+ id,
2627
+ },
2628
+ { abortEarly: false, allowUnknown: true }
2629
+ );
2630
+ if (error) {
2631
+ return Promise.reject(new FDKClientValidationError(error));
2632
+ }
2633
+
2634
+ // Showing warrnings if extra unknown parameters are found
2635
+ const { error: warrning } = CartValidator.platformCheckoutCart().validate(
2636
+ {
2637
+ body,
2638
+ id,
2639
+ },
2640
+ { abortEarly: false, allowUnknown: false }
2641
+ );
2642
+ if (warrning) {
2643
+ Logger({
2644
+ level: "WARN",
2645
+ message: "Parameter Validation warrnings for platformCheckoutCart",
2646
+ });
2647
+ Logger({ level: "WARN", message: warrning });
2648
+ }
2649
+
2650
+ const query_params = {};
2651
+ query_params["id"] = id;
2652
+
2653
+ const response = await PlatformAPIClient.execute(
2654
+ this.config,
2655
+ "post",
2656
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/checkout`,
2657
+ query_params,
2658
+ body
2659
+ );
2660
+
2661
+ const {
2662
+ error: res_error,
2663
+ } = CartModel.CartCheckoutResponse().validate(response, {
2664
+ abortEarly: false,
2665
+ allowUnknown: false,
2666
+ });
2667
+
2668
+ if (res_error) {
2669
+ Logger({
2670
+ level: "WARN",
2671
+ message: "Response Validation Warnnings for platformCheckoutCart",
2672
+ });
2673
+ Logger({ level: "WARN", message: res_error });
2674
+ }
2675
+
2676
+ return response;
2677
+ }
2678
+
2679
+ /**
2680
+ * @param {Object} arg - Arg object.
2681
+ * @param {string} [arg.id] -
2682
+ * @param {PlatformCartCheckoutDetailV2Request} arg.body
2683
+ * @returns {Promise<CartCheckoutResponse>} - Success response
2684
+ * @summary: Checkout all items in the cart
2685
+ * @description: Use this API to checkout all items in the cart for payment and order generation. For COD, order will be directly generated, whereas for other checkout modes, user will be redirected to a payment gateway.
2686
+ */
2687
+ async platformCheckoutCartV2({ body, id } = {}) {
2688
+ const { error } = CartValidator.platformCheckoutCartV2().validate(
2689
+ {
2690
+ body,
2691
+ id,
2692
+ },
2693
+ { abortEarly: false, allowUnknown: true }
2694
+ );
2695
+ if (error) {
2696
+ return Promise.reject(new FDKClientValidationError(error));
2697
+ }
2698
+
2699
+ // Showing warrnings if extra unknown parameters are found
2700
+ const { error: warrning } = CartValidator.platformCheckoutCartV2().validate(
2701
+ {
2702
+ body,
2703
+ id,
2704
+ },
2705
+ { abortEarly: false, allowUnknown: false }
2706
+ );
2707
+ if (warrning) {
2708
+ Logger({
2709
+ level: "WARN",
2710
+ message: "Parameter Validation warrnings for platformCheckoutCartV2",
2711
+ });
2712
+ Logger({ level: "WARN", message: warrning });
2713
+ }
2714
+
2715
+ const query_params = {};
2716
+ query_params["id"] = id;
2717
+
2718
+ const response = await PlatformAPIClient.execute(
2719
+ this.config,
2720
+ "post",
2721
+ `/service/platform/cart/v2.0/company/${this.config.companyId}/application/${this.applicationId}/checkout`,
2722
+ query_params,
2723
+ body
2724
+ );
2725
+
2726
+ const {
2727
+ error: res_error,
2728
+ } = CartModel.CartCheckoutResponse().validate(response, {
2729
+ abortEarly: false,
2730
+ allowUnknown: false,
2731
+ });
2732
+
2733
+ if (res_error) {
2734
+ Logger({
2735
+ level: "WARN",
2736
+ message: "Response Validation Warnnings for platformCheckoutCartV2",
2737
+ });
2738
+ Logger({ level: "WARN", message: res_error });
2739
+ }
2740
+
2741
+ return response;
2742
+ }
2743
+
2744
+ /**
2745
+ * @param {Object} arg - Arg object.
2746
+ * @param {string} [arg.id] -
2747
+ * @param {boolean} [arg.i] -
2748
+ * @param {boolean} [arg.b] -
2749
+ * @param {boolean} [arg.buyNow] -
2750
+ * @param {PlatformUpdateCartRequest} arg.body
2751
+ * @returns {Promise<UpdateCartDetailResponse>} - Success response
2752
+ * @summary: Update items in the customer 's cart using cart id
2753
+ * @description: <p>Use this API to update items added to the cart with the help of a request object containing attributes like item_quantity and item_size. These attributes will be fetched from the following APIs</p> <ul> <li><font color="monochrome">operation</font> Operation for current api call. <b>update_item</b> for update items. <b>remove_item</b> for removing items.</li> <li> <font color="monochrome">item_id</font> "/platform/content/v1/products/"</li> <li> <font color="monochrome">item_size</font> "/platform/content/v1/products/:slug/sizes/"</li> <li> <font color="monochrome">quantity</font> item quantity (must be greater than or equal to 1)</li> <li> <font color="monochrome">article_id</font> "/content​/v1​/products​/:identifier​/sizes​/price​/"</li> <li> <font color="monochrome">item_index</font> item position in the cart (must be greater than or equal to 0)</li> </ul>
2754
+ */
2755
+ async platformUpdateCart({ body, id, i, b, buyNow } = {}) {
2756
+ const { error } = CartValidator.platformUpdateCart().validate(
2757
+ {
2758
+ body,
2759
+ id,
2760
+ i,
2761
+ b,
2762
+ buyNow,
2763
+ },
2764
+ { abortEarly: false, allowUnknown: true }
2765
+ );
2766
+ if (error) {
2767
+ return Promise.reject(new FDKClientValidationError(error));
2768
+ }
2769
+
2770
+ // Showing warrnings if extra unknown parameters are found
2771
+ const { error: warrning } = CartValidator.platformUpdateCart().validate(
2772
+ {
2773
+ body,
2774
+ id,
2775
+ i,
2776
+ b,
2777
+ buyNow,
2778
+ },
2779
+ { abortEarly: false, allowUnknown: false }
2780
+ );
2781
+ if (warrning) {
2782
+ Logger({
2783
+ level: "WARN",
2784
+ message: "Parameter Validation warrnings for platformUpdateCart",
2785
+ });
2786
+ Logger({ level: "WARN", message: warrning });
2787
+ }
2788
+
2789
+ const query_params = {};
2790
+ query_params["id"] = id;
2791
+ query_params["i"] = i;
2792
+ query_params["b"] = b;
2793
+ query_params["buy_now"] = buyNow;
2794
+
2795
+ const response = await PlatformAPIClient.execute(
2796
+ this.config,
2797
+ "put",
2798
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/detail`,
2799
+ query_params,
2800
+ body
2801
+ );
2802
+
2803
+ const {
2804
+ error: res_error,
2805
+ } = CartModel.UpdateCartDetailResponse().validate(response, {
2806
+ abortEarly: false,
2807
+ allowUnknown: false,
2808
+ });
2809
+
2810
+ if (res_error) {
2811
+ Logger({
2812
+ level: "WARN",
2813
+ message: "Response Validation Warnnings for platformUpdateCart",
2814
+ });
2815
+ Logger({ level: "WARN", message: res_error });
2816
+ }
2817
+
2818
+ return response;
2819
+ }
2820
+
2821
+ /**
2822
+ * @param {Object} arg - Arg object.
2823
+ * @param {string} arg.id - ID allotted to the selected address
2824
+ * @param {string} [arg.userId] - Option to delete address for the provided user_id.
2825
+ * @returns {Promise<DeleteAddressResponse>} - Success response
2826
+ * @summary: Remove address associated with an account
2827
+ * @description: Use this API to delete an address by its ID. This will returns an object that will indicate whether the address was deleted successfully or not.
2828
+ */
2829
+ async removeAddress({ id, userId } = {}) {
2830
+ const { error } = CartValidator.removeAddress().validate(
2831
+ {
2832
+ id,
2833
+ userId,
2834
+ },
2835
+ { abortEarly: false, allowUnknown: true }
2836
+ );
2837
+ if (error) {
2838
+ return Promise.reject(new FDKClientValidationError(error));
2839
+ }
2840
+
2841
+ // Showing warrnings if extra unknown parameters are found
2842
+ const { error: warrning } = CartValidator.removeAddress().validate(
2843
+ {
2844
+ id,
2845
+ userId,
2846
+ },
2847
+ { abortEarly: false, allowUnknown: false }
2848
+ );
2849
+ if (warrning) {
2850
+ Logger({
2851
+ level: "WARN",
2852
+ message: "Parameter Validation warrnings for removeAddress",
2853
+ });
2854
+ Logger({ level: "WARN", message: warrning });
2855
+ }
2856
+
2857
+ const query_params = {};
2858
+ query_params["user_id"] = userId;
2859
+
2860
+ const response = await PlatformAPIClient.execute(
2861
+ this.config,
2862
+ "delete",
2863
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/address/${id}`,
2864
+ query_params,
2865
+ undefined
2866
+ );
2867
+
2868
+ const {
2869
+ error: res_error,
2870
+ } = CartModel.DeleteAddressResponse().validate(response, {
2871
+ abortEarly: false,
2872
+ allowUnknown: false,
2873
+ });
2874
+
2875
+ if (res_error) {
2876
+ Logger({
2877
+ level: "WARN",
2878
+ message: "Response Validation Warnnings for removeAddress",
2879
+ });
2880
+ Logger({ level: "WARN", message: res_error });
2881
+ }
2882
+
2883
+ return response;
2884
+ }
2885
+
2886
+ /**
2887
+ * @param {Object} arg - Arg object.
2888
+ * @param {string} [arg.uid] -
2889
+ * @param {boolean} [arg.buyNow] -
2890
+ * @returns {Promise<CartDetailResponse>} - Success response
2891
+ * @summary: Remove Applied Coupon for platform pos user
2892
+ * @description: Remove Coupon applied on the cart by passing uid in request body.
2893
+ */
2894
+ async removeCoupon({ uid, buyNow } = {}) {
2895
+ const { error } = CartValidator.removeCoupon().validate(
2896
+ {
2897
+ uid,
2898
+ buyNow,
2899
+ },
2900
+ { abortEarly: false, allowUnknown: true }
2901
+ );
2902
+ if (error) {
2903
+ return Promise.reject(new FDKClientValidationError(error));
2904
+ }
2905
+
2906
+ // Showing warrnings if extra unknown parameters are found
2907
+ const { error: warrning } = CartValidator.removeCoupon().validate(
2908
+ {
2909
+ uid,
2910
+ buyNow,
2911
+ },
2912
+ { abortEarly: false, allowUnknown: false }
2913
+ );
2914
+ if (warrning) {
2915
+ Logger({
2916
+ level: "WARN",
2917
+ message: "Parameter Validation warrnings for removeCoupon",
2918
+ });
2919
+ Logger({ level: "WARN", message: warrning });
2920
+ }
2921
+
2922
+ const query_params = {};
2923
+ query_params["uid"] = uid;
2924
+ query_params["buy_now"] = buyNow;
2925
+
2926
+ const response = await PlatformAPIClient.execute(
2927
+ this.config,
2928
+ "delete",
2929
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/platform-pos-coupon`,
2930
+ query_params,
2931
+ undefined
2932
+ );
2933
+
2934
+ const {
2935
+ error: res_error,
2936
+ } = CartModel.CartDetailResponse().validate(response, {
2937
+ abortEarly: false,
2938
+ allowUnknown: false,
2939
+ });
2940
+
2941
+ if (res_error) {
2942
+ Logger({
2943
+ level: "WARN",
2944
+ message: "Response Validation Warnnings for removeCoupon",
2945
+ });
2946
+ Logger({ level: "WARN", message: res_error });
2947
+ }
2948
+
2949
+ return response;
2950
+ }
2951
+
2952
+ /**
2953
+ * @param {Object} arg - Arg object.
2954
+ * @param {string} arg.id -
2955
+ * @returns {Promise<SuccessMessage>} - Success response
2956
+ * @summary: Remove price adjustment
2957
+ * @description: Remove price adjustment
2958
+ */
2959
+ async removePriceAdjustment({ id } = {}) {
2960
+ const { error } = CartValidator.removePriceAdjustment().validate(
2961
+ {
2962
+ id,
2963
+ },
2964
+ { abortEarly: false, allowUnknown: true }
2965
+ );
2966
+ if (error) {
2967
+ return Promise.reject(new FDKClientValidationError(error));
2968
+ }
2969
+
2970
+ // Showing warrnings if extra unknown parameters are found
2971
+ const { error: warrning } = CartValidator.removePriceAdjustment().validate(
2972
+ {
2973
+ id,
2974
+ },
2975
+ { abortEarly: false, allowUnknown: false }
2976
+ );
2977
+ if (warrning) {
2978
+ Logger({
2979
+ level: "WARN",
2980
+ message: "Parameter Validation warrnings for removePriceAdjustment",
2981
+ });
2982
+ Logger({ level: "WARN", message: warrning });
2983
+ }
2984
+
2985
+ const query_params = {};
2986
+
2987
+ const response = await PlatformAPIClient.execute(
2988
+ this.config,
2989
+ "delete",
2990
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/price-adjustment/${id}`,
2991
+ query_params,
2992
+ undefined
2993
+ );
2994
+
2995
+ const { error: res_error } = CartModel.SuccessMessage().validate(response, {
2996
+ abortEarly: false,
2997
+ allowUnknown: false,
2998
+ });
2999
+
3000
+ if (res_error) {
3001
+ Logger({
3002
+ level: "WARN",
3003
+ message: "Response Validation Warnnings for removePriceAdjustment",
3004
+ });
3005
+ Logger({ level: "WARN", message: res_error });
3006
+ }
3007
+
3008
+ return response;
3009
+ }
3010
+
3011
+ /**
3012
+ * @param {Object} arg - Arg object.
3013
+ * @param {string} [arg.cartId] -
3014
+ * @param {boolean} [arg.buyNow] -
3015
+ * @param {boolean} [arg.i] -
3016
+ * @param {boolean} [arg.b] -
3017
+ * @param {PlatformSelectCartAddressRequest} arg.body
3018
+ * @returns {Promise<CartDetailResponse>} - Success response
3019
+ * @summary: Select an address from available addresses
3020
+ * @description: <p>Select Address from all addresses associated with the account in order to ship the cart items to that address, otherwise default address will be selected implicitly. See `PlatformSelectCartAddressRequest` in schema of request body for the list of attributes needed to select Address from account. On successful request, this API returns a Cart object. Below address attributes are required. <ul> <li> <font color="monochrome">address_id</font></li> <li> <font color="monochrome">billing_address_id</font></li> <li> <font color="monochrome">uid</font></li> </ul></p>
3021
+ */
3022
+ async selectAddress({ body, cartId, buyNow, i, b } = {}) {
3023
+ const { error } = CartValidator.selectAddress().validate(
3024
+ {
3025
+ body,
3026
+ cartId,
3027
+ buyNow,
3028
+ i,
3029
+ b,
3030
+ },
3031
+ { abortEarly: false, allowUnknown: true }
3032
+ );
3033
+ if (error) {
3034
+ return Promise.reject(new FDKClientValidationError(error));
3035
+ }
3036
+
3037
+ // Showing warrnings if extra unknown parameters are found
3038
+ const { error: warrning } = CartValidator.selectAddress().validate(
3039
+ {
3040
+ body,
3041
+ cartId,
3042
+ buyNow,
3043
+ i,
3044
+ b,
3045
+ },
3046
+ { abortEarly: false, allowUnknown: false }
3047
+ );
3048
+ if (warrning) {
3049
+ Logger({
3050
+ level: "WARN",
3051
+ message: "Parameter Validation warrnings for selectAddress",
3052
+ });
3053
+ Logger({ level: "WARN", message: warrning });
3054
+ }
3055
+
3056
+ const query_params = {};
3057
+ query_params["cart_id"] = cartId;
3058
+ query_params["buy_now"] = buyNow;
3059
+ query_params["i"] = i;
3060
+ query_params["b"] = b;
3061
+
3062
+ const response = await PlatformAPIClient.execute(
3063
+ this.config,
3064
+ "post",
3065
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/select-address`,
3066
+ query_params,
3067
+ body
3068
+ );
3069
+
3070
+ const {
3071
+ error: res_error,
3072
+ } = CartModel.CartDetailResponse().validate(response, {
3073
+ abortEarly: false,
3074
+ allowUnknown: false,
3075
+ });
3076
+
3077
+ if (res_error) {
3078
+ Logger({
3079
+ level: "WARN",
3080
+ message: "Response Validation Warnnings for selectAddress",
3081
+ });
3082
+ Logger({ level: "WARN", message: res_error });
3083
+ }
3084
+
3085
+ return response;
3086
+ }
3087
+
3088
+ /**
3089
+ * @param {Object} arg - Arg object.
3090
+ * @param {string} [arg.id] -
3091
+ * @param {boolean} [arg.buyNow] -
3092
+ * @param {string} [arg.orderType] - The order type of shipment HomeDelivery
3093
+ * - If the customer wants the order home-delivered PickAtStore - If the
3094
+ * customer wants the handover of an order at the store itself.
3095
+ * @param {UpdateCartPaymentRequest} arg.body
3096
+ * @returns {Promise<CartDetailResponse>} - Success response
3097
+ * @summary: Update cart payment
3098
+ * @description: Use this API to update cart payment.
3099
+ */
3100
+ async selectPaymentMode({ body, id, buyNow, orderType } = {}) {
3101
+ const { error } = CartValidator.selectPaymentMode().validate(
3102
+ {
3103
+ body,
3104
+ id,
3105
+ buyNow,
3106
+ orderType,
3107
+ },
3108
+ { abortEarly: false, allowUnknown: true }
3109
+ );
3110
+ if (error) {
3111
+ return Promise.reject(new FDKClientValidationError(error));
3112
+ }
3113
+
3114
+ // Showing warrnings if extra unknown parameters are found
3115
+ const { error: warrning } = CartValidator.selectPaymentMode().validate(
3116
+ {
3117
+ body,
3118
+ id,
3119
+ buyNow,
3120
+ orderType,
3121
+ },
3122
+ { abortEarly: false, allowUnknown: false }
3123
+ );
3124
+ if (warrning) {
3125
+ Logger({
3126
+ level: "WARN",
3127
+ message: "Parameter Validation warrnings for selectPaymentMode",
3128
+ });
3129
+ Logger({ level: "WARN", message: warrning });
3130
+ }
3131
+
3132
+ const query_params = {};
3133
+ query_params["id"] = id;
3134
+ query_params["buy_now"] = buyNow;
3135
+ query_params["order_type"] = orderType;
3136
+
3137
+ const response = await PlatformAPIClient.execute(
3138
+ this.config,
3139
+ "put",
3140
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/payment`,
3141
+ query_params,
3142
+ body
3143
+ );
3144
+
3145
+ const {
3146
+ error: res_error,
3147
+ } = CartModel.CartDetailResponse().validate(response, {
3148
+ abortEarly: false,
3149
+ allowUnknown: false,
3150
+ });
3151
+
3152
+ if (res_error) {
3153
+ Logger({
3154
+ level: "WARN",
3155
+ message: "Response Validation Warnnings for selectPaymentMode",
3156
+ });
3157
+ Logger({ level: "WARN", message: res_error });
3158
+ }
3159
+
3160
+ return response;
3161
+ }
3162
+
3163
+ /**
3164
+ * @param {Object} arg - Arg object.
3165
+ * @param {string} [arg.id] -
3166
+ * @param {boolean} [arg.buyNow] -
3167
+ * @param {string} [arg.orderType] - The order type of shipment HomeDelivery
3168
+ * - If the customer wants the order home-delivered PickAtStore - If the
3169
+ * customer wants the handover of an order at the store itself.
3170
+ * @param {UpdateCartPaymentRequestV2} arg.body
3171
+ * @returns {Promise<CartDetailResponse>} - Success response
3172
+ * @summary: Update cart payment
3173
+ * @description: Use this API to update cart payment.
3174
+ */
3175
+ async selectPaymentModeV2({ body, id, buyNow, orderType } = {}) {
3176
+ const { error } = CartValidator.selectPaymentModeV2().validate(
3177
+ {
3178
+ body,
3179
+ id,
3180
+ buyNow,
3181
+ orderType,
3182
+ },
3183
+ { abortEarly: false, allowUnknown: true }
3184
+ );
3185
+ if (error) {
3186
+ return Promise.reject(new FDKClientValidationError(error));
3187
+ }
3188
+
3189
+ // Showing warrnings if extra unknown parameters are found
3190
+ const { error: warrning } = CartValidator.selectPaymentModeV2().validate(
3191
+ {
3192
+ body,
3193
+ id,
3194
+ buyNow,
3195
+ orderType,
3196
+ },
3197
+ { abortEarly: false, allowUnknown: false }
3198
+ );
3199
+ if (warrning) {
3200
+ Logger({
3201
+ level: "WARN",
3202
+ message: "Parameter Validation warrnings for selectPaymentModeV2",
3203
+ });
3204
+ Logger({ level: "WARN", message: warrning });
3205
+ }
3206
+
3207
+ const query_params = {};
3208
+ query_params["id"] = id;
3209
+ query_params["buy_now"] = buyNow;
3210
+ query_params["order_type"] = orderType;
3211
+
3212
+ const response = await PlatformAPIClient.execute(
3213
+ this.config,
3214
+ "put",
3215
+ `/service/platform/cart/v2.0/company/${this.config.companyId}/application/${this.applicationId}/payment`,
3216
+ query_params,
3217
+ body
3218
+ );
3219
+
3220
+ const {
3221
+ error: res_error,
3222
+ } = CartModel.CartDetailResponse().validate(response, {
3223
+ abortEarly: false,
3224
+ allowUnknown: false,
3225
+ });
3226
+
3227
+ if (res_error) {
3228
+ Logger({
3229
+ level: "WARN",
3230
+ message: "Response Validation Warnnings for selectPaymentModeV2",
3231
+ });
3232
+ Logger({ level: "WARN", message: res_error });
3233
+ }
3234
+
3235
+ return response;
3236
+ }
3237
+
3238
+ /**
3239
+ * @param {Object} arg - Arg object.
3240
+ * @param {string} arg.id - ID allotted to the selected address
3241
+ * @param {PlatformAddress} arg.body
3242
+ * @returns {Promise<UpdateAddressResponse>} - Success response
3243
+ * @summary: Update address added to an account
3244
+ * @description: <p>Use this API to update an existing address in the account. Request object should contain attributes mentioned in <font color="blue">Address </font> can be updated. These attributes are:</p> <ul> <li> <font color="monochrome">is_default_address</font></li> <li> <font color="monochrome">landmark</font></li> <li> <font color="monochrome">area</font></li> <li> <font color="monochrome">pincode</font></li> <li> <font color="monochrome">email</font></li> <li> <font color="monochrome">address_type</font></li> <li> <font color="monochrome">name</font></li> <li> <font color="monochrome">address_id</font></li> <li> <font color="monochrome">address</font></li> </ul>
3245
+ */
3246
+ async updateAddress({ id, body } = {}) {
3247
+ const { error } = CartValidator.updateAddress().validate(
3248
+ {
3249
+ id,
3250
+ body,
3251
+ },
3252
+ { abortEarly: false, allowUnknown: true }
3253
+ );
3254
+ if (error) {
3255
+ return Promise.reject(new FDKClientValidationError(error));
3256
+ }
3257
+
3258
+ // Showing warrnings if extra unknown parameters are found
3259
+ const { error: warrning } = CartValidator.updateAddress().validate(
3260
+ {
3261
+ id,
3262
+ body,
3263
+ },
3264
+ { abortEarly: false, allowUnknown: false }
3265
+ );
3266
+ if (warrning) {
3267
+ Logger({
3268
+ level: "WARN",
3269
+ message: "Parameter Validation warrnings for updateAddress",
3270
+ });
3271
+ Logger({ level: "WARN", message: warrning });
3272
+ }
3273
+
3274
+ const query_params = {};
3275
+
3276
+ const response = await PlatformAPIClient.execute(
3277
+ this.config,
3278
+ "put",
3279
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/address/${id}`,
3280
+ query_params,
3281
+ body
3282
+ );
3283
+
3284
+ const {
3285
+ error: res_error,
3286
+ } = CartModel.UpdateAddressResponse().validate(response, {
3287
+ abortEarly: false,
3288
+ allowUnknown: false,
3289
+ });
3290
+
3291
+ if (res_error) {
3292
+ Logger({
3293
+ level: "WARN",
3294
+ message: "Response Validation Warnnings for updateAddress",
3295
+ });
3296
+ Logger({ level: "WARN", message: res_error });
3297
+ }
3298
+
3299
+ return response;
3300
+ }
3301
+
3302
+ /**
3303
+ * @param {Object} arg - Arg object.
3304
+ * @param {string} arg.cartId - Current Cart _id
3305
+ * @param {boolean} [arg.b] -
3306
+ * @param {UpdateCartRequest} arg.body
3307
+ * @returns {Promise<UpdateCartDetailResponse>} - Success response
3308
+ * @summary: Update items in the abandoned cart
3309
+ * @description: <p>Use this API to update items added to the cart with the help of a request object containing attributes like item_quantity and item_size. These attributes will be fetched from the following APIs</p> <ul> <li><font color="monochrome">operation</font> Operation for current api call. <b>update_item</b> for update items. <b>remove_item</b> for removing items.</li> <li> <font color="monochrome">item_id</font> "/platform/content/v1/products/"</li> <li> <font color="monochrome">item_size</font> "/platform/content/v1/products/:slug/sizes/"</li> <li> <font color="monochrome">quantity</font> item quantity (must be greater than or equal to 1)</li> <li> <font color="monochrome">article_id</font> "/content​/v1​/products​/:identifier​/sizes​/price​/"</li> <li> <font color="monochrome">item_index</font> item position in the cart (must be greater than or equal to 0)</li> </ul>
3310
+ */
3311
+ async updateCart({ cartId, body, b } = {}) {
3312
+ const { error } = CartValidator.updateCart().validate(
3313
+ {
3314
+ cartId,
3315
+ body,
3316
+ b,
3317
+ },
3318
+ { abortEarly: false, allowUnknown: true }
3319
+ );
3320
+ if (error) {
3321
+ return Promise.reject(new FDKClientValidationError(error));
3322
+ }
3323
+
3324
+ // Showing warrnings if extra unknown parameters are found
3325
+ const { error: warrning } = CartValidator.updateCart().validate(
3326
+ {
3327
+ cartId,
3328
+ body,
3329
+ b,
3330
+ },
3331
+ { abortEarly: false, allowUnknown: false }
3332
+ );
3333
+ if (warrning) {
3334
+ Logger({
3335
+ level: "WARN",
3336
+ message: "Parameter Validation warrnings for updateCart",
3337
+ });
3338
+ Logger({ level: "WARN", message: warrning });
3339
+ }
3340
+
3341
+ const query_params = {};
3342
+ query_params["b"] = b;
3343
+
3344
+ const response = await PlatformAPIClient.execute(
3345
+ this.config,
3346
+ "put",
3347
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/abandoned/carts/${cartId}`,
3348
+ query_params,
3349
+ body
3350
+ );
3351
+
3352
+ const {
3353
+ error: res_error,
3354
+ } = CartModel.UpdateCartDetailResponse().validate(response, {
3355
+ abortEarly: false,
3356
+ allowUnknown: false,
3357
+ });
3358
+
3359
+ if (res_error) {
3360
+ Logger({
3361
+ level: "WARN",
3362
+ message: "Response Validation Warnnings for updateCart",
3363
+ });
3364
+ Logger({ level: "WARN", message: res_error });
3365
+ }
3366
+
3367
+ return response;
3368
+ }
3369
+
3370
+ /**
3371
+ * @param {Object} arg - Arg object.
3372
+ * @param {string} [arg.id] -
3373
+ * @param {boolean} [arg.buyNow] -
3374
+ * @param {PlatformCartMetaRequest} arg.body
3375
+ * @returns {Promise<CartMetaResponse>} - Success response
3376
+ * @summary: Update the cart meta for platform pos user
3377
+ * @description: Use this API to update cart meta like checkout_mode and gstin.
3378
+ */
3379
+ async updateCartMeta({ body, id, buyNow } = {}) {
3380
+ const { error } = CartValidator.updateCartMeta().validate(
3381
+ {
3382
+ body,
3383
+ id,
3384
+ buyNow,
3385
+ },
3386
+ { abortEarly: false, allowUnknown: true }
3387
+ );
3388
+ if (error) {
3389
+ return Promise.reject(new FDKClientValidationError(error));
3390
+ }
3391
+
3392
+ // Showing warrnings if extra unknown parameters are found
3393
+ const { error: warrning } = CartValidator.updateCartMeta().validate(
3394
+ {
3395
+ body,
3396
+ id,
3397
+ buyNow,
3398
+ },
3399
+ { abortEarly: false, allowUnknown: false }
3400
+ );
3401
+ if (warrning) {
3402
+ Logger({
3403
+ level: "WARN",
3404
+ message: "Parameter Validation warrnings for updateCartMeta",
3405
+ });
3406
+ Logger({ level: "WARN", message: warrning });
3407
+ }
3408
+
3409
+ const query_params = {};
3410
+ query_params["id"] = id;
3411
+ query_params["buy_now"] = buyNow;
3412
+
3413
+ const response = await PlatformAPIClient.execute(
3414
+ this.config,
3415
+ "put",
3416
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/meta`,
3417
+ query_params,
3418
+ body
3419
+ );
3420
+
3421
+ const { error: res_error } = CartModel.CartMetaResponse().validate(
3422
+ response,
3423
+ { abortEarly: false, allowUnknown: false }
3424
+ );
3425
+
3426
+ if (res_error) {
3427
+ Logger({
3428
+ level: "WARN",
3429
+ message: "Response Validation Warnnings for updateCartMeta",
1371
3430
  });
1372
- return data;
1373
- };
1374
- paginator.setCallback(callback.bind(this));
1375
- return paginator;
3431
+ Logger({ level: "WARN", message: res_error });
3432
+ }
3433
+
3434
+ return response;
1376
3435
  }
1377
3436
 
1378
3437
  /**
1379
3438
  * @param {Object} arg - Arg object.
1380
- * @param {OverrideCheckoutReq} arg.body
1381
- * @returns {Promise<OverrideCheckoutResponse>} - Success response
1382
- * @summary: Create Fynd order with overriding cart details
1383
- * @description: Generate Fynd order while overriding cart details sent with provided `cart_items`
3439
+ * @param {string} arg.cartMetaId -
3440
+ * @param {CartMetaConfigUpdate} arg.body
3441
+ * @returns {Promise<CartMetaConfigUpdate>} - Success response
3442
+ * @summary: Update cart meta configuration
3443
+ * @description: Update cart meta configuration
1384
3444
  */
1385
- async overrideCart({ body } = {}) {
1386
- const { error } = CartValidator.overrideCart().validate(
3445
+ async updateCartMetaConfig({ cartMetaId, body } = {}) {
3446
+ const { error } = CartValidator.updateCartMetaConfig().validate(
1387
3447
  {
3448
+ cartMetaId,
1388
3449
  body,
1389
3450
  },
1390
3451
  { abortEarly: false, allowUnknown: true }
@@ -1394,8 +3455,9 @@ class Cart {
1394
3455
  }
1395
3456
 
1396
3457
  // Showing warrnings if extra unknown parameters are found
1397
- const { error: warrning } = CartValidator.overrideCart().validate(
3458
+ const { error: warrning } = CartValidator.updateCartMetaConfig().validate(
1398
3459
  {
3460
+ cartMetaId,
1399
3461
  body,
1400
3462
  },
1401
3463
  { abortEarly: false, allowUnknown: false }
@@ -1403,7 +3465,7 @@ class Cart {
1403
3465
  if (warrning) {
1404
3466
  Logger({
1405
3467
  level: "WARN",
1406
- message: "Parameter Validation warrnings for overrideCart",
3468
+ message: "Parameter Validation warrnings for updateCartMetaConfig",
1407
3469
  });
1408
3470
  Logger({ level: "WARN", message: warrning });
1409
3471
  }
@@ -1412,15 +3474,15 @@ class Cart {
1412
3474
 
1413
3475
  const response = await PlatformAPIClient.execute(
1414
3476
  this.config,
1415
- "post",
1416
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/checkout/over-ride`,
3477
+ "put",
3478
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/cart_configuration/${cartMetaId}`,
1417
3479
  query_params,
1418
3480
  body
1419
3481
  );
1420
3482
 
1421
3483
  const {
1422
3484
  error: res_error,
1423
- } = CartModel.OverrideCheckoutResponse().validate(response, {
3485
+ } = CartModel.CartMetaConfigUpdate().validate(response, {
1424
3486
  abortEarly: false,
1425
3487
  allowUnknown: false,
1426
3488
  });
@@ -1428,7 +3490,7 @@ class Cart {
1428
3490
  if (res_error) {
1429
3491
  Logger({
1430
3492
  level: "WARN",
1431
- message: "Response Validation Warnnings for overrideCart",
3493
+ message: "Response Validation Warnnings for updateCartMetaConfig",
1432
3494
  });
1433
3495
  Logger({ level: "WARN", message: res_error });
1434
3496
  }
@@ -1438,19 +3500,17 @@ class Cart {
1438
3500
 
1439
3501
  /**
1440
3502
  * @param {Object} arg - Arg object.
1441
- * @param {string} arg.cartId - Current Cart _id
1442
- * @param {boolean} [arg.b] -
1443
- * @param {UpdateCartRequest} arg.body
1444
- * @returns {Promise<UpdateCartDetailResponse>} - Success response
1445
- * @summary: Update items in the abandoned cart
1446
- * @description: <p>Use this API to update items added to the cart with the help of a request object containing attributes like item_quantity and item_size. These attributes will be fetched from the following APIs</p> <ul> <li><font color="monochrome">operation</font> Operation for current api call. <b>update_item</b> for update items. <b>remove_item</b> for removing items.</li> <li> <font color="monochrome">item_id</font> "/platform/content/v1/products/"</li> <li> <font color="monochrome">item_size</font> "/platform/content/v1/products/:slug/sizes/"</li> <li> <font color="monochrome">quantity</font> item quantity (must be greater than or equal to 1)</li> <li> <font color="monochrome">article_id</font> "/content​/v1​/products​/:identifier​/sizes​/price​/"</li> <li> <font color="monochrome">item_index</font> item position in the cart (must be greater than or equal to 0)</li> </ul>
3503
+ * @param {string} [arg.id] -
3504
+ * @param {UpdateUserCartMapping} arg.body
3505
+ * @returns {Promise<UserCartMappingResponse>} - Success response
3506
+ * @summary: Update user id for store os customer
3507
+ * @description: Update user id for store os customer after creating customer
1447
3508
  */
1448
- async updateCart({ cartId, body, b } = {}) {
1449
- const { error } = CartValidator.updateCart().validate(
3509
+ async updateCartUser({ body, id } = {}) {
3510
+ const { error } = CartValidator.updateCartUser().validate(
1450
3511
  {
1451
- cartId,
1452
3512
  body,
1453
- b,
3513
+ id,
1454
3514
  },
1455
3515
  { abortEarly: false, allowUnknown: true }
1456
3516
  );
@@ -1459,36 +3519,35 @@ class Cart {
1459
3519
  }
1460
3520
 
1461
3521
  // Showing warrnings if extra unknown parameters are found
1462
- const { error: warrning } = CartValidator.updateCart().validate(
3522
+ const { error: warrning } = CartValidator.updateCartUser().validate(
1463
3523
  {
1464
- cartId,
1465
3524
  body,
1466
- b,
3525
+ id,
1467
3526
  },
1468
3527
  { abortEarly: false, allowUnknown: false }
1469
3528
  );
1470
3529
  if (warrning) {
1471
3530
  Logger({
1472
3531
  level: "WARN",
1473
- message: "Parameter Validation warrnings for updateCart",
3532
+ message: "Parameter Validation warrnings for updateCartUser",
1474
3533
  });
1475
3534
  Logger({ level: "WARN", message: warrning });
1476
3535
  }
1477
3536
 
1478
3537
  const query_params = {};
1479
- query_params["b"] = b;
3538
+ query_params["id"] = id;
1480
3539
 
1481
3540
  const response = await PlatformAPIClient.execute(
1482
3541
  this.config,
1483
3542
  "put",
1484
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/abandoned/carts/${cartId}`,
3543
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/update-user`,
1485
3544
  query_params,
1486
3545
  body
1487
3546
  );
1488
3547
 
1489
3548
  const {
1490
3549
  error: res_error,
1491
- } = CartModel.UpdateCartDetailResponse().validate(response, {
3550
+ } = CartModel.UserCartMappingResponse().validate(response, {
1492
3551
  abortEarly: false,
1493
3552
  allowUnknown: false,
1494
3553
  });
@@ -1496,7 +3555,7 @@ class Cart {
1496
3555
  if (res_error) {
1497
3556
  Logger({
1498
3557
  level: "WARN",
1499
- message: "Response Validation Warnnings for updateCart",
3558
+ message: "Response Validation Warnnings for updateCartUser",
1500
3559
  });
1501
3560
  Logger({ level: "WARN", message: res_error });
1502
3561
  }
@@ -1506,17 +3565,20 @@ class Cart {
1506
3565
 
1507
3566
  /**
1508
3567
  * @param {Object} arg - Arg object.
1509
- * @param {string} arg.cartMetaId -
1510
- * @param {CartMetaConfigUpdate} arg.body
1511
- * @returns {Promise<CartMetaConfigUpdate>} - Success response
1512
- * @summary: Update cart meta configuration
1513
- * @description: Update cart meta configuration
3568
+ * @param {string} arg.token - Token of the shared short link
3569
+ * @param {string} arg.action - Operation to perform on the existing cart
3570
+ * merge or replace.
3571
+ * @param {string} [arg.cartId] -
3572
+ * @returns {Promise<SharedCartResponse>} - Success response
3573
+ * @summary: Merge or replace existing cart
3574
+ * @description: Use this API to merge the shared cart with existing cart, or replace the existing cart with the shared cart. The `action` parameter is used to indicate the operation Merge or Replace.
1514
3575
  */
1515
- async updateCartMetaConfig({ cartMetaId, body } = {}) {
1516
- const { error } = CartValidator.updateCartMetaConfig().validate(
3576
+ async updateCartWithSharedItems({ token, action, cartId } = {}) {
3577
+ const { error } = CartValidator.updateCartWithSharedItems().validate(
1517
3578
  {
1518
- cartMetaId,
1519
- body,
3579
+ token,
3580
+ action,
3581
+ cartId,
1520
3582
  },
1521
3583
  { abortEarly: false, allowUnknown: true }
1522
3584
  );
@@ -1525,34 +3587,38 @@ class Cart {
1525
3587
  }
1526
3588
 
1527
3589
  // Showing warrnings if extra unknown parameters are found
1528
- const { error: warrning } = CartValidator.updateCartMetaConfig().validate(
3590
+ const {
3591
+ error: warrning,
3592
+ } = CartValidator.updateCartWithSharedItems().validate(
1529
3593
  {
1530
- cartMetaId,
1531
- body,
3594
+ token,
3595
+ action,
3596
+ cartId,
1532
3597
  },
1533
3598
  { abortEarly: false, allowUnknown: false }
1534
3599
  );
1535
3600
  if (warrning) {
1536
3601
  Logger({
1537
3602
  level: "WARN",
1538
- message: "Parameter Validation warrnings for updateCartMetaConfig",
3603
+ message: "Parameter Validation warrnings for updateCartWithSharedItems",
1539
3604
  });
1540
3605
  Logger({ level: "WARN", message: warrning });
1541
3606
  }
1542
3607
 
1543
3608
  const query_params = {};
3609
+ query_params["cart_id"] = cartId;
1544
3610
 
1545
3611
  const response = await PlatformAPIClient.execute(
1546
3612
  this.config,
1547
- "put",
1548
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/cart_configuration/${cartMetaId}`,
3613
+ "post",
3614
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/share-cart/${token}/${action}`,
1549
3615
  query_params,
1550
- body
3616
+ undefined
1551
3617
  );
1552
3618
 
1553
3619
  const {
1554
3620
  error: res_error,
1555
- } = CartModel.CartMetaConfigUpdate().validate(response, {
3621
+ } = CartModel.SharedCartResponse().validate(response, {
1556
3622
  abortEarly: false,
1557
3623
  allowUnknown: false,
1558
3624
  });
@@ -1560,7 +3626,7 @@ class Cart {
1560
3626
  if (res_error) {
1561
3627
  Logger({
1562
3628
  level: "WARN",
1563
- message: "Response Validation Warnnings for updateCartMetaConfig",
3629
+ message: "Response Validation Warnnings for updateCartWithSharedItems",
1564
3630
  });
1565
3631
  Logger({ level: "WARN", message: res_error });
1566
3632
  }
@@ -1692,6 +3758,70 @@ class Cart {
1692
3758
  return response;
1693
3759
  }
1694
3760
 
3761
+ /**
3762
+ * @param {Object} arg - Arg object.
3763
+ * @param {string} arg.id -
3764
+ * @param {PriceAdjustmentUpdate} arg.body
3765
+ * @returns {Promise<PriceAdjustmentResponse>} - Success response
3766
+ * @summary: Update price adjustment configuration
3767
+ * @description: Update price adjustment configuration
3768
+ */
3769
+ async updatePriceAdjustment({ id, body } = {}) {
3770
+ const { error } = CartValidator.updatePriceAdjustment().validate(
3771
+ {
3772
+ id,
3773
+ body,
3774
+ },
3775
+ { abortEarly: false, allowUnknown: true }
3776
+ );
3777
+ if (error) {
3778
+ return Promise.reject(new FDKClientValidationError(error));
3779
+ }
3780
+
3781
+ // Showing warrnings if extra unknown parameters are found
3782
+ const { error: warrning } = CartValidator.updatePriceAdjustment().validate(
3783
+ {
3784
+ id,
3785
+ body,
3786
+ },
3787
+ { abortEarly: false, allowUnknown: false }
3788
+ );
3789
+ if (warrning) {
3790
+ Logger({
3791
+ level: "WARN",
3792
+ message: "Parameter Validation warrnings for updatePriceAdjustment",
3793
+ });
3794
+ Logger({ level: "WARN", message: warrning });
3795
+ }
3796
+
3797
+ const query_params = {};
3798
+
3799
+ const response = await PlatformAPIClient.execute(
3800
+ this.config,
3801
+ "put",
3802
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/price-adjustment/${id}`,
3803
+ query_params,
3804
+ body
3805
+ );
3806
+
3807
+ const {
3808
+ error: res_error,
3809
+ } = CartModel.PriceAdjustmentResponse().validate(response, {
3810
+ abortEarly: false,
3811
+ allowUnknown: false,
3812
+ });
3813
+
3814
+ if (res_error) {
3815
+ Logger({
3816
+ level: "WARN",
3817
+ message: "Response Validation Warnnings for updatePriceAdjustment",
3818
+ });
3819
+ Logger({ level: "WARN", message: res_error });
3820
+ }
3821
+
3822
+ return response;
3823
+ }
3824
+
1695
3825
  /**
1696
3826
  * @param {Object} arg - Arg object.
1697
3827
  * @param {string} arg.id -
@@ -1817,6 +3947,200 @@ class Cart {
1817
3947
 
1818
3948
  return response;
1819
3949
  }
3950
+
3951
+ /**
3952
+ * @param {Object} arg - Arg object.
3953
+ * @param {boolean} [arg.i] - This is a boolean value. Select `true` to
3954
+ * retrieve all the items added in the cart.
3955
+ * @param {boolean} [arg.p] - This is a boolean value. Select `true` for
3956
+ * getting a payment option in response.
3957
+ * @param {string} [arg.id] - The unique identifier of the cart
3958
+ * @param {string} [arg.addressId] - ID allotted to an address
3959
+ * @param {string} [arg.areaCode] - The PIN Code of the destination address,
3960
+ * e.g. 400059
3961
+ * @param {string} [arg.orderType] - The order type of shipment HomeDelivery
3962
+ * - If the customer wants the order home-delivered PickAtStore - If the
3963
+ * customer wants the handover of an order at the store itself.
3964
+ * @param {UpdateCartShipmentRequest} arg.body
3965
+ * @returns {Promise<PlatformCartShipmentsResponse>} - Success response
3966
+ * @summary: Update shipment delivery type and quantity before checkout
3967
+ * @description: Use this API to update the delivery type and quantity as per customer's preference for either store pick-up or home-delivery.
3968
+ */
3969
+ async updateShipments({
3970
+ body,
3971
+ i,
3972
+ p,
3973
+ id,
3974
+ addressId,
3975
+ areaCode,
3976
+ orderType,
3977
+ } = {}) {
3978
+ const { error } = CartValidator.updateShipments().validate(
3979
+ {
3980
+ body,
3981
+ i,
3982
+ p,
3983
+ id,
3984
+ addressId,
3985
+ areaCode,
3986
+ orderType,
3987
+ },
3988
+ { abortEarly: false, allowUnknown: true }
3989
+ );
3990
+ if (error) {
3991
+ return Promise.reject(new FDKClientValidationError(error));
3992
+ }
3993
+
3994
+ // Showing warrnings if extra unknown parameters are found
3995
+ const { error: warrning } = CartValidator.updateShipments().validate(
3996
+ {
3997
+ body,
3998
+ i,
3999
+ p,
4000
+ id,
4001
+ addressId,
4002
+ areaCode,
4003
+ orderType,
4004
+ },
4005
+ { abortEarly: false, allowUnknown: false }
4006
+ );
4007
+ if (warrning) {
4008
+ Logger({
4009
+ level: "WARN",
4010
+ message: "Parameter Validation warrnings for updateShipments",
4011
+ });
4012
+ Logger({ level: "WARN", message: warrning });
4013
+ }
4014
+
4015
+ const query_params = {};
4016
+ query_params["i"] = i;
4017
+ query_params["p"] = p;
4018
+ query_params["id"] = id;
4019
+ query_params["address_id"] = addressId;
4020
+ query_params["area_code"] = areaCode;
4021
+ query_params["order_type"] = orderType;
4022
+
4023
+ const response = await PlatformAPIClient.execute(
4024
+ this.config,
4025
+ "put",
4026
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/shipment`,
4027
+ query_params,
4028
+ body
4029
+ );
4030
+
4031
+ const {
4032
+ error: res_error,
4033
+ } = CartModel.PlatformCartShipmentsResponse().validate(response, {
4034
+ abortEarly: false,
4035
+ allowUnknown: false,
4036
+ });
4037
+
4038
+ if (res_error) {
4039
+ Logger({
4040
+ level: "WARN",
4041
+ message: "Response Validation Warnnings for updateShipments",
4042
+ });
4043
+ Logger({ level: "WARN", message: res_error });
4044
+ }
4045
+
4046
+ return response;
4047
+ }
4048
+
4049
+ /**
4050
+ * @param {Object} arg - Arg object.
4051
+ * @param {string} [arg.id] -
4052
+ * @param {boolean} [arg.buyNow] -
4053
+ * @param {string} [arg.addressId] -
4054
+ * @param {string} [arg.paymentMode] -
4055
+ * @param {string} [arg.paymentIdentifier] -
4056
+ * @param {string} [arg.aggregatorName] -
4057
+ * @param {string} [arg.merchantCode] -
4058
+ * @returns {Promise<PaymentCouponValidate>} - Success response
4059
+ * @summary: Verify the coupon eligibility against the payment mode
4060
+ * @description: Use this API to validate a coupon against the payment mode such as NetBanking, Wallet, UPI etc.
4061
+ */
4062
+ async validateCouponForPayment({
4063
+ id,
4064
+ buyNow,
4065
+ addressId,
4066
+ paymentMode,
4067
+ paymentIdentifier,
4068
+ aggregatorName,
4069
+ merchantCode,
4070
+ } = {}) {
4071
+ const { error } = CartValidator.validateCouponForPayment().validate(
4072
+ {
4073
+ id,
4074
+ buyNow,
4075
+ addressId,
4076
+ paymentMode,
4077
+ paymentIdentifier,
4078
+ aggregatorName,
4079
+ merchantCode,
4080
+ },
4081
+ { abortEarly: false, allowUnknown: true }
4082
+ );
4083
+ if (error) {
4084
+ return Promise.reject(new FDKClientValidationError(error));
4085
+ }
4086
+
4087
+ // Showing warrnings if extra unknown parameters are found
4088
+ const {
4089
+ error: warrning,
4090
+ } = CartValidator.validateCouponForPayment().validate(
4091
+ {
4092
+ id,
4093
+ buyNow,
4094
+ addressId,
4095
+ paymentMode,
4096
+ paymentIdentifier,
4097
+ aggregatorName,
4098
+ merchantCode,
4099
+ },
4100
+ { abortEarly: false, allowUnknown: false }
4101
+ );
4102
+ if (warrning) {
4103
+ Logger({
4104
+ level: "WARN",
4105
+ message: "Parameter Validation warrnings for validateCouponForPayment",
4106
+ });
4107
+ Logger({ level: "WARN", message: warrning });
4108
+ }
4109
+
4110
+ const query_params = {};
4111
+ query_params["id"] = id;
4112
+ query_params["buy_now"] = buyNow;
4113
+ query_params["address_id"] = addressId;
4114
+ query_params["payment_mode"] = paymentMode;
4115
+ query_params["payment_identifier"] = paymentIdentifier;
4116
+ query_params["aggregator_name"] = aggregatorName;
4117
+ query_params["merchant_code"] = merchantCode;
4118
+
4119
+ const response = await PlatformAPIClient.execute(
4120
+ this.config,
4121
+ "get",
4122
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/payment/validate/`,
4123
+ query_params,
4124
+ undefined
4125
+ );
4126
+
4127
+ const {
4128
+ error: res_error,
4129
+ } = CartModel.PaymentCouponValidate().validate(response, {
4130
+ abortEarly: false,
4131
+ allowUnknown: false,
4132
+ });
4133
+
4134
+ if (res_error) {
4135
+ Logger({
4136
+ level: "WARN",
4137
+ message: "Response Validation Warnnings for validateCouponForPayment",
4138
+ });
4139
+ Logger({ level: "WARN", message: res_error });
4140
+ }
4141
+
4142
+ return response;
4143
+ }
1820
4144
  }
1821
4145
 
1822
4146
  module.exports = Cart;