@gofynd/fdk-client-javascript 1.1.2 → 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 (117) 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 +36 -6
  8. package/sdk/application/Cart/CartApplicationClient.js +105 -10
  9. package/sdk/application/Cart/CartApplicationModel.d.ts +9 -0
  10. package/sdk/application/Cart/CartApplicationModel.js +105 -1
  11. package/sdk/application/Cart/CartApplicationValidator.d.ts +1 -0
  12. package/sdk/application/Cart/CartApplicationValidator.js +15 -1
  13. package/sdk/application/Catalog/CatalogApplicationModel.d.ts +1 -0
  14. package/sdk/application/Catalog/CatalogApplicationModel.js +13 -0
  15. package/sdk/application/Configuration/ConfigurationApplicationClient.d.ts +14 -10
  16. package/sdk/application/Configuration/ConfigurationApplicationClient.js +16 -10
  17. package/sdk/application/Configuration/ConfigurationApplicationModel.js +1 -0
  18. package/sdk/application/Configuration/ConfigurationApplicationValidator.js +1 -0
  19. package/sdk/application/Content/ContentApplicationModel.js +3 -1
  20. package/sdk/application/Logistic/LogisticApplicationModel.js +3 -2
  21. package/sdk/application/Order/OrderApplicationClient.d.ts +2 -2
  22. package/sdk/application/Order/OrderApplicationClient.js +2 -2
  23. package/sdk/application/Order/OrderApplicationModel.js +18 -8
  24. package/sdk/application/Payment/PaymentApplicationClient.d.ts +35 -0
  25. package/sdk/application/Payment/PaymentApplicationClient.js +200 -0
  26. package/sdk/application/Payment/PaymentApplicationModel.d.ts +4 -0
  27. package/sdk/application/Payment/PaymentApplicationModel.js +58 -7
  28. package/sdk/application/Payment/PaymentApplicationValidator.d.ts +3 -0
  29. package/sdk/application/Payment/PaymentApplicationValidator.js +19 -0
  30. package/sdk/application/PosCart/PosCartApplicationClient.d.ts +16 -3
  31. package/sdk/application/PosCart/PosCartApplicationClient.js +39 -6
  32. package/sdk/application/PosCart/PosCartApplicationModel.d.ts +6 -0
  33. package/sdk/application/PosCart/PosCartApplicationModel.js +63 -1
  34. package/sdk/application/PosCart/PosCartApplicationValidator.js +6 -0
  35. package/sdk/application/index.d.ts +10 -10
  36. package/sdk/application/index.js +13 -13
  37. package/sdk/common/Constant.d.ts +5 -0
  38. package/sdk/common/Constant.js +5 -0
  39. package/sdk/platform/Billing/BillingPlatformModel.js +6 -1
  40. package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +459 -2
  41. package/sdk/platform/Cart/CartPlatformApplicationClient.js +2480 -340
  42. package/sdk/platform/Cart/CartPlatformApplicationValidator.d.ts +29 -0
  43. package/sdk/platform/Cart/CartPlatformApplicationValidator.js +250 -0
  44. package/sdk/platform/Cart/CartPlatformModel.d.ts +52 -0
  45. package/sdk/platform/Cart/CartPlatformModel.js +580 -2
  46. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.d.ts +8 -2
  47. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.js +10 -0
  48. package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.js +1 -0
  49. package/sdk/platform/Catalog/CatalogPlatformClient.js +2 -2
  50. package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +1 -0
  51. package/sdk/platform/Catalog/CatalogPlatformModel.js +41 -29
  52. package/sdk/platform/Communication/CommunicationPlatformModel.d.ts +1 -0
  53. package/sdk/platform/Communication/CommunicationPlatformModel.js +9 -0
  54. package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.d.ts +2 -2
  55. package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.js +2 -2
  56. package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.js +5 -4
  57. package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.d.ts +99 -78
  58. package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.js +99 -78
  59. package/sdk/platform/Configuration/ConfigurationPlatformClient.d.ts +87 -71
  60. package/sdk/platform/Configuration/ConfigurationPlatformClient.js +87 -71
  61. package/sdk/platform/Configuration/ConfigurationPlatformModel.d.ts +2 -0
  62. package/sdk/platform/Configuration/ConfigurationPlatformModel.js +26 -0
  63. package/sdk/platform/Content/ContentPlatformModel.js +3 -1
  64. package/sdk/platform/Finance/FinancePlatformClient.d.ts +135 -0
  65. package/sdk/platform/Finance/FinancePlatformClient.js +853 -0
  66. package/sdk/platform/Finance/FinancePlatformModel.d.ts +51 -0
  67. package/sdk/platform/Finance/FinancePlatformModel.js +342 -0
  68. package/sdk/platform/Finance/FinancePlatformValidator.d.ts +16 -0
  69. package/sdk/platform/Finance/FinancePlatformValidator.js +84 -0
  70. package/sdk/platform/Order/OrderPlatformApplicationClient.d.ts +11 -1
  71. package/sdk/platform/Order/OrderPlatformApplicationClient.js +66 -2
  72. package/sdk/platform/Order/OrderPlatformApplicationValidator.d.ts +1 -0
  73. package/sdk/platform/Order/OrderPlatformApplicationValidator.js +6 -0
  74. package/sdk/platform/Order/OrderPlatformClient.d.ts +159 -79
  75. package/sdk/platform/Order/OrderPlatformClient.js +541 -114
  76. package/sdk/platform/Order/OrderPlatformModel.d.ts +42 -6
  77. package/sdk/platform/Order/OrderPlatformModel.js +569 -159
  78. package/sdk/platform/Order/OrderPlatformValidator.d.ts +6 -0
  79. package/sdk/platform/Order/OrderPlatformValidator.js +51 -9
  80. package/sdk/platform/Partner/PartnerPlatformApplicationClient.d.ts +22 -0
  81. package/sdk/platform/Partner/PartnerPlatformApplicationClient.js +127 -0
  82. package/sdk/platform/Partner/PartnerPlatformApplicationValidator.d.ts +2 -0
  83. package/sdk/platform/Partner/PartnerPlatformApplicationValidator.js +13 -0
  84. package/sdk/platform/Partner/PartnerPlatformClient.d.ts +145 -0
  85. package/sdk/platform/Partner/PartnerPlatformClient.js +799 -0
  86. package/sdk/platform/Partner/PartnerPlatformModel.d.ts +39 -0
  87. package/sdk/platform/Partner/PartnerPlatformModel.js +367 -0
  88. package/sdk/platform/Partner/PartnerPlatformValidator.d.ts +14 -0
  89. package/sdk/platform/Partner/PartnerPlatformValidator.js +87 -0
  90. package/sdk/platform/Payment/PaymentPlatformApplicationClient.d.ts +221 -0
  91. package/sdk/platform/Payment/PaymentPlatformApplicationClient.js +1476 -190
  92. package/sdk/platform/Payment/PaymentPlatformApplicationValidator.d.ts +20 -0
  93. package/sdk/platform/Payment/PaymentPlatformApplicationValidator.js +126 -0
  94. package/sdk/platform/Payment/PaymentPlatformModel.d.ts +44 -0
  95. package/sdk/platform/Payment/PaymentPlatformModel.js +410 -0
  96. package/sdk/platform/PlatformApplicationClient.d.ts +1149 -938
  97. package/sdk/platform/PlatformApplicationClient.js +1259 -1035
  98. package/sdk/platform/PlatformClient.d.ts +9888 -8286
  99. package/sdk/platform/PlatformClient.js +10960 -9038
  100. package/sdk/platform/index.d.ts +15 -14
  101. package/sdk/platform/index.js +20 -18
  102. package/sdk/public/PublicClient.d.ts +2 -2
  103. package/sdk/public/PublicClient.js +4 -4
  104. package/sdk/public/index.d.ts +1 -1
  105. package/sdk/public/index.js +2 -2
  106. package/partner.d.ts +0 -4
  107. package/partner.js +0 -7
  108. package/sdk/partner/OAuthClient.d.ts +0 -14
  109. package/sdk/partner/OAuthClient.js +0 -112
  110. package/sdk/partner/PartnerAPIClient.d.ts +0 -12
  111. package/sdk/partner/PartnerAPIClient.js +0 -42
  112. package/sdk/partner/PartnerClient.d.ts +0 -6
  113. package/sdk/partner/PartnerClient.js +0 -17
  114. package/sdk/partner/PartnerConfig.d.ts +0 -30
  115. package/sdk/partner/PartnerConfig.js +0 -39
  116. package/sdk/partner/index.d.ts +0 -3
  117. 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,69 +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.entityType] - Entity_type as coupon or promotion
1045
- * @param {boolean} [arg.isHidden] - Show Promo Coupon Config or not
1046
- * @returns {Promise<ActivePromosResponse>} - Success response
1047
- * @summary: Fetch all promos that are set as active
1048
- * @description: Use this API to get list of all the active promos/coupons.
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
1049
1341
  */
1050
- async getPromosCouponConfig({ entityType, isHidden } = {}) {
1051
- const { error } = CartValidator.getPromosCouponConfig().validate(
1342
+ async getCartList({ fromDate, toDate, filterOn } = {}) {
1343
+ const { error } = CartValidator.getCartList().validate(
1052
1344
  {
1053
- entityType,
1054
- isHidden,
1345
+ fromDate,
1346
+ toDate,
1347
+ filterOn,
1055
1348
  },
1056
1349
  { abortEarly: false, allowUnknown: true }
1057
1350
  );
@@ -1060,36 +1353,38 @@ class Cart {
1060
1353
  }
1061
1354
 
1062
1355
  // Showing warrnings if extra unknown parameters are found
1063
- const { error: warrning } = CartValidator.getPromosCouponConfig().validate(
1356
+ const { error: warrning } = CartValidator.getCartList().validate(
1064
1357
  {
1065
- entityType,
1066
- isHidden,
1358
+ fromDate,
1359
+ toDate,
1360
+ filterOn,
1067
1361
  },
1068
1362
  { abortEarly: false, allowUnknown: false }
1069
1363
  );
1070
1364
  if (warrning) {
1071
1365
  Logger({
1072
1366
  level: "WARN",
1073
- message: "Parameter Validation warrnings for getPromosCouponConfig",
1367
+ message: "Parameter Validation warrnings for getCartList",
1074
1368
  });
1075
1369
  Logger({ level: "WARN", message: warrning });
1076
1370
  }
1077
1371
 
1078
1372
  const query_params = {};
1079
- query_params["entity_type"] = entityType;
1080
- query_params["is_hidden"] = isHidden;
1373
+ query_params["from_date"] = fromDate;
1374
+ query_params["to_date"] = toDate;
1375
+ query_params["filter_on"] = filterOn;
1081
1376
 
1082
1377
  const response = await PlatformAPIClient.execute(
1083
1378
  this.config,
1084
1379
  "get",
1085
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promo-coupons`,
1380
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/cart-list`,
1086
1381
  query_params,
1087
1382
  undefined
1088
1383
  );
1089
1384
 
1090
1385
  const {
1091
1386
  error: res_error,
1092
- } = CartModel.ActivePromosResponse().validate(response, {
1387
+ } = CartModel.MultiCartResponse().validate(response, {
1093
1388
  abortEarly: false,
1094
1389
  allowUnknown: false,
1095
1390
  });
@@ -1097,7 +1392,7 @@ class Cart {
1097
1392
  if (res_error) {
1098
1393
  Logger({
1099
1394
  level: "WARN",
1100
- message: "Response Validation Warnnings for getPromosCouponConfig",
1395
+ message: "Response Validation Warnnings for getCartList",
1101
1396
  });
1102
1397
  Logger({ level: "WARN", message: res_error });
1103
1398
  }
@@ -1107,15 +1402,15 @@ class Cart {
1107
1402
 
1108
1403
  /**
1109
1404
  * @param {Object} arg - Arg object.
1110
- * @param {string} arg.id -
1111
- * @returns {Promise<PromotionUpdate>} - Success response
1112
- * @summary: Get with single promotion details or promotion list
1113
- * @description: Get single promotion details with `id` in path param
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.
1114
1409
  */
1115
- async getPromotionById({ id } = {}) {
1116
- const { error } = CartValidator.getPromotionById().validate(
1410
+ async getCartShareLink({ body } = {}) {
1411
+ const { error } = CartValidator.getCartShareLink().validate(
1117
1412
  {
1118
- id,
1413
+ body,
1119
1414
  },
1120
1415
  { abortEarly: false, allowUnknown: true }
1121
1416
  );
@@ -1124,16 +1419,16 @@ class Cart {
1124
1419
  }
1125
1420
 
1126
1421
  // Showing warrnings if extra unknown parameters are found
1127
- const { error: warrning } = CartValidator.getPromotionById().validate(
1422
+ const { error: warrning } = CartValidator.getCartShareLink().validate(
1128
1423
  {
1129
- id,
1424
+ body,
1130
1425
  },
1131
1426
  { abortEarly: false, allowUnknown: false }
1132
1427
  );
1133
1428
  if (warrning) {
1134
1429
  Logger({
1135
1430
  level: "WARN",
1136
- message: "Parameter Validation warrnings for getPromotionById",
1431
+ message: "Parameter Validation warrnings for getCartShareLink",
1137
1432
  });
1138
1433
  Logger({ level: "WARN", message: warrning });
1139
1434
  }
@@ -1142,21 +1437,23 @@ class Cart {
1142
1437
 
1143
1438
  const response = await PlatformAPIClient.execute(
1144
1439
  this.config,
1145
- "get",
1146
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion/${id}`,
1440
+ "post",
1441
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/share-cart`,
1147
1442
  query_params,
1148
- undefined
1443
+ body
1149
1444
  );
1150
1445
 
1151
- const { error: res_error } = CartModel.PromotionUpdate().validate(
1152
- response,
1153
- { abortEarly: false, allowUnknown: false }
1154
- );
1446
+ const {
1447
+ error: res_error,
1448
+ } = CartModel.GetShareCartLinkResponse().validate(response, {
1449
+ abortEarly: false,
1450
+ allowUnknown: false,
1451
+ });
1155
1452
 
1156
1453
  if (res_error) {
1157
1454
  Logger({
1158
1455
  level: "WARN",
1159
- message: "Response Validation Warnnings for getPromotionById",
1456
+ message: "Response Validation Warnnings for getCartShareLink",
1160
1457
  });
1161
1458
  Logger({ level: "WARN", message: res_error });
1162
1459
  }
@@ -1166,15 +1463,15 @@ class Cart {
1166
1463
 
1167
1464
  /**
1168
1465
  * @param {Object} arg - Arg object.
1169
- * @param {string} [arg.code] -
1170
- * @returns {Promise<Object>} - Success response
1171
- * @summary: Check if promotion is already created with promotion code
1172
- * @description: Check if sent promotion code is already existing promotion code. As promotion code is to be unique.
1466
+ * @param {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.
1173
1470
  */
1174
- async getPromotionCodeExists({ code } = {}) {
1175
- const { error } = CartValidator.getPromotionCodeExists().validate(
1471
+ async getCartSharedItems({ token } = {}) {
1472
+ const { error } = CartValidator.getCartSharedItems().validate(
1176
1473
  {
1177
- code,
1474
+ token,
1178
1475
  },
1179
1476
  { abortEarly: false, allowUnknown: true }
1180
1477
  );
@@ -1183,32 +1480,33 @@ class Cart {
1183
1480
  }
1184
1481
 
1185
1482
  // Showing warrnings if extra unknown parameters are found
1186
- const { error: warrning } = CartValidator.getPromotionCodeExists().validate(
1483
+ const { error: warrning } = CartValidator.getCartSharedItems().validate(
1187
1484
  {
1188
- code,
1485
+ token,
1189
1486
  },
1190
1487
  { abortEarly: false, allowUnknown: false }
1191
1488
  );
1192
1489
  if (warrning) {
1193
1490
  Logger({
1194
1491
  level: "WARN",
1195
- message: "Parameter Validation warrnings for getPromotionCodeExists",
1492
+ message: "Parameter Validation warrnings for getCartSharedItems",
1196
1493
  });
1197
1494
  Logger({ level: "WARN", message: warrning });
1198
1495
  }
1199
1496
 
1200
1497
  const query_params = {};
1201
- query_params["code"] = code;
1202
1498
 
1203
1499
  const response = await PlatformAPIClient.execute(
1204
1500
  this.config,
1205
1501
  "get",
1206
- `/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}`,
1207
1503
  query_params,
1208
1504
  undefined
1209
1505
  );
1210
1506
 
1211
- const { error: res_error } = Joi.any().validate(response, {
1507
+ const {
1508
+ error: res_error,
1509
+ } = CartModel.SharedCartResponse().validate(response, {
1212
1510
  abortEarly: false,
1213
1511
  allowUnknown: false,
1214
1512
  });
@@ -1216,7 +1514,7 @@ class Cart {
1216
1514
  if (res_error) {
1217
1515
  Logger({
1218
1516
  level: "WARN",
1219
- message: "Response Validation Warnnings for getPromotionCodeExists",
1517
+ message: "Response Validation Warnnings for getCartSharedItems",
1220
1518
  });
1221
1519
  Logger({ level: "WARN", message: res_error });
1222
1520
  }
@@ -1226,38 +1524,15 @@ class Cart {
1226
1524
 
1227
1525
  /**
1228
1526
  * @param {Object} arg - Arg object.
1229
- * @param {number} [arg.pageNo] -
1230
- * @param {number} [arg.pageSize] -
1231
- * @param {string} [arg.q] -
1232
- * @param {boolean} [arg.isActive] -
1233
- * @param {string} [arg.promoGroup] -
1234
- * @param {string} [arg.promotionType] -
1235
- * @param {string} [arg.fpPanel] -
1236
- * @param {string} [arg.promotionId] -
1237
- * @returns {Promise<PromotionsResponse>} - Success response
1238
- * @summary: Get promotion list
1239
- * @description: Get promotion list with pagination
1527
+ * @param {string} arg.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
1240
1531
  */
1241
- async getPromotions({
1242
- pageNo,
1243
- pageSize,
1244
- q,
1245
- isActive,
1246
- promoGroup,
1247
- promotionType,
1248
- fpPanel,
1249
- promotionId,
1250
- } = {}) {
1251
- const { error } = CartValidator.getPromotions().validate(
1532
+ async getCouponById({ id } = {}) {
1533
+ const { error } = CartValidator.getCouponById().validate(
1252
1534
  {
1253
- pageNo,
1254
- pageSize,
1255
- q,
1256
- isActive,
1257
- promoGroup,
1258
- promotionType,
1259
- fpPanel,
1260
- promotionId,
1535
+ id,
1261
1536
  },
1262
1537
  { abortEarly: false, allowUnknown: true }
1263
1538
  );
@@ -1266,30 +1541,626 @@ class Cart {
1266
1541
  }
1267
1542
 
1268
1543
  // Showing warrnings if extra unknown parameters are found
1269
- const { error: warrning } = CartValidator.getPromotions().validate(
1544
+ const { error: warrning } = CartValidator.getCouponById().validate(
1270
1545
  {
1271
- pageNo,
1272
- pageSize,
1273
- q,
1274
- isActive,
1275
- promoGroup,
1276
- promotionType,
1277
- fpPanel,
1278
- promotionId,
1546
+ id,
1279
1547
  },
1280
1548
  { abortEarly: false, allowUnknown: false }
1281
1549
  );
1282
1550
  if (warrning) {
1283
1551
  Logger({
1284
1552
  level: "WARN",
1285
- message: "Parameter Validation warrnings for getPromotions",
1553
+ message: "Parameter Validation warrnings for getCouponById",
1286
1554
  });
1287
1555
  Logger({ level: "WARN", message: warrning });
1288
1556
  }
1289
1557
 
1290
1558
  const query_params = {};
1291
- query_params["page_no"] = pageNo;
1292
- query_params["page_size"] = pageSize;
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;
1293
2164
  query_params["q"] = q;
1294
2165
  query_params["is_active"] = isActive;
1295
2166
  query_params["promo_group"] = promoGroup;
@@ -1299,23 +2170,1143 @@ class Cart {
1299
2170
 
1300
2171
  const response = await PlatformAPIClient.execute(
1301
2172
  this.config,
1302
- "get",
1303
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion`,
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`,
1304
3297
  query_params,
1305
- undefined
3298
+ body
1306
3299
  );
1307
3300
 
1308
- const {
1309
- error: res_error,
1310
- } = CartModel.PromotionsResponse().validate(response, {
1311
- abortEarly: false,
1312
- allowUnknown: false,
1313
- });
3301
+ const { error: res_error } = CartModel.CartMetaResponse().validate(
3302
+ response,
3303
+ { abortEarly: false, allowUnknown: false }
3304
+ );
1314
3305
 
1315
3306
  if (res_error) {
1316
3307
  Logger({
1317
3308
  level: "WARN",
1318
- message: "Response Validation Warnnings for getPromotions",
3309
+ message: "Response Validation Warnnings for updateCartMeta",
1319
3310
  });
1320
3311
  Logger({ level: "WARN", message: res_error });
1321
3312
  }
@@ -1325,66 +3316,16 @@ class Cart {
1325
3316
 
1326
3317
  /**
1327
3318
  * @param {Object} arg - Arg object.
1328
- * @param {string} arg.companyId - Current company id
1329
- * @param {string} arg.applicationId - Current Application _id
1330
- * @param {number} [arg.pageSize] -
1331
- * @param {string} [arg.q] -
1332
- * @param {boolean} [arg.isActive] -
1333
- * @param {string} [arg.promoGroup] -
1334
- * @param {string} [arg.promotionType] -
1335
- * @param {string} [arg.fpPanel] -
1336
- * @param {string} [arg.promotionId] -
1337
- * @summary: Get promotion list
1338
- * @description: Get promotion list with pagination
1339
- */
1340
- getPromotionsPaginator({
1341
- companyId,
1342
- applicationId,
1343
- pageSize,
1344
- q,
1345
- isActive,
1346
- promoGroup,
1347
- promotionType,
1348
- fpPanel,
1349
- promotionId,
1350
- } = {}) {
1351
- const paginator = new Paginator();
1352
- const callback = async () => {
1353
- const pageId = paginator.nextId;
1354
- const pageNo = paginator.pageNo;
1355
- const pageType = "number";
1356
- const data = await this.getPromotions({
1357
- companyId: companyId,
1358
- applicationId: applicationId,
1359
- pageNo: pageNo,
1360
- pageSize: pageSize,
1361
- q: q,
1362
- isActive: isActive,
1363
- promoGroup: promoGroup,
1364
- promotionType: promotionType,
1365
- fpPanel: fpPanel,
1366
- promotionId: promotionId,
1367
- });
1368
- paginator.setPaginator({
1369
- hasNext: data.page.has_next ? true : false,
1370
- nextId: data.page.next_id,
1371
- });
1372
- return data;
1373
- };
1374
- paginator.setCallback(callback.bind(this));
1375
- return paginator;
1376
- }
1377
-
1378
- /**
1379
- * @param {Object} arg - Arg object.
1380
- * @param {OverrideCheckoutReq} arg.body
1381
- * @returns {Promise<OverrideCheckoutResponse>} - Success response
1382
- * @summary: Create Fynd order with overriding cart details
1383
- * @description: Generate Fynd order while overriding cart details sent with provided `cart_items`
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
1384
3324
  */
1385
- async overrideCart({ body } = {}) {
1386
- const { error } = CartValidator.overrideCart().validate(
3325
+ async updateCartMetaConfig({ cartMetaId, body } = {}) {
3326
+ const { error } = CartValidator.updateCartMetaConfig().validate(
1387
3327
  {
3328
+ cartMetaId,
1388
3329
  body,
1389
3330
  },
1390
3331
  { abortEarly: false, allowUnknown: true }
@@ -1394,8 +3335,9 @@ class Cart {
1394
3335
  }
1395
3336
 
1396
3337
  // Showing warrnings if extra unknown parameters are found
1397
- const { error: warrning } = CartValidator.overrideCart().validate(
3338
+ const { error: warrning } = CartValidator.updateCartMetaConfig().validate(
1398
3339
  {
3340
+ cartMetaId,
1399
3341
  body,
1400
3342
  },
1401
3343
  { abortEarly: false, allowUnknown: false }
@@ -1403,7 +3345,7 @@ class Cart {
1403
3345
  if (warrning) {
1404
3346
  Logger({
1405
3347
  level: "WARN",
1406
- message: "Parameter Validation warrnings for overrideCart",
3348
+ message: "Parameter Validation warrnings for updateCartMetaConfig",
1407
3349
  });
1408
3350
  Logger({ level: "WARN", message: warrning });
1409
3351
  }
@@ -1412,15 +3354,15 @@ class Cart {
1412
3354
 
1413
3355
  const response = await PlatformAPIClient.execute(
1414
3356
  this.config,
1415
- "post",
1416
- `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/checkout/over-ride`,
3357
+ "put",
3358
+ `/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/cart_configuration/${cartMetaId}`,
1417
3359
  query_params,
1418
3360
  body
1419
3361
  );
1420
3362
 
1421
3363
  const {
1422
3364
  error: res_error,
1423
- } = CartModel.OverrideCheckoutResponse().validate(response, {
3365
+ } = CartModel.CartMetaConfigUpdate().validate(response, {
1424
3366
  abortEarly: false,
1425
3367
  allowUnknown: false,
1426
3368
  });
@@ -1428,7 +3370,7 @@ class Cart {
1428
3370
  if (res_error) {
1429
3371
  Logger({
1430
3372
  level: "WARN",
1431
- message: "Response Validation Warnnings for overrideCart",
3373
+ message: "Response Validation Warnnings for updateCartMetaConfig",
1432
3374
  });
1433
3375
  Logger({ level: "WARN", message: res_error });
1434
3376
  }
@@ -1438,19 +3380,17 @@ class Cart {
1438
3380
 
1439
3381
  /**
1440
3382
  * @param {Object} arg - Arg object.
1441
- * @param {string} arg.cartId - Current Cart _id
1442
- * @param {boolean} [arg.b] -
1443
- * @param {UpdateCartRequest} arg.body
1444
- * @returns {Promise<UpdateCartDetailResponse>} - Success response
1445
- * @summary: Update items in the abandoned cart
1446
- * @description: <p>Use this API to update items added to the cart with the help of a request object containing attributes like item_quantity and item_size. These attributes will be fetched from the following APIs</p> <ul> <li><font color="monochrome">operation</font> Operation for current api call. <b>update_item</b> for update items. <b>remove_item</b> for removing items.</li> <li> <font color="monochrome">item_id</font> "/platform/content/v1/products/"</li> <li> <font color="monochrome">item_size</font> "/platform/content/v1/products/:slug/sizes/"</li> <li> <font color="monochrome">quantity</font> item quantity (must be greater than or equal to 1)</li> <li> <font color="monochrome">article_id</font> "/content​/v1​/products​/:identifier​/sizes​/price​/"</li> <li> <font color="monochrome">item_index</font> item position in the cart (must be greater than or equal to 0)</li> </ul>
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
1447
3388
  */
1448
- async updateCart({ cartId, body, b } = {}) {
1449
- const { error } = CartValidator.updateCart().validate(
3389
+ async updateCartUser({ body, id } = {}) {
3390
+ const { error } = CartValidator.updateCartUser().validate(
1450
3391
  {
1451
- cartId,
1452
3392
  body,
1453
- b,
3393
+ id,
1454
3394
  },
1455
3395
  { abortEarly: false, allowUnknown: true }
1456
3396
  );
@@ -1459,36 +3399,35 @@ class Cart {
1459
3399
  }
1460
3400
 
1461
3401
  // Showing warrnings if extra unknown parameters are found
1462
- const { error: warrning } = CartValidator.updateCart().validate(
3402
+ const { error: warrning } = CartValidator.updateCartUser().validate(
1463
3403
  {
1464
- cartId,
1465
3404
  body,
1466
- b,
3405
+ id,
1467
3406
  },
1468
3407
  { abortEarly: false, allowUnknown: false }
1469
3408
  );
1470
3409
  if (warrning) {
1471
3410
  Logger({
1472
3411
  level: "WARN",
1473
- message: "Parameter Validation warrnings for updateCart",
3412
+ message: "Parameter Validation warrnings for updateCartUser",
1474
3413
  });
1475
3414
  Logger({ level: "WARN", message: warrning });
1476
3415
  }
1477
3416
 
1478
3417
  const query_params = {};
1479
- query_params["b"] = b;
3418
+ query_params["id"] = id;
1480
3419
 
1481
3420
  const response = await PlatformAPIClient.execute(
1482
3421
  this.config,
1483
3422
  "put",
1484
- `/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`,
1485
3424
  query_params,
1486
3425
  body
1487
3426
  );
1488
3427
 
1489
3428
  const {
1490
3429
  error: res_error,
1491
- } = CartModel.UpdateCartDetailResponse().validate(response, {
3430
+ } = CartModel.UserCartMappingResponse().validate(response, {
1492
3431
  abortEarly: false,
1493
3432
  allowUnknown: false,
1494
3433
  });
@@ -1496,7 +3435,7 @@ class Cart {
1496
3435
  if (res_error) {
1497
3436
  Logger({
1498
3437
  level: "WARN",
1499
- message: "Response Validation Warnnings for updateCart",
3438
+ message: "Response Validation Warnnings for updateCartUser",
1500
3439
  });
1501
3440
  Logger({ level: "WARN", message: res_error });
1502
3441
  }
@@ -1506,17 +3445,20 @@ class Cart {
1506
3445
 
1507
3446
  /**
1508
3447
  * @param {Object} arg - Arg object.
1509
- * @param {string} arg.cartMetaId -
1510
- * @param {CartMetaConfigUpdate} arg.body
1511
- * @returns {Promise<CartMetaConfigUpdate>} - Success response
1512
- * @summary: Update cart meta configuration
1513
- * @description: Update cart meta configuration
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.
1514
3455
  */
1515
- async updateCartMetaConfig({ cartMetaId, body } = {}) {
1516
- const { error } = CartValidator.updateCartMetaConfig().validate(
3456
+ async updateCartWithSharedItems({ token, action, cartId } = {}) {
3457
+ const { error } = CartValidator.updateCartWithSharedItems().validate(
1517
3458
  {
1518
- cartMetaId,
1519
- body,
3459
+ token,
3460
+ action,
3461
+ cartId,
1520
3462
  },
1521
3463
  { abortEarly: false, allowUnknown: true }
1522
3464
  );
@@ -1525,34 +3467,38 @@ class Cart {
1525
3467
  }
1526
3468
 
1527
3469
  // Showing warrnings if extra unknown parameters are found
1528
- const { error: warrning } = CartValidator.updateCartMetaConfig().validate(
3470
+ const {
3471
+ error: warrning,
3472
+ } = CartValidator.updateCartWithSharedItems().validate(
1529
3473
  {
1530
- cartMetaId,
1531
- body,
3474
+ token,
3475
+ action,
3476
+ cartId,
1532
3477
  },
1533
3478
  { abortEarly: false, allowUnknown: false }
1534
3479
  );
1535
3480
  if (warrning) {
1536
3481
  Logger({
1537
3482
  level: "WARN",
1538
- message: "Parameter Validation warrnings for updateCartMetaConfig",
3483
+ message: "Parameter Validation warrnings for updateCartWithSharedItems",
1539
3484
  });
1540
3485
  Logger({ level: "WARN", message: warrning });
1541
3486
  }
1542
3487
 
1543
3488
  const query_params = {};
3489
+ query_params["cart_id"] = cartId;
1544
3490
 
1545
3491
  const response = await PlatformAPIClient.execute(
1546
3492
  this.config,
1547
- "put",
1548
- `/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}`,
1549
3495
  query_params,
1550
- body
3496
+ undefined
1551
3497
  );
1552
3498
 
1553
3499
  const {
1554
3500
  error: res_error,
1555
- } = CartModel.CartMetaConfigUpdate().validate(response, {
3501
+ } = CartModel.SharedCartResponse().validate(response, {
1556
3502
  abortEarly: false,
1557
3503
  allowUnknown: false,
1558
3504
  });
@@ -1560,7 +3506,7 @@ class Cart {
1560
3506
  if (res_error) {
1561
3507
  Logger({
1562
3508
  level: "WARN",
1563
- message: "Response Validation Warnnings for updateCartMetaConfig",
3509
+ message: "Response Validation Warnnings for updateCartWithSharedItems",
1564
3510
  });
1565
3511
  Logger({ level: "WARN", message: res_error });
1566
3512
  }
@@ -1817,6 +3763,200 @@ class Cart {
1817
3763
 
1818
3764
  return response;
1819
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
+ }
1820
3960
  }
1821
3961
 
1822
3962
  module.exports = Cart;