@gofynd/fdk-client-javascript 1.1.1 → 1.1.3

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