@gofynd/fdk-client-javascript 0.1.35

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 (277) hide show
  1. package/.github/workflows/on_create_release.yml +23 -0
  2. package/.github/workflows/on_merge_main.yml +38 -0
  3. package/.github/workflows/on_pull_request.yml +35 -0
  4. package/.prettierrc +5 -0
  5. package/LICENSE +21 -0
  6. package/README.md +118 -0
  7. package/application.d.ts +3 -0
  8. package/application.js +6 -0
  9. package/common.d.ts +4 -0
  10. package/common.js +9 -0
  11. package/documentation/application/CART.md +7290 -0
  12. package/documentation/application/CATALOG.md +9570 -0
  13. package/documentation/application/COMMON.md +448 -0
  14. package/documentation/application/COMMUNICATION.md +463 -0
  15. package/documentation/application/CONFIGURATION.md +2902 -0
  16. package/documentation/application/CONTENT.md +3350 -0
  17. package/documentation/application/FILESTORAGE.md +491 -0
  18. package/documentation/application/LEAD.md +1891 -0
  19. package/documentation/application/LOGISTIC.md +439 -0
  20. package/documentation/application/ORDER.md +3428 -0
  21. package/documentation/application/PAYMENT.md +5035 -0
  22. package/documentation/application/POSCART.md +7889 -0
  23. package/documentation/application/README.md +21 -0
  24. package/documentation/application/REWARDS.md +714 -0
  25. package/documentation/application/SHARE.md +729 -0
  26. package/documentation/application/THEME.md +5796 -0
  27. package/documentation/application/USER.md +4326 -0
  28. package/documentation/platform/ANALYTICS.md +1150 -0
  29. package/documentation/platform/AUDITTRAIL.md +572 -0
  30. package/documentation/platform/BILLING.md +2396 -0
  31. package/documentation/platform/CART.md +5539 -0
  32. package/documentation/platform/CATALOG.md +21624 -0
  33. package/documentation/platform/COMMON.md +448 -0
  34. package/documentation/platform/COMMUNICATION.md +5714 -0
  35. package/documentation/platform/COMPANYPROFILE.md +2141 -0
  36. package/documentation/platform/CONFIGURATION.md +7335 -0
  37. package/documentation/platform/CONTENT.md +8989 -0
  38. package/documentation/platform/DISCOUNT.md +773 -0
  39. package/documentation/platform/FILESTORAGE.md +994 -0
  40. package/documentation/platform/INVENTORY.md +1775 -0
  41. package/documentation/platform/LEAD.md +4736 -0
  42. package/documentation/platform/ORDER.md +3764 -0
  43. package/documentation/platform/PARTNER.md +216 -0
  44. package/documentation/platform/PAYMENT.md +3444 -0
  45. package/documentation/platform/README.md +27 -0
  46. package/documentation/platform/REWARDS.md +871 -0
  47. package/documentation/platform/SHARE.md +602 -0
  48. package/documentation/platform/THEME.md +35725 -0
  49. package/documentation/platform/USER.md +2305 -0
  50. package/documentation/platform/WEBHOOK.md +587 -0
  51. package/documentation/public/CONFIGURATION.md +448 -0
  52. package/documentation/public/INVENTORY.md +686 -0
  53. package/documentation/public/WEBHOOK.md +348 -0
  54. package/index.d.ts +10 -0
  55. package/index.js +18 -0
  56. package/jest.config.d.ts +4 -0
  57. package/jest.config.js +6 -0
  58. package/package.json +35 -0
  59. package/platform.d.ts +3 -0
  60. package/platform.js +6 -0
  61. package/public.d.ts +3 -0
  62. package/public.js +6 -0
  63. package/sdk/application/ApplicationAPIClient.d.ts +11 -0
  64. package/sdk/application/ApplicationAPIClient.js +44 -0
  65. package/sdk/application/ApplicationClient.d.ts +40 -0
  66. package/sdk/application/ApplicationClient.js +84 -0
  67. package/sdk/application/ApplicationConfig.d.ts +19 -0
  68. package/sdk/application/ApplicationConfig.js +55 -0
  69. package/sdk/application/ApplicationModels.d.ts +826 -0
  70. package/sdk/application/ApplicationModels.js +10474 -0
  71. package/sdk/application/client/CartApplicationClient.d.ts +432 -0
  72. package/sdk/application/client/CartApplicationClient.js +1066 -0
  73. package/sdk/application/client/CatalogApplicationClient.d.ts +694 -0
  74. package/sdk/application/client/CatalogApplicationClient.js +1629 -0
  75. package/sdk/application/client/CommonApplicationClient.d.ts +38 -0
  76. package/sdk/application/client/CommonApplicationClient.js +105 -0
  77. package/sdk/application/client/CommunicationApplicationClient.d.ts +39 -0
  78. package/sdk/application/client/CommunicationApplicationClient.js +131 -0
  79. package/sdk/application/client/ConfigurationApplicationClient.d.ts +210 -0
  80. package/sdk/application/client/ConfigurationApplicationClient.js +649 -0
  81. package/sdk/application/client/ContentApplicationClient.d.ts +256 -0
  82. package/sdk/application/client/ContentApplicationClient.js +785 -0
  83. package/sdk/application/client/FileStorageApplicationClient.d.ts +88 -0
  84. package/sdk/application/client/FileStorageApplicationClient.js +214 -0
  85. package/sdk/application/client/LeadApplicationClient.d.ts +90 -0
  86. package/sdk/application/client/LeadApplicationClient.js +264 -0
  87. package/sdk/application/client/LogisticApplicationClient.d.ts +42 -0
  88. package/sdk/application/client/LogisticApplicationClient.js +128 -0
  89. package/sdk/application/client/OrderApplicationClient.d.ts +190 -0
  90. package/sdk/application/client/OrderApplicationClient.js +479 -0
  91. package/sdk/application/client/PaymentApplicationClient.d.ts +454 -0
  92. package/sdk/application/client/PaymentApplicationClient.js +1378 -0
  93. package/sdk/application/client/PosCartApplicationClient.d.ts +449 -0
  94. package/sdk/application/client/PosCartApplicationClient.js +1123 -0
  95. package/sdk/application/client/RewardsApplicationClient.d.ts +93 -0
  96. package/sdk/application/client/RewardsApplicationClient.js +293 -0
  97. package/sdk/application/client/ShareApplicationClient.d.ts +87 -0
  98. package/sdk/application/client/ShareApplicationClient.js +268 -0
  99. package/sdk/application/client/ThemeApplicationClient.d.ts +52 -0
  100. package/sdk/application/client/ThemeApplicationClient.js +161 -0
  101. package/sdk/application/client/UserApplicationClient.d.ts +446 -0
  102. package/sdk/application/client/UserApplicationClient.js +1275 -0
  103. package/sdk/application/constructUrl.d.ts +5 -0
  104. package/sdk/application/constructUrl.js +13 -0
  105. package/sdk/application/index.d.ts +2 -0
  106. package/sdk/application/index.js +4 -0
  107. package/sdk/application/models/CartValidator.d.ts +29 -0
  108. package/sdk/application/models/CartValidator.js +223 -0
  109. package/sdk/application/models/CatalogValidator.d.ts +33 -0
  110. package/sdk/application/models/CatalogValidator.js +233 -0
  111. package/sdk/application/models/CommonValidator.d.ts +5 -0
  112. package/sdk/application/models/CommonValidator.js +18 -0
  113. package/sdk/application/models/CommunicationValidator.d.ts +6 -0
  114. package/sdk/application/models/CommunicationValidator.js +20 -0
  115. package/sdk/application/models/ConfigurationValidator.d.ts +19 -0
  116. package/sdk/application/models/ConfigurationValidator.js +88 -0
  117. package/sdk/application/models/ContentValidator.d.ts +22 -0
  118. package/sdk/application/models/ContentValidator.js +106 -0
  119. package/sdk/application/models/FileStorageValidator.d.ts +6 -0
  120. package/sdk/application/models/FileStorageValidator.js +24 -0
  121. package/sdk/application/models/LeadValidator.d.ts +10 -0
  122. package/sdk/application/models/LeadValidator.js +48 -0
  123. package/sdk/application/models/LogisticValidator.d.ts +6 -0
  124. package/sdk/application/models/LogisticValidator.js +22 -0
  125. package/sdk/application/models/OrderValidator.d.ts +15 -0
  126. package/sdk/application/models/OrderValidator.js +87 -0
  127. package/sdk/application/models/PaymentValidator.d.ts +40 -0
  128. package/sdk/application/models/PaymentValidator.js +235 -0
  129. package/sdk/application/models/PosCartValidator.d.ts +30 -0
  130. package/sdk/application/models/PosCartValidator.js +232 -0
  131. package/sdk/application/models/RewardsValidator.d.ts +10 -0
  132. package/sdk/application/models/RewardsValidator.js +43 -0
  133. package/sdk/application/models/ShareValidator.d.ts +10 -0
  134. package/sdk/application/models/ShareValidator.js +44 -0
  135. package/sdk/application/models/ThemeValidator.d.ts +7 -0
  136. package/sdk/application/models/ThemeValidator.js +27 -0
  137. package/sdk/application/models/UserValidator.d.ts +38 -0
  138. package/sdk/application/models/UserValidator.js +233 -0
  139. package/sdk/common/AxiosHelper.d.ts +1 -0
  140. package/sdk/common/AxiosHelper.js +141 -0
  141. package/sdk/common/Constant.d.ts +294 -0
  142. package/sdk/common/Constant.js +332 -0
  143. package/sdk/common/FDKError.d.ts +26 -0
  144. package/sdk/common/FDKError.js +51 -0
  145. package/sdk/common/Logger.d.ts +2 -0
  146. package/sdk/common/Logger.js +85 -0
  147. package/sdk/common/Paginator.d.ts +16 -0
  148. package/sdk/common/Paginator.js +26 -0
  149. package/sdk/common/RequestSigner.d.ts +1 -0
  150. package/sdk/common/RequestSigner.js +306 -0
  151. package/sdk/common/Utility.d.ts +9 -0
  152. package/sdk/common/Utility.js +86 -0
  153. package/sdk/common/utils.d.ts +14 -0
  154. package/sdk/common/utils.js +165 -0
  155. package/sdk/platform/OAuthClient.d.ts +26 -0
  156. package/sdk/platform/OAuthClient.js +221 -0
  157. package/sdk/platform/PlatformAPIClient.d.ts +12 -0
  158. package/sdk/platform/PlatformAPIClient.js +43 -0
  159. package/sdk/platform/PlatformApplicationClient.d.ts +24398 -0
  160. package/sdk/platform/PlatformApplicationClient.js +23185 -0
  161. package/sdk/platform/PlatformApplicationModels.d.ts +333 -0
  162. package/sdk/platform/PlatformApplicationModels.js +21262 -0
  163. package/sdk/platform/PlatformClient.d.ts +9535 -0
  164. package/sdk/platform/PlatformClient.js +12336 -0
  165. package/sdk/platform/PlatformConfig.d.ts +29 -0
  166. package/sdk/platform/PlatformConfig.js +36 -0
  167. package/sdk/platform/PlatformModels.d.ts +1396 -0
  168. package/sdk/platform/PlatformModels.js +19222 -0
  169. package/sdk/platform/client/AnalyticsPlatformClient.d.ts +84 -0
  170. package/sdk/platform/client/AnalyticsPlatformClient.js +215 -0
  171. package/sdk/platform/client/AuditTrailPlatformClient.d.ts +38 -0
  172. package/sdk/platform/client/AuditTrailPlatformClient.js +133 -0
  173. package/sdk/platform/client/BillingPlatformClient.d.ts +109 -0
  174. package/sdk/platform/client/BillingPlatformClient.js +381 -0
  175. package/sdk/platform/client/CatalogPlatformClient.d.ts +806 -0
  176. package/sdk/platform/client/CatalogPlatformClient.js +2462 -0
  177. package/sdk/platform/client/CommonPlatformClient.d.ts +30 -0
  178. package/sdk/platform/client/CommonPlatformClient.js +84 -0
  179. package/sdk/platform/client/CommunicationPlatformClient.d.ts +26 -0
  180. package/sdk/platform/client/CommunicationPlatformClient.js +72 -0
  181. package/sdk/platform/client/CompanyProfilePlatformClient.d.ts +182 -0
  182. package/sdk/platform/client/CompanyProfilePlatformClient.js +540 -0
  183. package/sdk/platform/client/ConfigurationPlatformClient.d.ts +277 -0
  184. package/sdk/platform/client/ConfigurationPlatformClient.js +806 -0
  185. package/sdk/platform/client/DiscountPlatformClient.d.ts +118 -0
  186. package/sdk/platform/client/DiscountPlatformClient.js +364 -0
  187. package/sdk/platform/client/FileStoragePlatformClient.d.ts +111 -0
  188. package/sdk/platform/client/FileStoragePlatformClient.js +268 -0
  189. package/sdk/platform/client/InventoryPlatformClient.d.ts +125 -0
  190. package/sdk/platform/client/InventoryPlatformClient.js +409 -0
  191. package/sdk/platform/client/LeadPlatformClient.d.ts +150 -0
  192. package/sdk/platform/client/LeadPlatformClient.js +439 -0
  193. package/sdk/platform/client/OrderPlatformClient.d.ts +190 -0
  194. package/sdk/platform/client/OrderPlatformClient.js +521 -0
  195. package/sdk/platform/client/PaymentPlatformClient.d.ts +98 -0
  196. package/sdk/platform/client/PaymentPlatformClient.js +331 -0
  197. package/sdk/platform/client/WebhookPlatformClient.d.ts +64 -0
  198. package/sdk/platform/client/WebhookPlatformClient.js +207 -0
  199. package/sdk/platform/index.d.ts +2 -0
  200. package/sdk/platform/index.js +4 -0
  201. package/sdk/platform/models/AnalyticsValidator.d.ts +7 -0
  202. package/sdk/platform/models/AnalyticsValidator.js +36 -0
  203. package/sdk/platform/models/AuditTrailValidator.d.ts +7 -0
  204. package/sdk/platform/models/AuditTrailValidator.js +26 -0
  205. package/sdk/platform/models/BillingValidator.d.ts +15 -0
  206. package/sdk/platform/models/BillingValidator.js +72 -0
  207. package/sdk/platform/models/CartValidator.d.ts +0 -0
  208. package/sdk/platform/models/CartValidator.js +0 -0
  209. package/sdk/platform/models/CatalogValidator.d.ts +74 -0
  210. package/sdk/platform/models/CatalogValidator.js +484 -0
  211. package/sdk/platform/models/CommonValidator.d.ts +5 -0
  212. package/sdk/platform/models/CommonValidator.js +18 -0
  213. package/sdk/platform/models/CommunicationValidator.d.ts +4 -0
  214. package/sdk/platform/models/CommunicationValidator.js +11 -0
  215. package/sdk/platform/models/CompanyProfileValidator.d.ts +17 -0
  216. package/sdk/platform/models/CompanyProfileValidator.js +93 -0
  217. package/sdk/platform/models/ConfigurationValidator.d.ts +21 -0
  218. package/sdk/platform/models/ConfigurationValidator.js +134 -0
  219. package/sdk/platform/models/ContentValidator.d.ts +0 -0
  220. package/sdk/platform/models/ContentValidator.js +0 -0
  221. package/sdk/platform/models/DiscountValidator.d.ts +13 -0
  222. package/sdk/platform/models/DiscountValidator.js +75 -0
  223. package/sdk/platform/models/FileStorageValidator.d.ts +9 -0
  224. package/sdk/platform/models/FileStorageValidator.js +44 -0
  225. package/sdk/platform/models/InventoryValidator.d.ts +15 -0
  226. package/sdk/platform/models/InventoryValidator.js +81 -0
  227. package/sdk/platform/models/LeadValidator.d.ts +14 -0
  228. package/sdk/platform/models/LeadValidator.js +78 -0
  229. package/sdk/platform/models/OrderValidator.d.ts +14 -0
  230. package/sdk/platform/models/OrderValidator.js +110 -0
  231. package/sdk/platform/models/PartnerValidator.d.ts +0 -0
  232. package/sdk/platform/models/PartnerValidator.js +0 -0
  233. package/sdk/platform/models/PaymentValidator.d.ts +13 -0
  234. package/sdk/platform/models/PaymentValidator.js +65 -0
  235. package/sdk/platform/models/RewardsValidator.d.ts +0 -0
  236. package/sdk/platform/models/RewardsValidator.js +0 -0
  237. package/sdk/platform/models/ShareValidator.d.ts +0 -0
  238. package/sdk/platform/models/ShareValidator.js +0 -0
  239. package/sdk/platform/models/ThemeValidator.d.ts +0 -0
  240. package/sdk/platform/models/ThemeValidator.js +0 -0
  241. package/sdk/platform/models/UserValidator.d.ts +0 -0
  242. package/sdk/platform/models/UserValidator.js +0 -0
  243. package/sdk/platform/models/WebhookValidator.d.ts +9 -0
  244. package/sdk/platform/models/WebhookValidator.js +42 -0
  245. package/sdk/public/PublicAPIClient.d.ts +11 -0
  246. package/sdk/public/PublicAPIClient.js +38 -0
  247. package/sdk/public/PublicClient.d.ts +12 -0
  248. package/sdk/public/PublicClient.js +24 -0
  249. package/sdk/public/PublicConfig.d.ts +10 -0
  250. package/sdk/public/PublicConfig.js +12 -0
  251. package/sdk/public/PublicModels.d.ts +50 -0
  252. package/sdk/public/PublicModels.js +712 -0
  253. package/sdk/public/client/ConfigurationPublicClient.d.ts +38 -0
  254. package/sdk/public/client/ConfigurationPublicClient.js +102 -0
  255. package/sdk/public/client/InventoryPublicClient.d.ts +81 -0
  256. package/sdk/public/client/InventoryPublicClient.js +239 -0
  257. package/sdk/public/client/WebhookPublicClient.d.ts +28 -0
  258. package/sdk/public/client/WebhookPublicClient.js +92 -0
  259. package/sdk/public/constructUrl.d.ts +5 -0
  260. package/sdk/public/constructUrl.js +13 -0
  261. package/sdk/public/index.d.ts +2 -0
  262. package/sdk/public/index.js +4 -0
  263. package/sdk/public/models/ConfigurationValidator.d.ts +5 -0
  264. package/sdk/public/models/ConfigurationValidator.js +18 -0
  265. package/sdk/public/models/InventoryValidator.d.ts +9 -0
  266. package/sdk/public/models/InventoryValidator.js +43 -0
  267. package/sdk/public/models/WebhookValidator.d.ts +5 -0
  268. package/sdk/public/models/WebhookValidator.js +14 -0
  269. package/tests/application/catalog.spec.js +47 -0
  270. package/tests/common/action-url.spec.js +35 -0
  271. package/tests/common/schema/action-url.json +163 -0
  272. package/tests/common/schema/url-action.json +667 -0
  273. package/tests/common/url-action.spec.js +48 -0
  274. package/tests/helpers/cookie.helper.js +31 -0
  275. package/tests/helpers/oauth.helper.js +43 -0
  276. package/tests/platform/catalog.spec.js +49 -0
  277. package/tests/public/location.spec.js +39 -0
@@ -0,0 +1,1066 @@
1
+ const APIClient = require("../ApplicationAPIClient");
2
+ const Paginator = require("../../common/Paginator");
3
+ const constructUrl = require("../constructUrl");
4
+ const { FDKClientValidationError } = require("../../common/FDKError");
5
+ const CartValidator = require("../models/CartValidator");
6
+
7
+ class Cart {
8
+ constructor(_conf) {
9
+ this._conf = _conf;
10
+ this._relativeUrls = {
11
+ getCart: "/service/application/cart/v1.0/detail",
12
+ getCartLastModified: "/service/application/cart/v1.0/detail",
13
+ addItems: "/service/application/cart/v1.0/detail",
14
+ updateCart: "/service/application/cart/v1.0/detail",
15
+ getItemCount: "/service/application/cart/v1.0/basic",
16
+ getCoupons: "/service/application/cart/v1.0/coupon",
17
+ applyCoupon: "/service/application/cart/v1.0/coupon",
18
+ removeCoupon: "/service/application/cart/v1.0/coupon",
19
+ getBulkDiscountOffers: "/service/application/cart/v1.0/bulk-price",
20
+ applyRewardPoints: "/service/application/cart/v1.0/redeem/points/",
21
+ getAddresses: "/service/application/cart/v1.0/address",
22
+ addAddress: "/service/application/cart/v1.0/address",
23
+ getAddressById: "/service/application/cart/v1.0/address/{id}",
24
+ updateAddress: "/service/application/cart/v1.0/address/{id}",
25
+ removeAddress: "/service/application/cart/v1.0/address/{id}",
26
+ selectAddress: "/service/application/cart/v1.0/select-address",
27
+ selectPaymentMode: "/service/application/cart/v1.0/payment",
28
+ validateCouponForPayment:
29
+ "/service/application/cart/v1.0/payment/validate/",
30
+ getShipments: "/service/application/cart/v1.0/shipment",
31
+ checkoutCart: "/service/application/cart/v1.0/checkout",
32
+ updateCartMeta: "/service/application/cart/v1.0/meta",
33
+ getCartShareLink: "/service/application/cart/v1.0/share-cart",
34
+ getCartSharedItems: "/service/application/cart/v1.0/share-cart/{token}",
35
+ updateCartWithSharedItems:
36
+ "/service/application/cart/v1.0/share-cart/{token}/{action}",
37
+ getPromotionOffers: "/service/application/cart/v1.0/available-promotions",
38
+ getLadderOffers: "/service/application/cart/v1.0/available-ladder-prices",
39
+ };
40
+ this._urls = Object.entries(this._relativeUrls).reduce(
41
+ (urls, [method, relativeUrl]) => {
42
+ urls[method] = `${_conf.domain}${relativeUrl}`;
43
+ return urls;
44
+ },
45
+ {}
46
+ );
47
+ }
48
+
49
+ updateUrls(urls) {
50
+ this._urls = {
51
+ ...this._urls,
52
+ ...urls,
53
+ };
54
+ }
55
+
56
+ /**
57
+ * @param {Object} arg - Arg object.
58
+ * @param {string} [arg.id] -
59
+ * @param {boolean} [arg.i] -
60
+ * @param {boolean} [arg.b] -
61
+ * @param {number} [arg.assignCardId] -
62
+ * @param {boolean} [arg.buyNow] -
63
+ * @returns {Promise<CartDetailResponse>} - Success response
64
+ * @summary: Fetch all items added to the cart
65
+ * @description: Use this API to get details of all the items added to a cart.
66
+ */
67
+ getCart({ id, i, b, assignCardId, buyNow } = {}) {
68
+ const { error } = CartValidator.getCart().validate(
69
+ { id, i, b, assignCardId, buyNow },
70
+ { abortEarly: false, allowUnknown: true }
71
+ );
72
+ if (error) {
73
+ return Promise.reject(new FDKClientValidationError(error));
74
+ }
75
+ const query_params = {};
76
+ query_params["id"] = id;
77
+ query_params["i"] = i;
78
+ query_params["b"] = b;
79
+ query_params["assign_card_id"] = assignCardId;
80
+ query_params["buy_now"] = buyNow;
81
+
82
+ const xHeaders = {};
83
+
84
+ return APIClient.execute(
85
+ this._conf,
86
+ "get",
87
+ constructUrl({
88
+ url: this._urls["getCart"],
89
+ params: {},
90
+ }),
91
+ query_params,
92
+ undefined,
93
+ xHeaders
94
+ );
95
+ }
96
+
97
+ /**
98
+ * @param {Object} arg - Arg object.
99
+ * @param {string} [arg.id] -
100
+ * @returns {Promise<any>} - Success response
101
+ * @summary: Fetch last-modified timestamp
102
+ * @description: Use this API to fetch Last-Modified timestamp in header metadata.
103
+ */
104
+ getCartLastModified({ id } = {}) {
105
+ const { error } = CartValidator.getCartLastModified().validate(
106
+ { id },
107
+ { abortEarly: false, allowUnknown: true }
108
+ );
109
+ if (error) {
110
+ return Promise.reject(new FDKClientValidationError(error));
111
+ }
112
+ const query_params = {};
113
+ query_params["id"] = id;
114
+
115
+ const xHeaders = {};
116
+
117
+ return APIClient.execute(
118
+ this._conf,
119
+ "head",
120
+ constructUrl({
121
+ url: this._urls["getCartLastModified"],
122
+ params: {},
123
+ }),
124
+ query_params,
125
+ undefined,
126
+ xHeaders
127
+ );
128
+ }
129
+
130
+ /**
131
+ * @param {Object} arg - Arg object.
132
+ * @param {boolean} [arg.i] -
133
+ * @param {boolean} [arg.b] -
134
+ * @param {boolean} [arg.buyNow] -
135
+ * @param {AddCartRequest} arg.body
136
+ * @returns {Promise<AddCartDetailResponse>} - Success response
137
+ * @summary: Add items to cart
138
+ * @description: Use this API to add items to the cart.
139
+ */
140
+ addItems({ body, i, b, buyNow } = {}) {
141
+ const { error } = CartValidator.addItems().validate(
142
+ { body, i, b, buyNow },
143
+ { abortEarly: false, allowUnknown: true }
144
+ );
145
+ if (error) {
146
+ return Promise.reject(new FDKClientValidationError(error));
147
+ }
148
+ const query_params = {};
149
+ query_params["i"] = i;
150
+ query_params["b"] = b;
151
+ query_params["buy_now"] = buyNow;
152
+
153
+ const xHeaders = {};
154
+
155
+ return APIClient.execute(
156
+ this._conf,
157
+ "post",
158
+ constructUrl({
159
+ url: this._urls["addItems"],
160
+ params: {},
161
+ }),
162
+ query_params,
163
+ body,
164
+ xHeaders
165
+ );
166
+ }
167
+
168
+ /**
169
+ * @param {Object} arg - Arg object.
170
+ * @param {string} [arg.id] -
171
+ * @param {boolean} [arg.i] -
172
+ * @param {boolean} [arg.b] -
173
+ * @param {boolean} [arg.buyNow] -
174
+ * @param {UpdateCartRequest} arg.body
175
+ * @returns {Promise<UpdateCartDetailResponse>} - Success response
176
+ * @summary: Update items in the cart
177
+ * @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>
178
+ */
179
+ updateCart({ body, id, i, b, buyNow } = {}) {
180
+ const { error } = CartValidator.updateCart().validate(
181
+ { body, id, i, b, buyNow },
182
+ { abortEarly: false, allowUnknown: true }
183
+ );
184
+ if (error) {
185
+ return Promise.reject(new FDKClientValidationError(error));
186
+ }
187
+ const query_params = {};
188
+ query_params["id"] = id;
189
+ query_params["i"] = i;
190
+ query_params["b"] = b;
191
+ query_params["buy_now"] = buyNow;
192
+
193
+ const xHeaders = {};
194
+
195
+ return APIClient.execute(
196
+ this._conf,
197
+ "put",
198
+ constructUrl({
199
+ url: this._urls["updateCart"],
200
+ params: {},
201
+ }),
202
+ query_params,
203
+ body,
204
+ xHeaders
205
+ );
206
+ }
207
+
208
+ /**
209
+ * @param {Object} arg - Arg object.
210
+ * @param {string} [arg.id] - The unique identifier of the cart.
211
+ * @param {boolean} [arg.buyNow] -
212
+ * @returns {Promise<CartItemCountResponse>} - Success response
213
+ * @summary: Count items in the cart
214
+ * @description: Use this API to get the total number of items present in cart.
215
+ */
216
+ getItemCount({ id, buyNow } = {}) {
217
+ const { error } = CartValidator.getItemCount().validate(
218
+ { id, buyNow },
219
+ { abortEarly: false, allowUnknown: true }
220
+ );
221
+ if (error) {
222
+ return Promise.reject(new FDKClientValidationError(error));
223
+ }
224
+ const query_params = {};
225
+ query_params["id"] = id;
226
+ query_params["buy_now"] = buyNow;
227
+
228
+ const xHeaders = {};
229
+
230
+ return APIClient.execute(
231
+ this._conf,
232
+ "get",
233
+ constructUrl({
234
+ url: this._urls["getItemCount"],
235
+ params: {},
236
+ }),
237
+ query_params,
238
+ undefined,
239
+ xHeaders
240
+ );
241
+ }
242
+
243
+ /**
244
+ * @param {Object} arg - Arg object.
245
+ * @param {string} [arg.id] -
246
+ * @param {boolean} [arg.buyNow] -
247
+ * @returns {Promise<GetCouponResponse>} - Success response
248
+ * @summary: Fetch Coupon
249
+ * @description: Use this API to get a list of available coupons along with their details.
250
+ */
251
+ getCoupons({ id, buyNow } = {}) {
252
+ const { error } = CartValidator.getCoupons().validate(
253
+ { id, buyNow },
254
+ { abortEarly: false, allowUnknown: true }
255
+ );
256
+ if (error) {
257
+ return Promise.reject(new FDKClientValidationError(error));
258
+ }
259
+ const query_params = {};
260
+ query_params["id"] = id;
261
+ query_params["buy_now"] = buyNow;
262
+
263
+ const xHeaders = {};
264
+
265
+ return APIClient.execute(
266
+ this._conf,
267
+ "get",
268
+ constructUrl({
269
+ url: this._urls["getCoupons"],
270
+ params: {},
271
+ }),
272
+ query_params,
273
+ undefined,
274
+ xHeaders
275
+ );
276
+ }
277
+
278
+ /**
279
+ * @param {Object} arg - Arg object.
280
+ * @param {boolean} [arg.i] -
281
+ * @param {boolean} [arg.b] -
282
+ * @param {boolean} [arg.p] -
283
+ * @param {string} [arg.id] -
284
+ * @param {boolean} [arg.buyNow] -
285
+ * @param {ApplyCouponRequest} arg.body
286
+ * @returns {Promise<CartDetailResponse>} - Success response
287
+ * @summary: Apply Coupon
288
+ * @description: Use this API to apply coupons on items in the cart.
289
+ */
290
+ applyCoupon({ body, i, b, p, id, buyNow } = {}) {
291
+ const { error } = CartValidator.applyCoupon().validate(
292
+ { body, i, b, p, id, buyNow },
293
+ { abortEarly: false, allowUnknown: true }
294
+ );
295
+ if (error) {
296
+ return Promise.reject(new FDKClientValidationError(error));
297
+ }
298
+ const query_params = {};
299
+ query_params["i"] = i;
300
+ query_params["b"] = b;
301
+ query_params["p"] = p;
302
+ query_params["id"] = id;
303
+ query_params["buy_now"] = buyNow;
304
+
305
+ const xHeaders = {};
306
+
307
+ return APIClient.execute(
308
+ this._conf,
309
+ "post",
310
+ constructUrl({
311
+ url: this._urls["applyCoupon"],
312
+ params: {},
313
+ }),
314
+ query_params,
315
+ body,
316
+ xHeaders
317
+ );
318
+ }
319
+
320
+ /**
321
+ * @param {Object} arg - Arg object.
322
+ * @param {string} [arg.id] -
323
+ * @param {boolean} [arg.buyNow] -
324
+ * @returns {Promise<CartDetailResponse>} - Success response
325
+ * @summary: Remove Coupon Applied
326
+ * @description: Remove Coupon applied on the cart by passing uid in request body.
327
+ */
328
+ removeCoupon({ id, buyNow } = {}) {
329
+ const { error } = CartValidator.removeCoupon().validate(
330
+ { id, buyNow },
331
+ { abortEarly: false, allowUnknown: true }
332
+ );
333
+ if (error) {
334
+ return Promise.reject(new FDKClientValidationError(error));
335
+ }
336
+ const query_params = {};
337
+ query_params["id"] = id;
338
+ query_params["buy_now"] = buyNow;
339
+
340
+ const xHeaders = {};
341
+
342
+ return APIClient.execute(
343
+ this._conf,
344
+ "delete",
345
+ constructUrl({
346
+ url: this._urls["removeCoupon"],
347
+ params: {},
348
+ }),
349
+ query_params,
350
+ undefined,
351
+ xHeaders
352
+ );
353
+ }
354
+
355
+ /**
356
+ * @param {Object} arg - Arg object.
357
+ * @param {number} [arg.itemId] - The Item ID of the product
358
+ * @param {string} [arg.articleId] - Article Mongo ID
359
+ * @param {number} [arg.uid] - UID of the product
360
+ * @param {string} [arg.slug] - A short, human-readable, URL-friendly
361
+ * identifier of a product. You can get slug value from the endpoint
362
+ * /service/application/catalog/v1.0/products/
363
+ * @returns {Promise<BulkPriceResponse>} - Success response
364
+ * @summary: Get discount offers based on quantity
365
+ * @description: Use this API to get a list of applicable offers along with current, next and best offer for given product. Either one of uid, item_id, slug should be present.
366
+ */
367
+ getBulkDiscountOffers({ itemId, articleId, uid, slug } = {}) {
368
+ const { error } = CartValidator.getBulkDiscountOffers().validate(
369
+ { itemId, articleId, uid, slug },
370
+ { abortEarly: false, allowUnknown: true }
371
+ );
372
+ if (error) {
373
+ return Promise.reject(new FDKClientValidationError(error));
374
+ }
375
+ const query_params = {};
376
+ query_params["item_id"] = itemId;
377
+ query_params["article_id"] = articleId;
378
+ query_params["uid"] = uid;
379
+ query_params["slug"] = slug;
380
+
381
+ const xHeaders = {};
382
+
383
+ return APIClient.execute(
384
+ this._conf,
385
+ "get",
386
+ constructUrl({
387
+ url: this._urls["getBulkDiscountOffers"],
388
+ params: {},
389
+ }),
390
+ query_params,
391
+ undefined,
392
+ xHeaders
393
+ );
394
+ }
395
+
396
+ /**
397
+ * @param {Object} arg - Arg object.
398
+ * @param {string} [arg.id] -
399
+ * @param {boolean} [arg.i] -
400
+ * @param {boolean} [arg.b] -
401
+ * @param {boolean} [arg.buyNow] -
402
+ * @param {RewardPointRequest} arg.body
403
+ * @returns {Promise<CartDetailResponse>} - Success response
404
+ * @summary: Apply reward points at cart
405
+ * @description: Use this API to redeem a fixed no. of reward points by applying it to the cart.
406
+ */
407
+ applyRewardPoints({ body, id, i, b, buyNow } = {}) {
408
+ const { error } = CartValidator.applyRewardPoints().validate(
409
+ { body, id, i, b, buyNow },
410
+ { abortEarly: false, allowUnknown: true }
411
+ );
412
+ if (error) {
413
+ return Promise.reject(new FDKClientValidationError(error));
414
+ }
415
+ const query_params = {};
416
+ query_params["id"] = id;
417
+ query_params["i"] = i;
418
+ query_params["b"] = b;
419
+ query_params["buy_now"] = buyNow;
420
+
421
+ const xHeaders = {};
422
+
423
+ return APIClient.execute(
424
+ this._conf,
425
+ "post",
426
+ constructUrl({
427
+ url: this._urls["applyRewardPoints"],
428
+ params: {},
429
+ }),
430
+ query_params,
431
+ body,
432
+ xHeaders
433
+ );
434
+ }
435
+
436
+ /**
437
+ * @param {Object} arg - Arg object.
438
+ * @param {string} [arg.cartId] -
439
+ * @param {boolean} [arg.buyNow] -
440
+ * @param {string} [arg.mobileNo] -
441
+ * @param {string} [arg.checkoutMode] -
442
+ * @param {string} [arg.tags] -
443
+ * @param {boolean} [arg.isDefault] -
444
+ * @returns {Promise<GetAddressesResponse>} - Success response
445
+ * @summary: Fetch address
446
+ * @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>
447
+ */
448
+ getAddresses({
449
+ cartId,
450
+ buyNow,
451
+ mobileNo,
452
+ checkoutMode,
453
+ tags,
454
+ isDefault,
455
+ } = {}) {
456
+ const { error } = CartValidator.getAddresses().validate(
457
+ { cartId, buyNow, mobileNo, checkoutMode, tags, isDefault },
458
+ { abortEarly: false, allowUnknown: true }
459
+ );
460
+ if (error) {
461
+ return Promise.reject(new FDKClientValidationError(error));
462
+ }
463
+ const query_params = {};
464
+ query_params["cart_id"] = cartId;
465
+ query_params["buy_now"] = buyNow;
466
+ query_params["mobile_no"] = mobileNo;
467
+ query_params["checkout_mode"] = checkoutMode;
468
+ query_params["tags"] = tags;
469
+ query_params["is_default"] = isDefault;
470
+
471
+ const xHeaders = {};
472
+
473
+ return APIClient.execute(
474
+ this._conf,
475
+ "get",
476
+ constructUrl({
477
+ url: this._urls["getAddresses"],
478
+ params: {},
479
+ }),
480
+ query_params,
481
+ undefined,
482
+ xHeaders
483
+ );
484
+ }
485
+
486
+ /**
487
+ * @param {Object} arg - Arg object.
488
+ * @param {Address} arg.body
489
+ * @returns {Promise<SaveAddressResponse>} - Success response
490
+ * @summary: Add address to an account
491
+ * @description: Use this API to add an address to an account.
492
+ */
493
+ addAddress({ body } = {}) {
494
+ const { error } = CartValidator.addAddress().validate(
495
+ { body },
496
+ { abortEarly: false, allowUnknown: true }
497
+ );
498
+ if (error) {
499
+ return Promise.reject(new FDKClientValidationError(error));
500
+ }
501
+ const query_params = {};
502
+
503
+ const xHeaders = {};
504
+
505
+ return APIClient.execute(
506
+ this._conf,
507
+ "post",
508
+ constructUrl({
509
+ url: this._urls["addAddress"],
510
+ params: {},
511
+ }),
512
+ query_params,
513
+ body,
514
+ xHeaders
515
+ );
516
+ }
517
+
518
+ /**
519
+ * @param {Object} arg - Arg object.
520
+ * @param {string} arg.id -
521
+ * @param {string} [arg.cartId] -
522
+ * @param {boolean} [arg.buyNow] -
523
+ * @param {string} [arg.mobileNo] -
524
+ * @param {string} [arg.checkoutMode] -
525
+ * @param {string} [arg.tags] -
526
+ * @param {boolean} [arg.isDefault] -
527
+ * @returns {Promise<Address>} - Success response
528
+ * @summary: Fetch a single address by its ID
529
+ * @description: Use this API to get an addresses using its ID. If successful, returns a Address resource in the response body specified in `Address`. 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>
530
+ */
531
+ getAddressById({
532
+ id,
533
+ cartId,
534
+ buyNow,
535
+ mobileNo,
536
+ checkoutMode,
537
+ tags,
538
+ isDefault,
539
+ } = {}) {
540
+ const { error } = CartValidator.getAddressById().validate(
541
+ { id, cartId, buyNow, mobileNo, checkoutMode, tags, isDefault },
542
+ { abortEarly: false, allowUnknown: true }
543
+ );
544
+ if (error) {
545
+ return Promise.reject(new FDKClientValidationError(error));
546
+ }
547
+ const query_params = {};
548
+ query_params["cart_id"] = cartId;
549
+ query_params["buy_now"] = buyNow;
550
+ query_params["mobile_no"] = mobileNo;
551
+ query_params["checkout_mode"] = checkoutMode;
552
+ query_params["tags"] = tags;
553
+ query_params["is_default"] = isDefault;
554
+
555
+ const xHeaders = {};
556
+
557
+ return APIClient.execute(
558
+ this._conf,
559
+ "get",
560
+ constructUrl({
561
+ url: this._urls["getAddressById"],
562
+ params: { id },
563
+ }),
564
+ query_params,
565
+ undefined,
566
+ xHeaders
567
+ );
568
+ }
569
+
570
+ /**
571
+ * @param {Object} arg - Arg object.
572
+ * @param {string} arg.id - ID allotted to the selected address
573
+ * @param {Address} arg.body
574
+ * @returns {Promise<UpdateAddressResponse>} - Success response
575
+ * @summary: Update address added to an account
576
+ * @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>
577
+ */
578
+ updateAddress({ id, body } = {}) {
579
+ const { error } = CartValidator.updateAddress().validate(
580
+ { id, body },
581
+ { abortEarly: false, allowUnknown: true }
582
+ );
583
+ if (error) {
584
+ return Promise.reject(new FDKClientValidationError(error));
585
+ }
586
+ const query_params = {};
587
+
588
+ const xHeaders = {};
589
+
590
+ return APIClient.execute(
591
+ this._conf,
592
+ "put",
593
+ constructUrl({
594
+ url: this._urls["updateAddress"],
595
+ params: { id },
596
+ }),
597
+ query_params,
598
+ body,
599
+ xHeaders
600
+ );
601
+ }
602
+
603
+ /**
604
+ * @param {Object} arg - Arg object.
605
+ * @param {string} arg.id - ID allotted to the selected address
606
+ * @returns {Promise<DeleteAddressResponse>} - Success response
607
+ * @summary: Remove address associated with an account
608
+ * @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.
609
+ */
610
+ removeAddress({ id } = {}) {
611
+ const { error } = CartValidator.removeAddress().validate(
612
+ { id },
613
+ { abortEarly: false, allowUnknown: true }
614
+ );
615
+ if (error) {
616
+ return Promise.reject(new FDKClientValidationError(error));
617
+ }
618
+ const query_params = {};
619
+
620
+ const xHeaders = {};
621
+
622
+ return APIClient.execute(
623
+ this._conf,
624
+ "delete",
625
+ constructUrl({
626
+ url: this._urls["removeAddress"],
627
+ params: { id },
628
+ }),
629
+ query_params,
630
+ undefined,
631
+ xHeaders
632
+ );
633
+ }
634
+
635
+ /**
636
+ * @param {Object} arg - Arg object.
637
+ * @param {string} [arg.cartId] -
638
+ * @param {boolean} [arg.buyNow] -
639
+ * @param {boolean} [arg.i] -
640
+ * @param {boolean} [arg.b] -
641
+ * @param {SelectCartAddressRequest} arg.body
642
+ * @returns {Promise<CartDetailResponse>} - Success response
643
+ * @summary: Select an address from available addresses
644
+ * @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 `SelectCartAddressRequest` 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>
645
+ */
646
+ selectAddress({ body, cartId, buyNow, i, b } = {}) {
647
+ const { error } = CartValidator.selectAddress().validate(
648
+ { body, cartId, buyNow, i, b },
649
+ { abortEarly: false, allowUnknown: true }
650
+ );
651
+ if (error) {
652
+ return Promise.reject(new FDKClientValidationError(error));
653
+ }
654
+ const query_params = {};
655
+ query_params["cart_id"] = cartId;
656
+ query_params["buy_now"] = buyNow;
657
+ query_params["i"] = i;
658
+ query_params["b"] = b;
659
+
660
+ const xHeaders = {};
661
+
662
+ return APIClient.execute(
663
+ this._conf,
664
+ "post",
665
+ constructUrl({
666
+ url: this._urls["selectAddress"],
667
+ params: {},
668
+ }),
669
+ query_params,
670
+ body,
671
+ xHeaders
672
+ );
673
+ }
674
+
675
+ /**
676
+ * @param {Object} arg - Arg object.
677
+ * @param {string} [arg.id] -
678
+ * @param {boolean} [arg.buyNow] -
679
+ * @param {UpdateCartPaymentRequest} arg.body
680
+ * @returns {Promise<CartDetailResponse>} - Success response
681
+ * @summary: Update cart payment
682
+ * @description: Use this API to update cart payment.
683
+ */
684
+ selectPaymentMode({ body, id, buyNow } = {}) {
685
+ const { error } = CartValidator.selectPaymentMode().validate(
686
+ { body, id, buyNow },
687
+ { abortEarly: false, allowUnknown: true }
688
+ );
689
+ if (error) {
690
+ return Promise.reject(new FDKClientValidationError(error));
691
+ }
692
+ const query_params = {};
693
+ query_params["id"] = id;
694
+ query_params["buy_now"] = buyNow;
695
+
696
+ const xHeaders = {};
697
+
698
+ return APIClient.execute(
699
+ this._conf,
700
+ "put",
701
+ constructUrl({
702
+ url: this._urls["selectPaymentMode"],
703
+ params: {},
704
+ }),
705
+ query_params,
706
+ body,
707
+ xHeaders
708
+ );
709
+ }
710
+
711
+ /**
712
+ * @param {Object} arg - Arg object.
713
+ * @param {string} [arg.id] -
714
+ * @param {boolean} [arg.buyNow] -
715
+ * @param {string} [arg.addressId] -
716
+ * @param {string} [arg.paymentMode] -
717
+ * @param {string} [arg.paymentIdentifier] -
718
+ * @param {string} [arg.aggregatorName] -
719
+ * @param {string} [arg.merchantCode] -
720
+ * @returns {Promise<PaymentCouponValidate>} - Success response
721
+ * @summary: Verify the coupon eligibility against the payment mode
722
+ * @description: Use this API to validate a coupon against the payment mode such as NetBanking, Wallet, UPI etc.
723
+ */
724
+ validateCouponForPayment({
725
+ id,
726
+ buyNow,
727
+ addressId,
728
+ paymentMode,
729
+ paymentIdentifier,
730
+ aggregatorName,
731
+ merchantCode,
732
+ } = {}) {
733
+ const { error } = CartValidator.validateCouponForPayment().validate(
734
+ {
735
+ id,
736
+ buyNow,
737
+ addressId,
738
+ paymentMode,
739
+ paymentIdentifier,
740
+ aggregatorName,
741
+ merchantCode,
742
+ },
743
+ { abortEarly: false, allowUnknown: true }
744
+ );
745
+ if (error) {
746
+ return Promise.reject(new FDKClientValidationError(error));
747
+ }
748
+ const query_params = {};
749
+ query_params["id"] = id;
750
+ query_params["buy_now"] = buyNow;
751
+ query_params["address_id"] = addressId;
752
+ query_params["payment_mode"] = paymentMode;
753
+ query_params["payment_identifier"] = paymentIdentifier;
754
+ query_params["aggregator_name"] = aggregatorName;
755
+ query_params["merchant_code"] = merchantCode;
756
+
757
+ const xHeaders = {};
758
+
759
+ return APIClient.execute(
760
+ this._conf,
761
+ "get",
762
+ constructUrl({
763
+ url: this._urls["validateCouponForPayment"],
764
+ params: {},
765
+ }),
766
+ query_params,
767
+ undefined,
768
+ xHeaders
769
+ );
770
+ }
771
+
772
+ /**
773
+ * @param {Object} arg - Arg object.
774
+ * @param {boolean} [arg.p] - This is a boolean value. Select `true` for
775
+ * getting a payment option in response.
776
+ * @param {string} [arg.id] - The unique identifier of the cart
777
+ * @param {boolean} [arg.buyNow] -
778
+ * @param {string} [arg.addressId] - ID allotted to the selected address
779
+ * @param {string} [arg.areaCode] - The PIN Code of the destination address,
780
+ * e.g. 400059
781
+ * @returns {Promise<CartShipmentsResponse>} - Success response
782
+ * @summary: Get delivery date and options before checkout
783
+ * @description: Use this API to get shipment details, expected delivery date, items and price breakup of the shipment.
784
+ */
785
+ getShipments({ p, id, buyNow, addressId, areaCode } = {}) {
786
+ const { error } = CartValidator.getShipments().validate(
787
+ { p, id, buyNow, addressId, areaCode },
788
+ { abortEarly: false, allowUnknown: true }
789
+ );
790
+ if (error) {
791
+ return Promise.reject(new FDKClientValidationError(error));
792
+ }
793
+ const query_params = {};
794
+ query_params["p"] = p;
795
+ query_params["id"] = id;
796
+ query_params["buy_now"] = buyNow;
797
+ query_params["address_id"] = addressId;
798
+ query_params["area_code"] = areaCode;
799
+
800
+ const xHeaders = {};
801
+
802
+ return APIClient.execute(
803
+ this._conf,
804
+ "get",
805
+ constructUrl({
806
+ url: this._urls["getShipments"],
807
+ params: {},
808
+ }),
809
+ query_params,
810
+ undefined,
811
+ xHeaders
812
+ );
813
+ }
814
+
815
+ /**
816
+ * @param {Object} arg - Arg object.
817
+ * @param {boolean} [arg.buyNow] - This indicates the type of cart to checkout
818
+ * @param {CartCheckoutDetailRequest} arg.body
819
+ * @returns {Promise<CartCheckoutResponse>} - Success response
820
+ * @summary: Checkout all items in the cart
821
+ * @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.
822
+ */
823
+ checkoutCart({ body, buyNow } = {}) {
824
+ const { error } = CartValidator.checkoutCart().validate(
825
+ { body, buyNow },
826
+ { abortEarly: false, allowUnknown: true }
827
+ );
828
+ if (error) {
829
+ return Promise.reject(new FDKClientValidationError(error));
830
+ }
831
+ const query_params = {};
832
+ query_params["buy_now"] = buyNow;
833
+
834
+ const xHeaders = {};
835
+
836
+ return APIClient.execute(
837
+ this._conf,
838
+ "post",
839
+ constructUrl({
840
+ url: this._urls["checkoutCart"],
841
+ params: {},
842
+ }),
843
+ query_params,
844
+ body,
845
+ xHeaders
846
+ );
847
+ }
848
+
849
+ /**
850
+ * @param {Object} arg - Arg object.
851
+ * @param {string} [arg.id] -
852
+ * @param {boolean} [arg.buyNow] -
853
+ * @param {CartMetaRequest} arg.body
854
+ * @returns {Promise<CartMetaResponse>} - Success response
855
+ * @summary: Update the cart meta
856
+ * @description: Use this API to update cart meta like checkout_mode and gstin.
857
+ */
858
+ updateCartMeta({ body, id, buyNow } = {}) {
859
+ const { error } = CartValidator.updateCartMeta().validate(
860
+ { body, id, buyNow },
861
+ { abortEarly: false, allowUnknown: true }
862
+ );
863
+ if (error) {
864
+ return Promise.reject(new FDKClientValidationError(error));
865
+ }
866
+ const query_params = {};
867
+ query_params["id"] = id;
868
+ query_params["buy_now"] = buyNow;
869
+
870
+ const xHeaders = {};
871
+
872
+ return APIClient.execute(
873
+ this._conf,
874
+ "put",
875
+ constructUrl({
876
+ url: this._urls["updateCartMeta"],
877
+ params: {},
878
+ }),
879
+ query_params,
880
+ body,
881
+ xHeaders
882
+ );
883
+ }
884
+
885
+ /**
886
+ * @param {Object} arg - Arg object.
887
+ * @param {GetShareCartLinkRequest} arg.body
888
+ * @returns {Promise<GetShareCartLinkResponse>} - Success response
889
+ * @summary: Generate token for sharing the cart
890
+ * @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.
891
+ */
892
+ getCartShareLink({ body } = {}) {
893
+ const { error } = CartValidator.getCartShareLink().validate(
894
+ { body },
895
+ { abortEarly: false, allowUnknown: true }
896
+ );
897
+ if (error) {
898
+ return Promise.reject(new FDKClientValidationError(error));
899
+ }
900
+ const query_params = {};
901
+
902
+ const xHeaders = {};
903
+
904
+ return APIClient.execute(
905
+ this._conf,
906
+ "post",
907
+ constructUrl({
908
+ url: this._urls["getCartShareLink"],
909
+ params: {},
910
+ }),
911
+ query_params,
912
+ body,
913
+ xHeaders
914
+ );
915
+ }
916
+
917
+ /**
918
+ * @param {Object} arg - Arg object.
919
+ * @param {string} arg.token - Token of the shared short link
920
+ * @returns {Promise<SharedCartResponse>} - Success response
921
+ * @summary: Get details of a shared cart
922
+ * @description: Use this API to get the shared cart details as per the token generated using the share-cart API.
923
+ */
924
+ getCartSharedItems({ token } = {}) {
925
+ const { error } = CartValidator.getCartSharedItems().validate(
926
+ { token },
927
+ { abortEarly: false, allowUnknown: true }
928
+ );
929
+ if (error) {
930
+ return Promise.reject(new FDKClientValidationError(error));
931
+ }
932
+ const query_params = {};
933
+
934
+ const xHeaders = {};
935
+
936
+ return APIClient.execute(
937
+ this._conf,
938
+ "get",
939
+ constructUrl({
940
+ url: this._urls["getCartSharedItems"],
941
+ params: { token },
942
+ }),
943
+ query_params,
944
+ undefined,
945
+ xHeaders
946
+ );
947
+ }
948
+
949
+ /**
950
+ * @param {Object} arg - Arg object.
951
+ * @param {string} arg.token - Token of the shared short link
952
+ * @param {string} arg.action - Operation to perform on the existing cart
953
+ * merge or replace.
954
+ * @returns {Promise<SharedCartResponse>} - Success response
955
+ * @summary: Merge or replace existing cart
956
+ * @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.
957
+ */
958
+ updateCartWithSharedItems({ token, action } = {}) {
959
+ const { error } = CartValidator.updateCartWithSharedItems().validate(
960
+ { token, action },
961
+ { abortEarly: false, allowUnknown: true }
962
+ );
963
+ if (error) {
964
+ return Promise.reject(new FDKClientValidationError(error));
965
+ }
966
+ const query_params = {};
967
+
968
+ const xHeaders = {};
969
+
970
+ return APIClient.execute(
971
+ this._conf,
972
+ "post",
973
+ constructUrl({
974
+ url: this._urls["updateCartWithSharedItems"],
975
+ params: { token, action },
976
+ }),
977
+ query_params,
978
+ undefined,
979
+ xHeaders
980
+ );
981
+ }
982
+
983
+ /**
984
+ * @param {Object} arg - Arg object.
985
+ * @param {string} [arg.slug] - A short, human-readable, URL-friendly
986
+ * identifier of a product. You can get slug value from the endpoint
987
+ * /service/application/catalog/v1.0/products/
988
+ * @param {number} [arg.pageSize] - Number of offers to be fetched to show
989
+ * @param {string} [arg.promotionGroup] - Type of promotion groups
990
+ * @returns {Promise<PromotionOffersResponse>} - Success response
991
+ * @summary: Fetch available promotions
992
+ * @description: Use this API to get top 5 offers available for current product
993
+ */
994
+ getPromotionOffers({ slug, pageSize, promotionGroup } = {}) {
995
+ const { error } = CartValidator.getPromotionOffers().validate(
996
+ { slug, pageSize, promotionGroup },
997
+ { abortEarly: false, allowUnknown: true }
998
+ );
999
+ if (error) {
1000
+ return Promise.reject(new FDKClientValidationError(error));
1001
+ }
1002
+ const query_params = {};
1003
+ query_params["slug"] = slug;
1004
+ query_params["page_size"] = pageSize;
1005
+ query_params["promotion_group"] = promotionGroup;
1006
+
1007
+ const xHeaders = {};
1008
+
1009
+ return APIClient.execute(
1010
+ this._conf,
1011
+ "get",
1012
+ constructUrl({
1013
+ url: this._urls["getPromotionOffers"],
1014
+ params: {},
1015
+ }),
1016
+ query_params,
1017
+ undefined,
1018
+ xHeaders
1019
+ );
1020
+ }
1021
+
1022
+ /**
1023
+ * @param {Object} arg - Arg object.
1024
+ * @param {string} arg.slug - A short, human-readable, URL-friendly
1025
+ * identifier of a product. You can get slug value from the endpoint
1026
+ * /service/application/catalog/v1.0/products/
1027
+ * @param {string} [arg.storeId] - Store uid of assigned store on PDP page.
1028
+ * If not passed default first created ladder will be returned
1029
+ * @param {string} [arg.promotionId] - Get ladder information of given
1030
+ * promotion id explicitely
1031
+ * @param {number} [arg.pageSize] - Number of offers to be fetched to show
1032
+ * @returns {Promise<LadderPriceOffers>} - Success response
1033
+ * @summary: Fetch ladder price promotion
1034
+ * @description: Use this API to get applicable ladder price promotion for current product
1035
+ */
1036
+ getLadderOffers({ slug, storeId, promotionId, pageSize } = {}) {
1037
+ const { error } = CartValidator.getLadderOffers().validate(
1038
+ { slug, storeId, promotionId, pageSize },
1039
+ { abortEarly: false, allowUnknown: true }
1040
+ );
1041
+ if (error) {
1042
+ return Promise.reject(new FDKClientValidationError(error));
1043
+ }
1044
+ const query_params = {};
1045
+ query_params["slug"] = slug;
1046
+ query_params["store_id"] = storeId;
1047
+ query_params["promotion_id"] = promotionId;
1048
+ query_params["page_size"] = pageSize;
1049
+
1050
+ const xHeaders = {};
1051
+
1052
+ return APIClient.execute(
1053
+ this._conf,
1054
+ "get",
1055
+ constructUrl({
1056
+ url: this._urls["getLadderOffers"],
1057
+ params: {},
1058
+ }),
1059
+ query_params,
1060
+ undefined,
1061
+ xHeaders
1062
+ );
1063
+ }
1064
+ }
1065
+
1066
+ module.exports = Cart;