@gofynd/fdk-client-javascript 1.0.0 → 1.0.2
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.
- package/documentation/application/CART.md +251 -251
- package/documentation/application/CATALOG.md +393 -393
- package/documentation/application/CONTENT.md +15 -1
- package/documentation/application/ORDER.md +268 -268
- package/documentation/application/PAYMENT.md +249 -249
- package/documentation/application/POSCART.md +297 -297
- package/documentation/platform/CART.md +499 -499
- package/documentation/platform/CATALOG.md +3497 -3097
- package/documentation/platform/COMPANYPROFILE.md +207 -207
- package/documentation/platform/CONTENT.md +123 -1
- package/documentation/platform/ORDER.md +1518 -1324
- package/documentation/platform/PARTNER.md +7 -7
- package/documentation/platform/PAYMENT.md +96 -96
- package/index.js +7 -1
- package/package.json +1 -1
- package/sdk/application/ApplicationConfig.js +1 -1
- package/sdk/application/Cart/CartApplicationClient.js +865 -52
- package/sdk/application/Cart/CartApplicationModel.d.ts +7 -7
- package/sdk/application/Cart/CartApplicationModel.js +335 -335
- package/sdk/application/Cart/CartApplicationValidator.js +1 -0
- package/sdk/application/Catalog/CatalogApplicationClient.d.ts +1 -1
- package/sdk/application/Catalog/CatalogApplicationClient.js +1034 -60
- package/sdk/application/Catalog/CatalogApplicationModel.d.ts +19 -19
- package/sdk/application/Catalog/CatalogApplicationModel.js +532 -532
- package/sdk/application/Catalog/CatalogApplicationValidator.js +1 -0
- package/sdk/application/Common/CommonApplicationClient.js +66 -4
- package/sdk/application/Common/CommonApplicationValidator.js +1 -0
- package/sdk/application/Communication/CommunicationApplicationClient.js +108 -6
- package/sdk/application/Communication/CommunicationApplicationValidator.js +1 -0
- package/sdk/application/Configuration/ConfigurationApplicationClient.d.ts +1 -1
- package/sdk/application/Configuration/ConfigurationApplicationClient.js +558 -32
- package/sdk/application/Configuration/ConfigurationApplicationValidator.js +1 -0
- package/sdk/application/Content/ContentApplicationClient.js +621 -38
- package/sdk/application/Content/ContentApplicationModel.d.ts +1 -0
- package/sdk/application/Content/ContentApplicationModel.js +11 -1
- package/sdk/application/Content/ContentApplicationValidator.js +1 -0
- package/sdk/application/FileStorage/FileStorageApplicationClient.js +101 -6
- package/sdk/application/FileStorage/FileStorageApplicationValidator.js +1 -0
- package/sdk/application/Lead/LeadApplicationClient.js +229 -14
- package/sdk/application/Lead/LeadApplicationValidator.js +1 -0
- package/sdk/application/Logistic/LogisticApplicationClient.js +134 -8
- package/sdk/application/Logistic/LogisticApplicationValidator.js +1 -0
- package/sdk/application/Order/OrderApplicationClient.d.ts +1 -1
- package/sdk/application/Order/OrderApplicationClient.js +403 -24
- package/sdk/application/Order/OrderApplicationModel.d.ts +20 -20
- package/sdk/application/Order/OrderApplicationModel.js +334 -334
- package/sdk/application/Order/OrderApplicationValidator.js +1 -0
- package/sdk/application/Payment/PaymentApplicationClient.js +1381 -78
- package/sdk/application/Payment/PaymentApplicationModel.d.ts +2 -2
- package/sdk/application/Payment/PaymentApplicationModel.js +350 -350
- package/sdk/application/Payment/PaymentApplicationValidator.js +1 -0
- package/sdk/application/PosCart/PosCartApplicationClient.js +914 -54
- package/sdk/application/PosCart/PosCartApplicationModel.d.ts +15 -15
- package/sdk/application/PosCart/PosCartApplicationModel.js +389 -389
- package/sdk/application/PosCart/PosCartApplicationValidator.js +1 -0
- package/sdk/application/Rewards/RewardsApplicationClient.js +235 -14
- package/sdk/application/Rewards/RewardsApplicationValidator.js +1 -0
- package/sdk/application/Share/ShareApplicationClient.js +226 -14
- package/sdk/application/Share/ShareApplicationValidator.js +1 -0
- package/sdk/application/Theme/ThemeApplicationClient.js +130 -8
- package/sdk/application/Theme/ThemeApplicationValidator.js +1 -0
- package/sdk/application/User/UserApplicationClient.js +1133 -70
- package/sdk/application/User/UserApplicationValidator.js +1 -0
- package/sdk/common/AxiosHelper.js +1 -1
- package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.d.ts +16 -8
- package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.js +287 -16
- package/sdk/platform/Analytics/AnalyticsPlatformClient.d.ts +8 -4
- package/sdk/platform/Analytics/AnalyticsPlatformClient.js +153 -8
- package/sdk/platform/AuditTrail/AuditTrailPlatformClient.d.ts +8 -4
- package/sdk/platform/AuditTrail/AuditTrailPlatformClient.js +141 -8
- package/sdk/platform/Billing/BillingPlatformClient.d.ts +24 -12
- package/sdk/platform/Billing/BillingPlatformClient.js +429 -24
- package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +34 -17
- package/sdk/platform/Cart/CartPlatformApplicationClient.js +617 -34
- package/sdk/platform/Cart/CartPlatformModel.d.ts +35 -35
- package/sdk/platform/Cart/CartPlatformModel.js +617 -617
- package/sdk/platform/Catalog/CatalogPlatformApplicationClient.d.ts +191 -138
- package/sdk/platform/Catalog/CatalogPlatformApplicationClient.js +2202 -302
- package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.d.ts +11 -11
- package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.js +45 -45
- package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +344 -226
- package/sdk/platform/Catalog/CatalogPlatformClient.js +3282 -488
- package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +110 -100
- package/sdk/platform/Catalog/CatalogPlatformModel.js +2073 -1795
- package/sdk/platform/Catalog/CatalogPlatformValidator.d.ts +23 -21
- package/sdk/platform/Catalog/CatalogPlatformValidator.js +103 -84
- package/sdk/platform/Common/CommonPlatformClient.d.ts +4 -2
- package/sdk/platform/Common/CommonPlatformClient.js +73 -4
- package/sdk/platform/Communication/CommunicationPlatformApplicationClient.d.ts +80 -40
- package/sdk/platform/Communication/CommunicationPlatformApplicationClient.js +1499 -80
- package/sdk/platform/Communication/CommunicationPlatformClient.d.ts +2 -1
- package/sdk/platform/Communication/CommunicationPlatformClient.js +41 -2
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.d.ts +27 -14
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.js +486 -26
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.d.ts +9 -9
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.js +274 -274
- package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.d.ts +56 -28
- package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.js +1022 -56
- package/sdk/platform/Configuration/ConfigurationPlatformClient.d.ts +36 -18
- package/sdk/platform/Configuration/ConfigurationPlatformClient.js +693 -36
- package/sdk/platform/Content/ContentPlatformApplicationClient.d.ts +148 -67
- package/sdk/platform/Content/ContentPlatformApplicationClient.js +2446 -140
- package/sdk/platform/Content/ContentPlatformApplicationValidator.d.ts +1 -0
- package/sdk/platform/Content/ContentPlatformApplicationValidator.js +7 -0
- package/sdk/platform/Content/ContentPlatformModel.d.ts +4 -0
- package/sdk/platform/Content/ContentPlatformModel.js +43 -1
- package/sdk/platform/Discount/DiscountPlatformClient.d.ts +21 -10
- package/sdk/platform/Discount/DiscountPlatformClient.js +400 -22
- package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.d.ts +8 -4
- package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.js +148 -8
- package/sdk/platform/FileStorage/FileStoragePlatformClient.d.ts +12 -6
- package/sdk/platform/FileStorage/FileStoragePlatformClient.js +214 -12
- package/sdk/platform/Inventory/InventoryPlatformClient.d.ts +27 -14
- package/sdk/platform/Inventory/InventoryPlatformClient.js +449 -24
- package/sdk/platform/Lead/LeadPlatformApplicationClient.d.ts +26 -13
- package/sdk/platform/Lead/LeadPlatformApplicationClient.js +447 -26
- package/sdk/platform/Lead/LeadPlatformClient.d.ts +22 -11
- package/sdk/platform/Lead/LeadPlatformClient.js +384 -22
- package/sdk/platform/OAuthClient.js +8 -8
- package/sdk/platform/Order/OrderPlatformApplicationClient.d.ts +6 -3
- package/sdk/platform/Order/OrderPlatformApplicationClient.js +125 -6
- package/sdk/platform/Order/OrderPlatformClient.d.ts +108 -47
- package/sdk/platform/Order/OrderPlatformClient.js +1641 -100
- package/sdk/platform/Order/OrderPlatformModel.d.ts +69 -58
- package/sdk/platform/Order/OrderPlatformModel.js +1485 -1493
- package/sdk/platform/Order/OrderPlatformValidator.d.ts +2 -1
- package/sdk/platform/Order/OrderPlatformValidator.js +15 -4
- package/sdk/platform/Partner/PartnerPlatformApplicationClient.d.ts +4 -2
- package/sdk/platform/Partner/PartnerPlatformApplicationClient.js +74 -4
- package/sdk/platform/Partner/PartnerPlatformModel.d.ts +1 -1
- package/sdk/platform/Partner/PartnerPlatformModel.js +8 -8
- package/sdk/platform/Payment/PaymentPlatformApplicationClient.d.ts +22 -11
- package/sdk/platform/Payment/PaymentPlatformApplicationClient.js +418 -22
- package/sdk/platform/Payment/PaymentPlatformClient.d.ts +21 -11
- package/sdk/platform/Payment/PaymentPlatformClient.js +374 -20
- package/sdk/platform/Payment/PaymentPlatformModel.js +139 -139
- package/sdk/platform/PlatformApplicationClient.d.ts +2973 -2827
- package/sdk/platform/PlatformApplicationClient.js +3461 -3263
- package/sdk/platform/PlatformClient.d.ts +2973 -2827
- package/sdk/platform/PlatformClient.js +3461 -3263
- package/sdk/platform/Rewards/RewardsPlatformApplicationClient.d.ts +26 -13
- package/sdk/platform/Rewards/RewardsPlatformApplicationClient.js +449 -26
- package/sdk/platform/Share/SharePlatformApplicationClient.d.ts +8 -4
- package/sdk/platform/Share/SharePlatformApplicationClient.js +139 -8
- package/sdk/platform/Theme/ThemePlatformApplicationClient.d.ts +47 -23
- package/sdk/platform/Theme/ThemePlatformApplicationClient.js +816 -48
- package/sdk/platform/User/UserPlatformApplicationClient.d.ts +24 -12
- package/sdk/platform/User/UserPlatformApplicationClient.js +417 -24
- package/sdk/platform/Webhook/WebhookPlatformClient.d.ts +12 -6
- package/sdk/platform/Webhook/WebhookPlatformClient.js +229 -12
- package/sdk/public/Configuration/ConfigurationPublicClient.js +72 -4
- package/sdk/public/Configuration/ConfigurationPublicValidator.js +3 -1
- package/sdk/public/Inventory/InventoryPublicClient.js +210 -12
- package/sdk/public/Inventory/InventoryPublicValidator.js +3 -1
- package/sdk/public/Webhook/WebhookPublicClient.js +74 -4
- package/sdk/public/Webhook/WebhookPublicValidator.js +3 -1
|
@@ -3,6 +3,8 @@ const constructUrl = require("../constructUrl");
|
|
|
3
3
|
const Paginator = require("../../common/Paginator");
|
|
4
4
|
const { FDKClientValidationError } = require("../../common/FDKError");
|
|
5
5
|
const CartValidator = require("./CartApplicationValidator");
|
|
6
|
+
const CartModel = require("./CartApplicationModel");
|
|
7
|
+
const { Logger } = require("./../../common/Logger");
|
|
6
8
|
|
|
7
9
|
class Cart {
|
|
8
10
|
constructor(_conf) {
|
|
@@ -65,7 +67,7 @@ class Cart {
|
|
|
65
67
|
* @summary: Fetch all items added to the cart
|
|
66
68
|
* @description: Use this API to get details of all the items added to a cart.
|
|
67
69
|
*/
|
|
68
|
-
getCart({ id, i, b, assignCardId, areaCode, buyNow } = {}) {
|
|
70
|
+
async getCart({ id, i, b, assignCardId, areaCode, buyNow } = {}) {
|
|
69
71
|
const { error } = CartValidator.getCart().validate(
|
|
70
72
|
{ id, i, b, assignCardId, areaCode, buyNow },
|
|
71
73
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -73,6 +75,20 @@ class Cart {
|
|
|
73
75
|
if (error) {
|
|
74
76
|
return Promise.reject(new FDKClientValidationError(error));
|
|
75
77
|
}
|
|
78
|
+
|
|
79
|
+
// Showing warrnings if extra unknown parameters are found
|
|
80
|
+
const { error: warrning } = CartValidator.getCart().validate(
|
|
81
|
+
{ id, i, b, assignCardId, areaCode, buyNow },
|
|
82
|
+
{ abortEarly: false, allowUnknown: false }
|
|
83
|
+
);
|
|
84
|
+
if (warrning) {
|
|
85
|
+
Logger({
|
|
86
|
+
level: "WARN",
|
|
87
|
+
message: "Parameter Validation warrnings for getCart",
|
|
88
|
+
});
|
|
89
|
+
Logger({ level: "WARN", message: warrning });
|
|
90
|
+
}
|
|
91
|
+
|
|
76
92
|
const query_params = {};
|
|
77
93
|
query_params["id"] = id;
|
|
78
94
|
query_params["i"] = i;
|
|
@@ -83,7 +99,7 @@ class Cart {
|
|
|
83
99
|
|
|
84
100
|
const xHeaders = {};
|
|
85
101
|
|
|
86
|
-
|
|
102
|
+
const response = await APIClient.execute(
|
|
87
103
|
this._conf,
|
|
88
104
|
"get",
|
|
89
105
|
constructUrl({
|
|
@@ -94,6 +110,23 @@ class Cart {
|
|
|
94
110
|
undefined,
|
|
95
111
|
xHeaders
|
|
96
112
|
);
|
|
113
|
+
|
|
114
|
+
const {
|
|
115
|
+
error: res_error,
|
|
116
|
+
} = CartModel.CartDetailResponse().validate(response, {
|
|
117
|
+
abortEarly: false,
|
|
118
|
+
allowUnknown: false,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (res_error) {
|
|
122
|
+
Logger({
|
|
123
|
+
level: "WARN",
|
|
124
|
+
message: "Response Validation Warnnings for getCart",
|
|
125
|
+
});
|
|
126
|
+
Logger({ level: "WARN", message: res_error });
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return response;
|
|
97
130
|
}
|
|
98
131
|
|
|
99
132
|
/**
|
|
@@ -103,7 +136,7 @@ class Cart {
|
|
|
103
136
|
* @summary: Fetch last-modified timestamp
|
|
104
137
|
* @description: Use this API to fetch Last-Modified timestamp in header metadata.
|
|
105
138
|
*/
|
|
106
|
-
getCartLastModified({ id } = {}) {
|
|
139
|
+
async getCartLastModified({ id } = {}) {
|
|
107
140
|
const { error } = CartValidator.getCartLastModified().validate(
|
|
108
141
|
{ id },
|
|
109
142
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -111,12 +144,26 @@ class Cart {
|
|
|
111
144
|
if (error) {
|
|
112
145
|
return Promise.reject(new FDKClientValidationError(error));
|
|
113
146
|
}
|
|
147
|
+
|
|
148
|
+
// Showing warrnings if extra unknown parameters are found
|
|
149
|
+
const { error: warrning } = CartValidator.getCartLastModified().validate(
|
|
150
|
+
{ id },
|
|
151
|
+
{ abortEarly: false, allowUnknown: false }
|
|
152
|
+
);
|
|
153
|
+
if (warrning) {
|
|
154
|
+
Logger({
|
|
155
|
+
level: "WARN",
|
|
156
|
+
message: "Parameter Validation warrnings for getCartLastModified",
|
|
157
|
+
});
|
|
158
|
+
Logger({ level: "WARN", message: warrning });
|
|
159
|
+
}
|
|
160
|
+
|
|
114
161
|
const query_params = {};
|
|
115
162
|
query_params["id"] = id;
|
|
116
163
|
|
|
117
164
|
const xHeaders = {};
|
|
118
165
|
|
|
119
|
-
|
|
166
|
+
const response = await APIClient.execute(
|
|
120
167
|
this._conf,
|
|
121
168
|
"head",
|
|
122
169
|
constructUrl({
|
|
@@ -127,6 +174,20 @@ class Cart {
|
|
|
127
174
|
undefined,
|
|
128
175
|
xHeaders
|
|
129
176
|
);
|
|
177
|
+
|
|
178
|
+
const { error: res_error } = Joi.string()
|
|
179
|
+
.allow("")
|
|
180
|
+
.validate(response, { abortEarly: false, allowUnknown: false });
|
|
181
|
+
|
|
182
|
+
if (res_error) {
|
|
183
|
+
Logger({
|
|
184
|
+
level: "WARN",
|
|
185
|
+
message: "Response Validation Warnnings for getCartLastModified",
|
|
186
|
+
});
|
|
187
|
+
Logger({ level: "WARN", message: res_error });
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return response;
|
|
130
191
|
}
|
|
131
192
|
|
|
132
193
|
/**
|
|
@@ -140,7 +201,7 @@ class Cart {
|
|
|
140
201
|
* @summary: Add items to cart
|
|
141
202
|
* @description: Use this API to add items to the cart.
|
|
142
203
|
*/
|
|
143
|
-
addItems({ body, i, b, areaCode, buyNow } = {}) {
|
|
204
|
+
async addItems({ body, i, b, areaCode, buyNow } = {}) {
|
|
144
205
|
const { error } = CartValidator.addItems().validate(
|
|
145
206
|
{ body, i, b, areaCode, buyNow },
|
|
146
207
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -148,6 +209,20 @@ class Cart {
|
|
|
148
209
|
if (error) {
|
|
149
210
|
return Promise.reject(new FDKClientValidationError(error));
|
|
150
211
|
}
|
|
212
|
+
|
|
213
|
+
// Showing warrnings if extra unknown parameters are found
|
|
214
|
+
const { error: warrning } = CartValidator.addItems().validate(
|
|
215
|
+
{ body, i, b, areaCode, buyNow },
|
|
216
|
+
{ abortEarly: false, allowUnknown: false }
|
|
217
|
+
);
|
|
218
|
+
if (warrning) {
|
|
219
|
+
Logger({
|
|
220
|
+
level: "WARN",
|
|
221
|
+
message: "Parameter Validation warrnings for addItems",
|
|
222
|
+
});
|
|
223
|
+
Logger({ level: "WARN", message: warrning });
|
|
224
|
+
}
|
|
225
|
+
|
|
151
226
|
const query_params = {};
|
|
152
227
|
query_params["i"] = i;
|
|
153
228
|
query_params["b"] = b;
|
|
@@ -156,7 +231,7 @@ class Cart {
|
|
|
156
231
|
|
|
157
232
|
const xHeaders = {};
|
|
158
233
|
|
|
159
|
-
|
|
234
|
+
const response = await APIClient.execute(
|
|
160
235
|
this._conf,
|
|
161
236
|
"post",
|
|
162
237
|
constructUrl({
|
|
@@ -167,6 +242,23 @@ class Cart {
|
|
|
167
242
|
body,
|
|
168
243
|
xHeaders
|
|
169
244
|
);
|
|
245
|
+
|
|
246
|
+
const {
|
|
247
|
+
error: res_error,
|
|
248
|
+
} = CartModel.AddCartDetailResponse().validate(response, {
|
|
249
|
+
abortEarly: false,
|
|
250
|
+
allowUnknown: false,
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
if (res_error) {
|
|
254
|
+
Logger({
|
|
255
|
+
level: "WARN",
|
|
256
|
+
message: "Response Validation Warnnings for addItems",
|
|
257
|
+
});
|
|
258
|
+
Logger({ level: "WARN", message: res_error });
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return response;
|
|
170
262
|
}
|
|
171
263
|
|
|
172
264
|
/**
|
|
@@ -181,7 +273,7 @@ class Cart {
|
|
|
181
273
|
* @summary: Update items in the cart
|
|
182
274
|
* @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>
|
|
183
275
|
*/
|
|
184
|
-
updateCart({ body, id, i, b, areaCode, buyNow } = {}) {
|
|
276
|
+
async updateCart({ body, id, i, b, areaCode, buyNow } = {}) {
|
|
185
277
|
const { error } = CartValidator.updateCart().validate(
|
|
186
278
|
{ body, id, i, b, areaCode, buyNow },
|
|
187
279
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -189,6 +281,20 @@ class Cart {
|
|
|
189
281
|
if (error) {
|
|
190
282
|
return Promise.reject(new FDKClientValidationError(error));
|
|
191
283
|
}
|
|
284
|
+
|
|
285
|
+
// Showing warrnings if extra unknown parameters are found
|
|
286
|
+
const { error: warrning } = CartValidator.updateCart().validate(
|
|
287
|
+
{ body, id, i, b, areaCode, buyNow },
|
|
288
|
+
{ abortEarly: false, allowUnknown: false }
|
|
289
|
+
);
|
|
290
|
+
if (warrning) {
|
|
291
|
+
Logger({
|
|
292
|
+
level: "WARN",
|
|
293
|
+
message: "Parameter Validation warrnings for updateCart",
|
|
294
|
+
});
|
|
295
|
+
Logger({ level: "WARN", message: warrning });
|
|
296
|
+
}
|
|
297
|
+
|
|
192
298
|
const query_params = {};
|
|
193
299
|
query_params["id"] = id;
|
|
194
300
|
query_params["i"] = i;
|
|
@@ -198,7 +304,7 @@ class Cart {
|
|
|
198
304
|
|
|
199
305
|
const xHeaders = {};
|
|
200
306
|
|
|
201
|
-
|
|
307
|
+
const response = await APIClient.execute(
|
|
202
308
|
this._conf,
|
|
203
309
|
"put",
|
|
204
310
|
constructUrl({
|
|
@@ -209,6 +315,23 @@ class Cart {
|
|
|
209
315
|
body,
|
|
210
316
|
xHeaders
|
|
211
317
|
);
|
|
318
|
+
|
|
319
|
+
const {
|
|
320
|
+
error: res_error,
|
|
321
|
+
} = CartModel.UpdateCartDetailResponse().validate(response, {
|
|
322
|
+
abortEarly: false,
|
|
323
|
+
allowUnknown: false,
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
if (res_error) {
|
|
327
|
+
Logger({
|
|
328
|
+
level: "WARN",
|
|
329
|
+
message: "Response Validation Warnnings for updateCart",
|
|
330
|
+
});
|
|
331
|
+
Logger({ level: "WARN", message: res_error });
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return response;
|
|
212
335
|
}
|
|
213
336
|
|
|
214
337
|
/**
|
|
@@ -219,7 +342,7 @@ class Cart {
|
|
|
219
342
|
* @summary: Count items in the cart
|
|
220
343
|
* @description: Use this API to get the total number of items present in cart.
|
|
221
344
|
*/
|
|
222
|
-
getItemCount({ id, buyNow } = {}) {
|
|
345
|
+
async getItemCount({ id, buyNow } = {}) {
|
|
223
346
|
const { error } = CartValidator.getItemCount().validate(
|
|
224
347
|
{ id, buyNow },
|
|
225
348
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -227,13 +350,27 @@ class Cart {
|
|
|
227
350
|
if (error) {
|
|
228
351
|
return Promise.reject(new FDKClientValidationError(error));
|
|
229
352
|
}
|
|
353
|
+
|
|
354
|
+
// Showing warrnings if extra unknown parameters are found
|
|
355
|
+
const { error: warrning } = CartValidator.getItemCount().validate(
|
|
356
|
+
{ id, buyNow },
|
|
357
|
+
{ abortEarly: false, allowUnknown: false }
|
|
358
|
+
);
|
|
359
|
+
if (warrning) {
|
|
360
|
+
Logger({
|
|
361
|
+
level: "WARN",
|
|
362
|
+
message: "Parameter Validation warrnings for getItemCount",
|
|
363
|
+
});
|
|
364
|
+
Logger({ level: "WARN", message: warrning });
|
|
365
|
+
}
|
|
366
|
+
|
|
230
367
|
const query_params = {};
|
|
231
368
|
query_params["id"] = id;
|
|
232
369
|
query_params["buy_now"] = buyNow;
|
|
233
370
|
|
|
234
371
|
const xHeaders = {};
|
|
235
372
|
|
|
236
|
-
|
|
373
|
+
const response = await APIClient.execute(
|
|
237
374
|
this._conf,
|
|
238
375
|
"get",
|
|
239
376
|
constructUrl({
|
|
@@ -244,6 +381,23 @@ class Cart {
|
|
|
244
381
|
undefined,
|
|
245
382
|
xHeaders
|
|
246
383
|
);
|
|
384
|
+
|
|
385
|
+
const {
|
|
386
|
+
error: res_error,
|
|
387
|
+
} = CartModel.CartItemCountResponse().validate(response, {
|
|
388
|
+
abortEarly: false,
|
|
389
|
+
allowUnknown: false,
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
if (res_error) {
|
|
393
|
+
Logger({
|
|
394
|
+
level: "WARN",
|
|
395
|
+
message: "Response Validation Warnnings for getItemCount",
|
|
396
|
+
});
|
|
397
|
+
Logger({ level: "WARN", message: res_error });
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return response;
|
|
247
401
|
}
|
|
248
402
|
|
|
249
403
|
/**
|
|
@@ -254,7 +408,7 @@ class Cart {
|
|
|
254
408
|
* @summary: Fetch Coupon
|
|
255
409
|
* @description: Use this API to get a list of available coupons along with their details.
|
|
256
410
|
*/
|
|
257
|
-
getCoupons({ id, buyNow } = {}) {
|
|
411
|
+
async getCoupons({ id, buyNow } = {}) {
|
|
258
412
|
const { error } = CartValidator.getCoupons().validate(
|
|
259
413
|
{ id, buyNow },
|
|
260
414
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -262,13 +416,27 @@ class Cart {
|
|
|
262
416
|
if (error) {
|
|
263
417
|
return Promise.reject(new FDKClientValidationError(error));
|
|
264
418
|
}
|
|
419
|
+
|
|
420
|
+
// Showing warrnings if extra unknown parameters are found
|
|
421
|
+
const { error: warrning } = CartValidator.getCoupons().validate(
|
|
422
|
+
{ id, buyNow },
|
|
423
|
+
{ abortEarly: false, allowUnknown: false }
|
|
424
|
+
);
|
|
425
|
+
if (warrning) {
|
|
426
|
+
Logger({
|
|
427
|
+
level: "WARN",
|
|
428
|
+
message: "Parameter Validation warrnings for getCoupons",
|
|
429
|
+
});
|
|
430
|
+
Logger({ level: "WARN", message: warrning });
|
|
431
|
+
}
|
|
432
|
+
|
|
265
433
|
const query_params = {};
|
|
266
434
|
query_params["id"] = id;
|
|
267
435
|
query_params["buy_now"] = buyNow;
|
|
268
436
|
|
|
269
437
|
const xHeaders = {};
|
|
270
438
|
|
|
271
|
-
|
|
439
|
+
const response = await APIClient.execute(
|
|
272
440
|
this._conf,
|
|
273
441
|
"get",
|
|
274
442
|
constructUrl({
|
|
@@ -279,6 +447,23 @@ class Cart {
|
|
|
279
447
|
undefined,
|
|
280
448
|
xHeaders
|
|
281
449
|
);
|
|
450
|
+
|
|
451
|
+
const {
|
|
452
|
+
error: res_error,
|
|
453
|
+
} = CartModel.GetCouponResponse().validate(response, {
|
|
454
|
+
abortEarly: false,
|
|
455
|
+
allowUnknown: false,
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
if (res_error) {
|
|
459
|
+
Logger({
|
|
460
|
+
level: "WARN",
|
|
461
|
+
message: "Response Validation Warnnings for getCoupons",
|
|
462
|
+
});
|
|
463
|
+
Logger({ level: "WARN", message: res_error });
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return response;
|
|
282
467
|
}
|
|
283
468
|
|
|
284
469
|
/**
|
|
@@ -293,7 +478,7 @@ class Cart {
|
|
|
293
478
|
* @summary: Apply Coupon
|
|
294
479
|
* @description: Use this API to apply coupons on items in the cart.
|
|
295
480
|
*/
|
|
296
|
-
applyCoupon({ body, i, b, p, id, buyNow } = {}) {
|
|
481
|
+
async applyCoupon({ body, i, b, p, id, buyNow } = {}) {
|
|
297
482
|
const { error } = CartValidator.applyCoupon().validate(
|
|
298
483
|
{ body, i, b, p, id, buyNow },
|
|
299
484
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -301,6 +486,20 @@ class Cart {
|
|
|
301
486
|
if (error) {
|
|
302
487
|
return Promise.reject(new FDKClientValidationError(error));
|
|
303
488
|
}
|
|
489
|
+
|
|
490
|
+
// Showing warrnings if extra unknown parameters are found
|
|
491
|
+
const { error: warrning } = CartValidator.applyCoupon().validate(
|
|
492
|
+
{ body, i, b, p, id, buyNow },
|
|
493
|
+
{ abortEarly: false, allowUnknown: false }
|
|
494
|
+
);
|
|
495
|
+
if (warrning) {
|
|
496
|
+
Logger({
|
|
497
|
+
level: "WARN",
|
|
498
|
+
message: "Parameter Validation warrnings for applyCoupon",
|
|
499
|
+
});
|
|
500
|
+
Logger({ level: "WARN", message: warrning });
|
|
501
|
+
}
|
|
502
|
+
|
|
304
503
|
const query_params = {};
|
|
305
504
|
query_params["i"] = i;
|
|
306
505
|
query_params["b"] = b;
|
|
@@ -310,7 +509,7 @@ class Cart {
|
|
|
310
509
|
|
|
311
510
|
const xHeaders = {};
|
|
312
511
|
|
|
313
|
-
|
|
512
|
+
const response = await APIClient.execute(
|
|
314
513
|
this._conf,
|
|
315
514
|
"post",
|
|
316
515
|
constructUrl({
|
|
@@ -321,6 +520,23 @@ class Cart {
|
|
|
321
520
|
body,
|
|
322
521
|
xHeaders
|
|
323
522
|
);
|
|
523
|
+
|
|
524
|
+
const {
|
|
525
|
+
error: res_error,
|
|
526
|
+
} = CartModel.CartDetailResponse().validate(response, {
|
|
527
|
+
abortEarly: false,
|
|
528
|
+
allowUnknown: false,
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
if (res_error) {
|
|
532
|
+
Logger({
|
|
533
|
+
level: "WARN",
|
|
534
|
+
message: "Response Validation Warnnings for applyCoupon",
|
|
535
|
+
});
|
|
536
|
+
Logger({ level: "WARN", message: res_error });
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
return response;
|
|
324
540
|
}
|
|
325
541
|
|
|
326
542
|
/**
|
|
@@ -331,7 +547,7 @@ class Cart {
|
|
|
331
547
|
* @summary: Remove Coupon Applied
|
|
332
548
|
* @description: Remove Coupon applied on the cart by passing uid in request body.
|
|
333
549
|
*/
|
|
334
|
-
removeCoupon({ id, buyNow } = {}) {
|
|
550
|
+
async removeCoupon({ id, buyNow } = {}) {
|
|
335
551
|
const { error } = CartValidator.removeCoupon().validate(
|
|
336
552
|
{ id, buyNow },
|
|
337
553
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -339,13 +555,27 @@ class Cart {
|
|
|
339
555
|
if (error) {
|
|
340
556
|
return Promise.reject(new FDKClientValidationError(error));
|
|
341
557
|
}
|
|
558
|
+
|
|
559
|
+
// Showing warrnings if extra unknown parameters are found
|
|
560
|
+
const { error: warrning } = CartValidator.removeCoupon().validate(
|
|
561
|
+
{ id, buyNow },
|
|
562
|
+
{ abortEarly: false, allowUnknown: false }
|
|
563
|
+
);
|
|
564
|
+
if (warrning) {
|
|
565
|
+
Logger({
|
|
566
|
+
level: "WARN",
|
|
567
|
+
message: "Parameter Validation warrnings for removeCoupon",
|
|
568
|
+
});
|
|
569
|
+
Logger({ level: "WARN", message: warrning });
|
|
570
|
+
}
|
|
571
|
+
|
|
342
572
|
const query_params = {};
|
|
343
573
|
query_params["id"] = id;
|
|
344
574
|
query_params["buy_now"] = buyNow;
|
|
345
575
|
|
|
346
576
|
const xHeaders = {};
|
|
347
577
|
|
|
348
|
-
|
|
578
|
+
const response = await APIClient.execute(
|
|
349
579
|
this._conf,
|
|
350
580
|
"delete",
|
|
351
581
|
constructUrl({
|
|
@@ -356,6 +586,23 @@ class Cart {
|
|
|
356
586
|
undefined,
|
|
357
587
|
xHeaders
|
|
358
588
|
);
|
|
589
|
+
|
|
590
|
+
const {
|
|
591
|
+
error: res_error,
|
|
592
|
+
} = CartModel.CartDetailResponse().validate(response, {
|
|
593
|
+
abortEarly: false,
|
|
594
|
+
allowUnknown: false,
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
if (res_error) {
|
|
598
|
+
Logger({
|
|
599
|
+
level: "WARN",
|
|
600
|
+
message: "Response Validation Warnnings for removeCoupon",
|
|
601
|
+
});
|
|
602
|
+
Logger({ level: "WARN", message: res_error });
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
return response;
|
|
359
606
|
}
|
|
360
607
|
|
|
361
608
|
/**
|
|
@@ -370,7 +617,7 @@ class Cart {
|
|
|
370
617
|
* @summary: Get discount offers based on quantity
|
|
371
618
|
* @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.
|
|
372
619
|
*/
|
|
373
|
-
getBulkDiscountOffers({ itemId, articleId, uid, slug } = {}) {
|
|
620
|
+
async getBulkDiscountOffers({ itemId, articleId, uid, slug } = {}) {
|
|
374
621
|
const { error } = CartValidator.getBulkDiscountOffers().validate(
|
|
375
622
|
{ itemId, articleId, uid, slug },
|
|
376
623
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -378,6 +625,20 @@ class Cart {
|
|
|
378
625
|
if (error) {
|
|
379
626
|
return Promise.reject(new FDKClientValidationError(error));
|
|
380
627
|
}
|
|
628
|
+
|
|
629
|
+
// Showing warrnings if extra unknown parameters are found
|
|
630
|
+
const { error: warrning } = CartValidator.getBulkDiscountOffers().validate(
|
|
631
|
+
{ itemId, articleId, uid, slug },
|
|
632
|
+
{ abortEarly: false, allowUnknown: false }
|
|
633
|
+
);
|
|
634
|
+
if (warrning) {
|
|
635
|
+
Logger({
|
|
636
|
+
level: "WARN",
|
|
637
|
+
message: "Parameter Validation warrnings for getBulkDiscountOffers",
|
|
638
|
+
});
|
|
639
|
+
Logger({ level: "WARN", message: warrning });
|
|
640
|
+
}
|
|
641
|
+
|
|
381
642
|
const query_params = {};
|
|
382
643
|
query_params["item_id"] = itemId;
|
|
383
644
|
query_params["article_id"] = articleId;
|
|
@@ -386,7 +647,7 @@ class Cart {
|
|
|
386
647
|
|
|
387
648
|
const xHeaders = {};
|
|
388
649
|
|
|
389
|
-
|
|
650
|
+
const response = await APIClient.execute(
|
|
390
651
|
this._conf,
|
|
391
652
|
"get",
|
|
392
653
|
constructUrl({
|
|
@@ -397,6 +658,23 @@ class Cart {
|
|
|
397
658
|
undefined,
|
|
398
659
|
xHeaders
|
|
399
660
|
);
|
|
661
|
+
|
|
662
|
+
const {
|
|
663
|
+
error: res_error,
|
|
664
|
+
} = CartModel.BulkPriceResponse().validate(response, {
|
|
665
|
+
abortEarly: false,
|
|
666
|
+
allowUnknown: false,
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
if (res_error) {
|
|
670
|
+
Logger({
|
|
671
|
+
level: "WARN",
|
|
672
|
+
message: "Response Validation Warnnings for getBulkDiscountOffers",
|
|
673
|
+
});
|
|
674
|
+
Logger({ level: "WARN", message: res_error });
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
return response;
|
|
400
678
|
}
|
|
401
679
|
|
|
402
680
|
/**
|
|
@@ -410,7 +688,7 @@ class Cart {
|
|
|
410
688
|
* @summary: Apply reward points at cart
|
|
411
689
|
* @description: Use this API to redeem a fixed no. of reward points by applying it to the cart.
|
|
412
690
|
*/
|
|
413
|
-
applyRewardPoints({ body, id, i, b, buyNow } = {}) {
|
|
691
|
+
async applyRewardPoints({ body, id, i, b, buyNow } = {}) {
|
|
414
692
|
const { error } = CartValidator.applyRewardPoints().validate(
|
|
415
693
|
{ body, id, i, b, buyNow },
|
|
416
694
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -418,6 +696,20 @@ class Cart {
|
|
|
418
696
|
if (error) {
|
|
419
697
|
return Promise.reject(new FDKClientValidationError(error));
|
|
420
698
|
}
|
|
699
|
+
|
|
700
|
+
// Showing warrnings if extra unknown parameters are found
|
|
701
|
+
const { error: warrning } = CartValidator.applyRewardPoints().validate(
|
|
702
|
+
{ body, id, i, b, buyNow },
|
|
703
|
+
{ abortEarly: false, allowUnknown: false }
|
|
704
|
+
);
|
|
705
|
+
if (warrning) {
|
|
706
|
+
Logger({
|
|
707
|
+
level: "WARN",
|
|
708
|
+
message: "Parameter Validation warrnings for applyRewardPoints",
|
|
709
|
+
});
|
|
710
|
+
Logger({ level: "WARN", message: warrning });
|
|
711
|
+
}
|
|
712
|
+
|
|
421
713
|
const query_params = {};
|
|
422
714
|
query_params["id"] = id;
|
|
423
715
|
query_params["i"] = i;
|
|
@@ -426,7 +718,7 @@ class Cart {
|
|
|
426
718
|
|
|
427
719
|
const xHeaders = {};
|
|
428
720
|
|
|
429
|
-
|
|
721
|
+
const response = await APIClient.execute(
|
|
430
722
|
this._conf,
|
|
431
723
|
"post",
|
|
432
724
|
constructUrl({
|
|
@@ -437,6 +729,23 @@ class Cart {
|
|
|
437
729
|
body,
|
|
438
730
|
xHeaders
|
|
439
731
|
);
|
|
732
|
+
|
|
733
|
+
const {
|
|
734
|
+
error: res_error,
|
|
735
|
+
} = CartModel.CartDetailResponse().validate(response, {
|
|
736
|
+
abortEarly: false,
|
|
737
|
+
allowUnknown: false,
|
|
738
|
+
});
|
|
739
|
+
|
|
740
|
+
if (res_error) {
|
|
741
|
+
Logger({
|
|
742
|
+
level: "WARN",
|
|
743
|
+
message: "Response Validation Warnnings for applyRewardPoints",
|
|
744
|
+
});
|
|
745
|
+
Logger({ level: "WARN", message: res_error });
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
return response;
|
|
440
749
|
}
|
|
441
750
|
|
|
442
751
|
/**
|
|
@@ -451,7 +760,7 @@ class Cart {
|
|
|
451
760
|
* @summary: Fetch address
|
|
452
761
|
* @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>
|
|
453
762
|
*/
|
|
454
|
-
getAddresses({
|
|
763
|
+
async getAddresses({
|
|
455
764
|
cartId,
|
|
456
765
|
buyNow,
|
|
457
766
|
mobileNo,
|
|
@@ -466,6 +775,20 @@ class Cart {
|
|
|
466
775
|
if (error) {
|
|
467
776
|
return Promise.reject(new FDKClientValidationError(error));
|
|
468
777
|
}
|
|
778
|
+
|
|
779
|
+
// Showing warrnings if extra unknown parameters are found
|
|
780
|
+
const { error: warrning } = CartValidator.getAddresses().validate(
|
|
781
|
+
{ cartId, buyNow, mobileNo, checkoutMode, tags, isDefault },
|
|
782
|
+
{ abortEarly: false, allowUnknown: false }
|
|
783
|
+
);
|
|
784
|
+
if (warrning) {
|
|
785
|
+
Logger({
|
|
786
|
+
level: "WARN",
|
|
787
|
+
message: "Parameter Validation warrnings for getAddresses",
|
|
788
|
+
});
|
|
789
|
+
Logger({ level: "WARN", message: warrning });
|
|
790
|
+
}
|
|
791
|
+
|
|
469
792
|
const query_params = {};
|
|
470
793
|
query_params["cart_id"] = cartId;
|
|
471
794
|
query_params["buy_now"] = buyNow;
|
|
@@ -476,7 +799,7 @@ class Cart {
|
|
|
476
799
|
|
|
477
800
|
const xHeaders = {};
|
|
478
801
|
|
|
479
|
-
|
|
802
|
+
const response = await APIClient.execute(
|
|
480
803
|
this._conf,
|
|
481
804
|
"get",
|
|
482
805
|
constructUrl({
|
|
@@ -487,6 +810,23 @@ class Cart {
|
|
|
487
810
|
undefined,
|
|
488
811
|
xHeaders
|
|
489
812
|
);
|
|
813
|
+
|
|
814
|
+
const {
|
|
815
|
+
error: res_error,
|
|
816
|
+
} = CartModel.GetAddressesResponse().validate(response, {
|
|
817
|
+
abortEarly: false,
|
|
818
|
+
allowUnknown: false,
|
|
819
|
+
});
|
|
820
|
+
|
|
821
|
+
if (res_error) {
|
|
822
|
+
Logger({
|
|
823
|
+
level: "WARN",
|
|
824
|
+
message: "Response Validation Warnnings for getAddresses",
|
|
825
|
+
});
|
|
826
|
+
Logger({ level: "WARN", message: res_error });
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
return response;
|
|
490
830
|
}
|
|
491
831
|
|
|
492
832
|
/**
|
|
@@ -496,7 +836,7 @@ class Cart {
|
|
|
496
836
|
* @summary: Add address to an account
|
|
497
837
|
* @description: Use this API to add an address to an account.
|
|
498
838
|
*/
|
|
499
|
-
addAddress({ body } = {}) {
|
|
839
|
+
async addAddress({ body } = {}) {
|
|
500
840
|
const { error } = CartValidator.addAddress().validate(
|
|
501
841
|
{ body },
|
|
502
842
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -504,11 +844,25 @@ class Cart {
|
|
|
504
844
|
if (error) {
|
|
505
845
|
return Promise.reject(new FDKClientValidationError(error));
|
|
506
846
|
}
|
|
847
|
+
|
|
848
|
+
// Showing warrnings if extra unknown parameters are found
|
|
849
|
+
const { error: warrning } = CartValidator.addAddress().validate(
|
|
850
|
+
{ body },
|
|
851
|
+
{ abortEarly: false, allowUnknown: false }
|
|
852
|
+
);
|
|
853
|
+
if (warrning) {
|
|
854
|
+
Logger({
|
|
855
|
+
level: "WARN",
|
|
856
|
+
message: "Parameter Validation warrnings for addAddress",
|
|
857
|
+
});
|
|
858
|
+
Logger({ level: "WARN", message: warrning });
|
|
859
|
+
}
|
|
860
|
+
|
|
507
861
|
const query_params = {};
|
|
508
862
|
|
|
509
863
|
const xHeaders = {};
|
|
510
864
|
|
|
511
|
-
|
|
865
|
+
const response = await APIClient.execute(
|
|
512
866
|
this._conf,
|
|
513
867
|
"post",
|
|
514
868
|
constructUrl({
|
|
@@ -519,6 +873,23 @@ class Cart {
|
|
|
519
873
|
body,
|
|
520
874
|
xHeaders
|
|
521
875
|
);
|
|
876
|
+
|
|
877
|
+
const {
|
|
878
|
+
error: res_error,
|
|
879
|
+
} = CartModel.SaveAddressResponse().validate(response, {
|
|
880
|
+
abortEarly: false,
|
|
881
|
+
allowUnknown: false,
|
|
882
|
+
});
|
|
883
|
+
|
|
884
|
+
if (res_error) {
|
|
885
|
+
Logger({
|
|
886
|
+
level: "WARN",
|
|
887
|
+
message: "Response Validation Warnnings for addAddress",
|
|
888
|
+
});
|
|
889
|
+
Logger({ level: "WARN", message: res_error });
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
return response;
|
|
522
893
|
}
|
|
523
894
|
|
|
524
895
|
/**
|
|
@@ -534,7 +905,7 @@ class Cart {
|
|
|
534
905
|
* @summary: Fetch a single address by its ID
|
|
535
906
|
* @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>
|
|
536
907
|
*/
|
|
537
|
-
getAddressById({
|
|
908
|
+
async getAddressById({
|
|
538
909
|
id,
|
|
539
910
|
cartId,
|
|
540
911
|
buyNow,
|
|
@@ -550,6 +921,20 @@ class Cart {
|
|
|
550
921
|
if (error) {
|
|
551
922
|
return Promise.reject(new FDKClientValidationError(error));
|
|
552
923
|
}
|
|
924
|
+
|
|
925
|
+
// Showing warrnings if extra unknown parameters are found
|
|
926
|
+
const { error: warrning } = CartValidator.getAddressById().validate(
|
|
927
|
+
{ id, cartId, buyNow, mobileNo, checkoutMode, tags, isDefault },
|
|
928
|
+
{ abortEarly: false, allowUnknown: false }
|
|
929
|
+
);
|
|
930
|
+
if (warrning) {
|
|
931
|
+
Logger({
|
|
932
|
+
level: "WARN",
|
|
933
|
+
message: "Parameter Validation warrnings for getAddressById",
|
|
934
|
+
});
|
|
935
|
+
Logger({ level: "WARN", message: warrning });
|
|
936
|
+
}
|
|
937
|
+
|
|
553
938
|
const query_params = {};
|
|
554
939
|
query_params["cart_id"] = cartId;
|
|
555
940
|
query_params["buy_now"] = buyNow;
|
|
@@ -560,7 +945,7 @@ class Cart {
|
|
|
560
945
|
|
|
561
946
|
const xHeaders = {};
|
|
562
947
|
|
|
563
|
-
|
|
948
|
+
const response = await APIClient.execute(
|
|
564
949
|
this._conf,
|
|
565
950
|
"get",
|
|
566
951
|
constructUrl({
|
|
@@ -571,6 +956,21 @@ class Cart {
|
|
|
571
956
|
undefined,
|
|
572
957
|
xHeaders
|
|
573
958
|
);
|
|
959
|
+
|
|
960
|
+
const { error: res_error } = CartModel.Address().validate(response, {
|
|
961
|
+
abortEarly: false,
|
|
962
|
+
allowUnknown: false,
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
if (res_error) {
|
|
966
|
+
Logger({
|
|
967
|
+
level: "WARN",
|
|
968
|
+
message: "Response Validation Warnnings for getAddressById",
|
|
969
|
+
});
|
|
970
|
+
Logger({ level: "WARN", message: res_error });
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
return response;
|
|
574
974
|
}
|
|
575
975
|
|
|
576
976
|
/**
|
|
@@ -581,7 +981,7 @@ class Cart {
|
|
|
581
981
|
* @summary: Update address added to an account
|
|
582
982
|
* @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>
|
|
583
983
|
*/
|
|
584
|
-
updateAddress({ id, body } = {}) {
|
|
984
|
+
async updateAddress({ id, body } = {}) {
|
|
585
985
|
const { error } = CartValidator.updateAddress().validate(
|
|
586
986
|
{ id, body },
|
|
587
987
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -589,11 +989,25 @@ class Cart {
|
|
|
589
989
|
if (error) {
|
|
590
990
|
return Promise.reject(new FDKClientValidationError(error));
|
|
591
991
|
}
|
|
992
|
+
|
|
993
|
+
// Showing warrnings if extra unknown parameters are found
|
|
994
|
+
const { error: warrning } = CartValidator.updateAddress().validate(
|
|
995
|
+
{ id, body },
|
|
996
|
+
{ abortEarly: false, allowUnknown: false }
|
|
997
|
+
);
|
|
998
|
+
if (warrning) {
|
|
999
|
+
Logger({
|
|
1000
|
+
level: "WARN",
|
|
1001
|
+
message: "Parameter Validation warrnings for updateAddress",
|
|
1002
|
+
});
|
|
1003
|
+
Logger({ level: "WARN", message: warrning });
|
|
1004
|
+
}
|
|
1005
|
+
|
|
592
1006
|
const query_params = {};
|
|
593
1007
|
|
|
594
1008
|
const xHeaders = {};
|
|
595
1009
|
|
|
596
|
-
|
|
1010
|
+
const response = await APIClient.execute(
|
|
597
1011
|
this._conf,
|
|
598
1012
|
"put",
|
|
599
1013
|
constructUrl({
|
|
@@ -604,6 +1018,23 @@ class Cart {
|
|
|
604
1018
|
body,
|
|
605
1019
|
xHeaders
|
|
606
1020
|
);
|
|
1021
|
+
|
|
1022
|
+
const {
|
|
1023
|
+
error: res_error,
|
|
1024
|
+
} = CartModel.UpdateAddressResponse().validate(response, {
|
|
1025
|
+
abortEarly: false,
|
|
1026
|
+
allowUnknown: false,
|
|
1027
|
+
});
|
|
1028
|
+
|
|
1029
|
+
if (res_error) {
|
|
1030
|
+
Logger({
|
|
1031
|
+
level: "WARN",
|
|
1032
|
+
message: "Response Validation Warnnings for updateAddress",
|
|
1033
|
+
});
|
|
1034
|
+
Logger({ level: "WARN", message: res_error });
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
return response;
|
|
607
1038
|
}
|
|
608
1039
|
|
|
609
1040
|
/**
|
|
@@ -613,7 +1044,7 @@ class Cart {
|
|
|
613
1044
|
* @summary: Remove address associated with an account
|
|
614
1045
|
* @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.
|
|
615
1046
|
*/
|
|
616
|
-
removeAddress({ id } = {}) {
|
|
1047
|
+
async removeAddress({ id } = {}) {
|
|
617
1048
|
const { error } = CartValidator.removeAddress().validate(
|
|
618
1049
|
{ id },
|
|
619
1050
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -621,11 +1052,25 @@ class Cart {
|
|
|
621
1052
|
if (error) {
|
|
622
1053
|
return Promise.reject(new FDKClientValidationError(error));
|
|
623
1054
|
}
|
|
1055
|
+
|
|
1056
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1057
|
+
const { error: warrning } = CartValidator.removeAddress().validate(
|
|
1058
|
+
{ id },
|
|
1059
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1060
|
+
);
|
|
1061
|
+
if (warrning) {
|
|
1062
|
+
Logger({
|
|
1063
|
+
level: "WARN",
|
|
1064
|
+
message: "Parameter Validation warrnings for removeAddress",
|
|
1065
|
+
});
|
|
1066
|
+
Logger({ level: "WARN", message: warrning });
|
|
1067
|
+
}
|
|
1068
|
+
|
|
624
1069
|
const query_params = {};
|
|
625
1070
|
|
|
626
1071
|
const xHeaders = {};
|
|
627
1072
|
|
|
628
|
-
|
|
1073
|
+
const response = await APIClient.execute(
|
|
629
1074
|
this._conf,
|
|
630
1075
|
"delete",
|
|
631
1076
|
constructUrl({
|
|
@@ -636,6 +1081,23 @@ class Cart {
|
|
|
636
1081
|
undefined,
|
|
637
1082
|
xHeaders
|
|
638
1083
|
);
|
|
1084
|
+
|
|
1085
|
+
const {
|
|
1086
|
+
error: res_error,
|
|
1087
|
+
} = CartModel.DeleteAddressResponse().validate(response, {
|
|
1088
|
+
abortEarly: false,
|
|
1089
|
+
allowUnknown: false,
|
|
1090
|
+
});
|
|
1091
|
+
|
|
1092
|
+
if (res_error) {
|
|
1093
|
+
Logger({
|
|
1094
|
+
level: "WARN",
|
|
1095
|
+
message: "Response Validation Warnnings for removeAddress",
|
|
1096
|
+
});
|
|
1097
|
+
Logger({ level: "WARN", message: res_error });
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
return response;
|
|
639
1101
|
}
|
|
640
1102
|
|
|
641
1103
|
/**
|
|
@@ -649,7 +1111,7 @@ class Cart {
|
|
|
649
1111
|
* @summary: Select an address from available addresses
|
|
650
1112
|
* @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>
|
|
651
1113
|
*/
|
|
652
|
-
selectAddress({ body, cartId, buyNow, i, b } = {}) {
|
|
1114
|
+
async selectAddress({ body, cartId, buyNow, i, b } = {}) {
|
|
653
1115
|
const { error } = CartValidator.selectAddress().validate(
|
|
654
1116
|
{ body, cartId, buyNow, i, b },
|
|
655
1117
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -657,6 +1119,20 @@ class Cart {
|
|
|
657
1119
|
if (error) {
|
|
658
1120
|
return Promise.reject(new FDKClientValidationError(error));
|
|
659
1121
|
}
|
|
1122
|
+
|
|
1123
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1124
|
+
const { error: warrning } = CartValidator.selectAddress().validate(
|
|
1125
|
+
{ body, cartId, buyNow, i, b },
|
|
1126
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1127
|
+
);
|
|
1128
|
+
if (warrning) {
|
|
1129
|
+
Logger({
|
|
1130
|
+
level: "WARN",
|
|
1131
|
+
message: "Parameter Validation warrnings for selectAddress",
|
|
1132
|
+
});
|
|
1133
|
+
Logger({ level: "WARN", message: warrning });
|
|
1134
|
+
}
|
|
1135
|
+
|
|
660
1136
|
const query_params = {};
|
|
661
1137
|
query_params["cart_id"] = cartId;
|
|
662
1138
|
query_params["buy_now"] = buyNow;
|
|
@@ -665,7 +1141,7 @@ class Cart {
|
|
|
665
1141
|
|
|
666
1142
|
const xHeaders = {};
|
|
667
1143
|
|
|
668
|
-
|
|
1144
|
+
const response = await APIClient.execute(
|
|
669
1145
|
this._conf,
|
|
670
1146
|
"post",
|
|
671
1147
|
constructUrl({
|
|
@@ -676,6 +1152,23 @@ class Cart {
|
|
|
676
1152
|
body,
|
|
677
1153
|
xHeaders
|
|
678
1154
|
);
|
|
1155
|
+
|
|
1156
|
+
const {
|
|
1157
|
+
error: res_error,
|
|
1158
|
+
} = CartModel.CartDetailResponse().validate(response, {
|
|
1159
|
+
abortEarly: false,
|
|
1160
|
+
allowUnknown: false,
|
|
1161
|
+
});
|
|
1162
|
+
|
|
1163
|
+
if (res_error) {
|
|
1164
|
+
Logger({
|
|
1165
|
+
level: "WARN",
|
|
1166
|
+
message: "Response Validation Warnnings for selectAddress",
|
|
1167
|
+
});
|
|
1168
|
+
Logger({ level: "WARN", message: res_error });
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
return response;
|
|
679
1172
|
}
|
|
680
1173
|
|
|
681
1174
|
/**
|
|
@@ -687,7 +1180,7 @@ class Cart {
|
|
|
687
1180
|
* @summary: Update cart payment
|
|
688
1181
|
* @description: Use this API to update cart payment.
|
|
689
1182
|
*/
|
|
690
|
-
selectPaymentMode({ body, id, buyNow } = {}) {
|
|
1183
|
+
async selectPaymentMode({ body, id, buyNow } = {}) {
|
|
691
1184
|
const { error } = CartValidator.selectPaymentMode().validate(
|
|
692
1185
|
{ body, id, buyNow },
|
|
693
1186
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -695,13 +1188,27 @@ class Cart {
|
|
|
695
1188
|
if (error) {
|
|
696
1189
|
return Promise.reject(new FDKClientValidationError(error));
|
|
697
1190
|
}
|
|
1191
|
+
|
|
1192
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1193
|
+
const { error: warrning } = CartValidator.selectPaymentMode().validate(
|
|
1194
|
+
{ body, id, buyNow },
|
|
1195
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1196
|
+
);
|
|
1197
|
+
if (warrning) {
|
|
1198
|
+
Logger({
|
|
1199
|
+
level: "WARN",
|
|
1200
|
+
message: "Parameter Validation warrnings for selectPaymentMode",
|
|
1201
|
+
});
|
|
1202
|
+
Logger({ level: "WARN", message: warrning });
|
|
1203
|
+
}
|
|
1204
|
+
|
|
698
1205
|
const query_params = {};
|
|
699
1206
|
query_params["id"] = id;
|
|
700
1207
|
query_params["buy_now"] = buyNow;
|
|
701
1208
|
|
|
702
1209
|
const xHeaders = {};
|
|
703
1210
|
|
|
704
|
-
|
|
1211
|
+
const response = await APIClient.execute(
|
|
705
1212
|
this._conf,
|
|
706
1213
|
"put",
|
|
707
1214
|
constructUrl({
|
|
@@ -712,6 +1219,23 @@ class Cart {
|
|
|
712
1219
|
body,
|
|
713
1220
|
xHeaders
|
|
714
1221
|
);
|
|
1222
|
+
|
|
1223
|
+
const {
|
|
1224
|
+
error: res_error,
|
|
1225
|
+
} = CartModel.CartDetailResponse().validate(response, {
|
|
1226
|
+
abortEarly: false,
|
|
1227
|
+
allowUnknown: false,
|
|
1228
|
+
});
|
|
1229
|
+
|
|
1230
|
+
if (res_error) {
|
|
1231
|
+
Logger({
|
|
1232
|
+
level: "WARN",
|
|
1233
|
+
message: "Response Validation Warnnings for selectPaymentMode",
|
|
1234
|
+
});
|
|
1235
|
+
Logger({ level: "WARN", message: res_error });
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
return response;
|
|
715
1239
|
}
|
|
716
1240
|
|
|
717
1241
|
/**
|
|
@@ -727,7 +1251,7 @@ class Cart {
|
|
|
727
1251
|
* @summary: Verify the coupon eligibility against the payment mode
|
|
728
1252
|
* @description: Use this API to validate a coupon against the payment mode such as NetBanking, Wallet, UPI etc.
|
|
729
1253
|
*/
|
|
730
|
-
validateCouponForPayment({
|
|
1254
|
+
async validateCouponForPayment({
|
|
731
1255
|
id,
|
|
732
1256
|
buyNow,
|
|
733
1257
|
addressId,
|
|
@@ -751,6 +1275,30 @@ class Cart {
|
|
|
751
1275
|
if (error) {
|
|
752
1276
|
return Promise.reject(new FDKClientValidationError(error));
|
|
753
1277
|
}
|
|
1278
|
+
|
|
1279
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1280
|
+
const {
|
|
1281
|
+
error: warrning,
|
|
1282
|
+
} = CartValidator.validateCouponForPayment().validate(
|
|
1283
|
+
{
|
|
1284
|
+
id,
|
|
1285
|
+
buyNow,
|
|
1286
|
+
addressId,
|
|
1287
|
+
paymentMode,
|
|
1288
|
+
paymentIdentifier,
|
|
1289
|
+
aggregatorName,
|
|
1290
|
+
merchantCode,
|
|
1291
|
+
},
|
|
1292
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1293
|
+
);
|
|
1294
|
+
if (warrning) {
|
|
1295
|
+
Logger({
|
|
1296
|
+
level: "WARN",
|
|
1297
|
+
message: "Parameter Validation warrnings for validateCouponForPayment",
|
|
1298
|
+
});
|
|
1299
|
+
Logger({ level: "WARN", message: warrning });
|
|
1300
|
+
}
|
|
1301
|
+
|
|
754
1302
|
const query_params = {};
|
|
755
1303
|
query_params["id"] = id;
|
|
756
1304
|
query_params["buy_now"] = buyNow;
|
|
@@ -762,7 +1310,7 @@ class Cart {
|
|
|
762
1310
|
|
|
763
1311
|
const xHeaders = {};
|
|
764
1312
|
|
|
765
|
-
|
|
1313
|
+
const response = await APIClient.execute(
|
|
766
1314
|
this._conf,
|
|
767
1315
|
"get",
|
|
768
1316
|
constructUrl({
|
|
@@ -773,6 +1321,23 @@ class Cart {
|
|
|
773
1321
|
undefined,
|
|
774
1322
|
xHeaders
|
|
775
1323
|
);
|
|
1324
|
+
|
|
1325
|
+
const {
|
|
1326
|
+
error: res_error,
|
|
1327
|
+
} = CartModel.PaymentCouponValidate().validate(response, {
|
|
1328
|
+
abortEarly: false,
|
|
1329
|
+
allowUnknown: false,
|
|
1330
|
+
});
|
|
1331
|
+
|
|
1332
|
+
if (res_error) {
|
|
1333
|
+
Logger({
|
|
1334
|
+
level: "WARN",
|
|
1335
|
+
message: "Response Validation Warnnings for validateCouponForPayment",
|
|
1336
|
+
});
|
|
1337
|
+
Logger({ level: "WARN", message: res_error });
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
return response;
|
|
776
1341
|
}
|
|
777
1342
|
|
|
778
1343
|
/**
|
|
@@ -788,7 +1353,7 @@ class Cart {
|
|
|
788
1353
|
* @summary: Get delivery date and options before checkout
|
|
789
1354
|
* @description: Use this API to get shipment details, expected delivery date, items and price breakup of the shipment.
|
|
790
1355
|
*/
|
|
791
|
-
getShipments({ p, id, buyNow, addressId, areaCode } = {}) {
|
|
1356
|
+
async getShipments({ p, id, buyNow, addressId, areaCode } = {}) {
|
|
792
1357
|
const { error } = CartValidator.getShipments().validate(
|
|
793
1358
|
{ p, id, buyNow, addressId, areaCode },
|
|
794
1359
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -796,6 +1361,20 @@ class Cart {
|
|
|
796
1361
|
if (error) {
|
|
797
1362
|
return Promise.reject(new FDKClientValidationError(error));
|
|
798
1363
|
}
|
|
1364
|
+
|
|
1365
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1366
|
+
const { error: warrning } = CartValidator.getShipments().validate(
|
|
1367
|
+
{ p, id, buyNow, addressId, areaCode },
|
|
1368
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1369
|
+
);
|
|
1370
|
+
if (warrning) {
|
|
1371
|
+
Logger({
|
|
1372
|
+
level: "WARN",
|
|
1373
|
+
message: "Parameter Validation warrnings for getShipments",
|
|
1374
|
+
});
|
|
1375
|
+
Logger({ level: "WARN", message: warrning });
|
|
1376
|
+
}
|
|
1377
|
+
|
|
799
1378
|
const query_params = {};
|
|
800
1379
|
query_params["p"] = p;
|
|
801
1380
|
query_params["id"] = id;
|
|
@@ -805,7 +1384,7 @@ class Cart {
|
|
|
805
1384
|
|
|
806
1385
|
const xHeaders = {};
|
|
807
1386
|
|
|
808
|
-
|
|
1387
|
+
const response = await APIClient.execute(
|
|
809
1388
|
this._conf,
|
|
810
1389
|
"get",
|
|
811
1390
|
constructUrl({
|
|
@@ -816,6 +1395,23 @@ class Cart {
|
|
|
816
1395
|
undefined,
|
|
817
1396
|
xHeaders
|
|
818
1397
|
);
|
|
1398
|
+
|
|
1399
|
+
const {
|
|
1400
|
+
error: res_error,
|
|
1401
|
+
} = CartModel.CartShipmentsResponse().validate(response, {
|
|
1402
|
+
abortEarly: false,
|
|
1403
|
+
allowUnknown: false,
|
|
1404
|
+
});
|
|
1405
|
+
|
|
1406
|
+
if (res_error) {
|
|
1407
|
+
Logger({
|
|
1408
|
+
level: "WARN",
|
|
1409
|
+
message: "Response Validation Warnnings for getShipments",
|
|
1410
|
+
});
|
|
1411
|
+
Logger({ level: "WARN", message: res_error });
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
return response;
|
|
819
1415
|
}
|
|
820
1416
|
|
|
821
1417
|
/**
|
|
@@ -826,7 +1422,7 @@ class Cart {
|
|
|
826
1422
|
* @summary: Checkout all items in the cart
|
|
827
1423
|
* @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.
|
|
828
1424
|
*/
|
|
829
|
-
checkoutCart({ body, buyNow } = {}) {
|
|
1425
|
+
async checkoutCart({ body, buyNow } = {}) {
|
|
830
1426
|
const { error } = CartValidator.checkoutCart().validate(
|
|
831
1427
|
{ body, buyNow },
|
|
832
1428
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -834,12 +1430,26 @@ class Cart {
|
|
|
834
1430
|
if (error) {
|
|
835
1431
|
return Promise.reject(new FDKClientValidationError(error));
|
|
836
1432
|
}
|
|
1433
|
+
|
|
1434
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1435
|
+
const { error: warrning } = CartValidator.checkoutCart().validate(
|
|
1436
|
+
{ body, buyNow },
|
|
1437
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1438
|
+
);
|
|
1439
|
+
if (warrning) {
|
|
1440
|
+
Logger({
|
|
1441
|
+
level: "WARN",
|
|
1442
|
+
message: "Parameter Validation warrnings for checkoutCart",
|
|
1443
|
+
});
|
|
1444
|
+
Logger({ level: "WARN", message: warrning });
|
|
1445
|
+
}
|
|
1446
|
+
|
|
837
1447
|
const query_params = {};
|
|
838
1448
|
query_params["buy_now"] = buyNow;
|
|
839
1449
|
|
|
840
1450
|
const xHeaders = {};
|
|
841
1451
|
|
|
842
|
-
|
|
1452
|
+
const response = await APIClient.execute(
|
|
843
1453
|
this._conf,
|
|
844
1454
|
"post",
|
|
845
1455
|
constructUrl({
|
|
@@ -850,6 +1460,23 @@ class Cart {
|
|
|
850
1460
|
body,
|
|
851
1461
|
xHeaders
|
|
852
1462
|
);
|
|
1463
|
+
|
|
1464
|
+
const {
|
|
1465
|
+
error: res_error,
|
|
1466
|
+
} = CartModel.CartCheckoutResponse().validate(response, {
|
|
1467
|
+
abortEarly: false,
|
|
1468
|
+
allowUnknown: false,
|
|
1469
|
+
});
|
|
1470
|
+
|
|
1471
|
+
if (res_error) {
|
|
1472
|
+
Logger({
|
|
1473
|
+
level: "WARN",
|
|
1474
|
+
message: "Response Validation Warnnings for checkoutCart",
|
|
1475
|
+
});
|
|
1476
|
+
Logger({ level: "WARN", message: res_error });
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
return response;
|
|
853
1480
|
}
|
|
854
1481
|
|
|
855
1482
|
/**
|
|
@@ -861,7 +1488,7 @@ class Cart {
|
|
|
861
1488
|
* @summary: Update the cart meta
|
|
862
1489
|
* @description: Use this API to update cart meta like checkout_mode and gstin.
|
|
863
1490
|
*/
|
|
864
|
-
updateCartMeta({ body, id, buyNow } = {}) {
|
|
1491
|
+
async updateCartMeta({ body, id, buyNow } = {}) {
|
|
865
1492
|
const { error } = CartValidator.updateCartMeta().validate(
|
|
866
1493
|
{ body, id, buyNow },
|
|
867
1494
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -869,13 +1496,27 @@ class Cart {
|
|
|
869
1496
|
if (error) {
|
|
870
1497
|
return Promise.reject(new FDKClientValidationError(error));
|
|
871
1498
|
}
|
|
1499
|
+
|
|
1500
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1501
|
+
const { error: warrning } = CartValidator.updateCartMeta().validate(
|
|
1502
|
+
{ body, id, buyNow },
|
|
1503
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1504
|
+
);
|
|
1505
|
+
if (warrning) {
|
|
1506
|
+
Logger({
|
|
1507
|
+
level: "WARN",
|
|
1508
|
+
message: "Parameter Validation warrnings for updateCartMeta",
|
|
1509
|
+
});
|
|
1510
|
+
Logger({ level: "WARN", message: warrning });
|
|
1511
|
+
}
|
|
1512
|
+
|
|
872
1513
|
const query_params = {};
|
|
873
1514
|
query_params["id"] = id;
|
|
874
1515
|
query_params["buy_now"] = buyNow;
|
|
875
1516
|
|
|
876
1517
|
const xHeaders = {};
|
|
877
1518
|
|
|
878
|
-
|
|
1519
|
+
const response = await APIClient.execute(
|
|
879
1520
|
this._conf,
|
|
880
1521
|
"put",
|
|
881
1522
|
constructUrl({
|
|
@@ -886,6 +1527,21 @@ class Cart {
|
|
|
886
1527
|
body,
|
|
887
1528
|
xHeaders
|
|
888
1529
|
);
|
|
1530
|
+
|
|
1531
|
+
const { error: res_error } = CartModel.CartMetaResponse().validate(
|
|
1532
|
+
response,
|
|
1533
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1534
|
+
);
|
|
1535
|
+
|
|
1536
|
+
if (res_error) {
|
|
1537
|
+
Logger({
|
|
1538
|
+
level: "WARN",
|
|
1539
|
+
message: "Response Validation Warnnings for updateCartMeta",
|
|
1540
|
+
});
|
|
1541
|
+
Logger({ level: "WARN", message: res_error });
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
return response;
|
|
889
1545
|
}
|
|
890
1546
|
|
|
891
1547
|
/**
|
|
@@ -895,7 +1551,7 @@ class Cart {
|
|
|
895
1551
|
* @summary: Generate token for sharing the cart
|
|
896
1552
|
* @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.
|
|
897
1553
|
*/
|
|
898
|
-
getCartShareLink({ body } = {}) {
|
|
1554
|
+
async getCartShareLink({ body } = {}) {
|
|
899
1555
|
const { error } = CartValidator.getCartShareLink().validate(
|
|
900
1556
|
{ body },
|
|
901
1557
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -903,11 +1559,25 @@ class Cart {
|
|
|
903
1559
|
if (error) {
|
|
904
1560
|
return Promise.reject(new FDKClientValidationError(error));
|
|
905
1561
|
}
|
|
1562
|
+
|
|
1563
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1564
|
+
const { error: warrning } = CartValidator.getCartShareLink().validate(
|
|
1565
|
+
{ body },
|
|
1566
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1567
|
+
);
|
|
1568
|
+
if (warrning) {
|
|
1569
|
+
Logger({
|
|
1570
|
+
level: "WARN",
|
|
1571
|
+
message: "Parameter Validation warrnings for getCartShareLink",
|
|
1572
|
+
});
|
|
1573
|
+
Logger({ level: "WARN", message: warrning });
|
|
1574
|
+
}
|
|
1575
|
+
|
|
906
1576
|
const query_params = {};
|
|
907
1577
|
|
|
908
1578
|
const xHeaders = {};
|
|
909
1579
|
|
|
910
|
-
|
|
1580
|
+
const response = await APIClient.execute(
|
|
911
1581
|
this._conf,
|
|
912
1582
|
"post",
|
|
913
1583
|
constructUrl({
|
|
@@ -918,6 +1588,23 @@ class Cart {
|
|
|
918
1588
|
body,
|
|
919
1589
|
xHeaders
|
|
920
1590
|
);
|
|
1591
|
+
|
|
1592
|
+
const {
|
|
1593
|
+
error: res_error,
|
|
1594
|
+
} = CartModel.GetShareCartLinkResponse().validate(response, {
|
|
1595
|
+
abortEarly: false,
|
|
1596
|
+
allowUnknown: false,
|
|
1597
|
+
});
|
|
1598
|
+
|
|
1599
|
+
if (res_error) {
|
|
1600
|
+
Logger({
|
|
1601
|
+
level: "WARN",
|
|
1602
|
+
message: "Response Validation Warnnings for getCartShareLink",
|
|
1603
|
+
});
|
|
1604
|
+
Logger({ level: "WARN", message: res_error });
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
return response;
|
|
921
1608
|
}
|
|
922
1609
|
|
|
923
1610
|
/**
|
|
@@ -927,7 +1614,7 @@ class Cart {
|
|
|
927
1614
|
* @summary: Get details of a shared cart
|
|
928
1615
|
* @description: Use this API to get the shared cart details as per the token generated using the share-cart API.
|
|
929
1616
|
*/
|
|
930
|
-
getCartSharedItems({ token } = {}) {
|
|
1617
|
+
async getCartSharedItems({ token } = {}) {
|
|
931
1618
|
const { error } = CartValidator.getCartSharedItems().validate(
|
|
932
1619
|
{ token },
|
|
933
1620
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -935,11 +1622,25 @@ class Cart {
|
|
|
935
1622
|
if (error) {
|
|
936
1623
|
return Promise.reject(new FDKClientValidationError(error));
|
|
937
1624
|
}
|
|
1625
|
+
|
|
1626
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1627
|
+
const { error: warrning } = CartValidator.getCartSharedItems().validate(
|
|
1628
|
+
{ token },
|
|
1629
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1630
|
+
);
|
|
1631
|
+
if (warrning) {
|
|
1632
|
+
Logger({
|
|
1633
|
+
level: "WARN",
|
|
1634
|
+
message: "Parameter Validation warrnings for getCartSharedItems",
|
|
1635
|
+
});
|
|
1636
|
+
Logger({ level: "WARN", message: warrning });
|
|
1637
|
+
}
|
|
1638
|
+
|
|
938
1639
|
const query_params = {};
|
|
939
1640
|
|
|
940
1641
|
const xHeaders = {};
|
|
941
1642
|
|
|
942
|
-
|
|
1643
|
+
const response = await APIClient.execute(
|
|
943
1644
|
this._conf,
|
|
944
1645
|
"get",
|
|
945
1646
|
constructUrl({
|
|
@@ -950,6 +1651,23 @@ class Cart {
|
|
|
950
1651
|
undefined,
|
|
951
1652
|
xHeaders
|
|
952
1653
|
);
|
|
1654
|
+
|
|
1655
|
+
const {
|
|
1656
|
+
error: res_error,
|
|
1657
|
+
} = CartModel.SharedCartResponse().validate(response, {
|
|
1658
|
+
abortEarly: false,
|
|
1659
|
+
allowUnknown: false,
|
|
1660
|
+
});
|
|
1661
|
+
|
|
1662
|
+
if (res_error) {
|
|
1663
|
+
Logger({
|
|
1664
|
+
level: "WARN",
|
|
1665
|
+
message: "Response Validation Warnnings for getCartSharedItems",
|
|
1666
|
+
});
|
|
1667
|
+
Logger({ level: "WARN", message: res_error });
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
return response;
|
|
953
1671
|
}
|
|
954
1672
|
|
|
955
1673
|
/**
|
|
@@ -961,7 +1679,7 @@ class Cart {
|
|
|
961
1679
|
* @summary: Merge or replace existing cart
|
|
962
1680
|
* @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.
|
|
963
1681
|
*/
|
|
964
|
-
updateCartWithSharedItems({ token, action } = {}) {
|
|
1682
|
+
async updateCartWithSharedItems({ token, action } = {}) {
|
|
965
1683
|
const { error } = CartValidator.updateCartWithSharedItems().validate(
|
|
966
1684
|
{ token, action },
|
|
967
1685
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -969,11 +1687,27 @@ class Cart {
|
|
|
969
1687
|
if (error) {
|
|
970
1688
|
return Promise.reject(new FDKClientValidationError(error));
|
|
971
1689
|
}
|
|
1690
|
+
|
|
1691
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1692
|
+
const {
|
|
1693
|
+
error: warrning,
|
|
1694
|
+
} = CartValidator.updateCartWithSharedItems().validate(
|
|
1695
|
+
{ token, action },
|
|
1696
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1697
|
+
);
|
|
1698
|
+
if (warrning) {
|
|
1699
|
+
Logger({
|
|
1700
|
+
level: "WARN",
|
|
1701
|
+
message: "Parameter Validation warrnings for updateCartWithSharedItems",
|
|
1702
|
+
});
|
|
1703
|
+
Logger({ level: "WARN", message: warrning });
|
|
1704
|
+
}
|
|
1705
|
+
|
|
972
1706
|
const query_params = {};
|
|
973
1707
|
|
|
974
1708
|
const xHeaders = {};
|
|
975
1709
|
|
|
976
|
-
|
|
1710
|
+
const response = await APIClient.execute(
|
|
977
1711
|
this._conf,
|
|
978
1712
|
"post",
|
|
979
1713
|
constructUrl({
|
|
@@ -984,6 +1718,23 @@ class Cart {
|
|
|
984
1718
|
undefined,
|
|
985
1719
|
xHeaders
|
|
986
1720
|
);
|
|
1721
|
+
|
|
1722
|
+
const {
|
|
1723
|
+
error: res_error,
|
|
1724
|
+
} = CartModel.SharedCartResponse().validate(response, {
|
|
1725
|
+
abortEarly: false,
|
|
1726
|
+
allowUnknown: false,
|
|
1727
|
+
});
|
|
1728
|
+
|
|
1729
|
+
if (res_error) {
|
|
1730
|
+
Logger({
|
|
1731
|
+
level: "WARN",
|
|
1732
|
+
message: "Response Validation Warnnings for updateCartWithSharedItems",
|
|
1733
|
+
});
|
|
1734
|
+
Logger({ level: "WARN", message: res_error });
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
return response;
|
|
987
1738
|
}
|
|
988
1739
|
|
|
989
1740
|
/**
|
|
@@ -997,7 +1748,7 @@ class Cart {
|
|
|
997
1748
|
* @summary: Fetch available promotions
|
|
998
1749
|
* @description: Use this API to get top 5 offers available for current product
|
|
999
1750
|
*/
|
|
1000
|
-
getPromotionOffers({ slug, pageSize, promotionGroup } = {}) {
|
|
1751
|
+
async getPromotionOffers({ slug, pageSize, promotionGroup } = {}) {
|
|
1001
1752
|
const { error } = CartValidator.getPromotionOffers().validate(
|
|
1002
1753
|
{ slug, pageSize, promotionGroup },
|
|
1003
1754
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -1005,6 +1756,20 @@ class Cart {
|
|
|
1005
1756
|
if (error) {
|
|
1006
1757
|
return Promise.reject(new FDKClientValidationError(error));
|
|
1007
1758
|
}
|
|
1759
|
+
|
|
1760
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1761
|
+
const { error: warrning } = CartValidator.getPromotionOffers().validate(
|
|
1762
|
+
{ slug, pageSize, promotionGroup },
|
|
1763
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1764
|
+
);
|
|
1765
|
+
if (warrning) {
|
|
1766
|
+
Logger({
|
|
1767
|
+
level: "WARN",
|
|
1768
|
+
message: "Parameter Validation warrnings for getPromotionOffers",
|
|
1769
|
+
});
|
|
1770
|
+
Logger({ level: "WARN", message: warrning });
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1008
1773
|
const query_params = {};
|
|
1009
1774
|
query_params["slug"] = slug;
|
|
1010
1775
|
query_params["page_size"] = pageSize;
|
|
@@ -1012,7 +1777,7 @@ class Cart {
|
|
|
1012
1777
|
|
|
1013
1778
|
const xHeaders = {};
|
|
1014
1779
|
|
|
1015
|
-
|
|
1780
|
+
const response = await APIClient.execute(
|
|
1016
1781
|
this._conf,
|
|
1017
1782
|
"get",
|
|
1018
1783
|
constructUrl({
|
|
@@ -1023,6 +1788,23 @@ class Cart {
|
|
|
1023
1788
|
undefined,
|
|
1024
1789
|
xHeaders
|
|
1025
1790
|
);
|
|
1791
|
+
|
|
1792
|
+
const {
|
|
1793
|
+
error: res_error,
|
|
1794
|
+
} = CartModel.PromotionOffersResponse().validate(response, {
|
|
1795
|
+
abortEarly: false,
|
|
1796
|
+
allowUnknown: false,
|
|
1797
|
+
});
|
|
1798
|
+
|
|
1799
|
+
if (res_error) {
|
|
1800
|
+
Logger({
|
|
1801
|
+
level: "WARN",
|
|
1802
|
+
message: "Response Validation Warnnings for getPromotionOffers",
|
|
1803
|
+
});
|
|
1804
|
+
Logger({ level: "WARN", message: res_error });
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
return response;
|
|
1026
1808
|
}
|
|
1027
1809
|
|
|
1028
1810
|
/**
|
|
@@ -1039,7 +1821,7 @@ class Cart {
|
|
|
1039
1821
|
* @summary: Fetch ladder price promotion
|
|
1040
1822
|
* @description: Use this API to get applicable ladder price promotion for current product
|
|
1041
1823
|
*/
|
|
1042
|
-
getLadderOffers({ slug, storeId, promotionId, pageSize } = {}) {
|
|
1824
|
+
async getLadderOffers({ slug, storeId, promotionId, pageSize } = {}) {
|
|
1043
1825
|
const { error } = CartValidator.getLadderOffers().validate(
|
|
1044
1826
|
{ slug, storeId, promotionId, pageSize },
|
|
1045
1827
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -1047,6 +1829,20 @@ class Cart {
|
|
|
1047
1829
|
if (error) {
|
|
1048
1830
|
return Promise.reject(new FDKClientValidationError(error));
|
|
1049
1831
|
}
|
|
1832
|
+
|
|
1833
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1834
|
+
const { error: warrning } = CartValidator.getLadderOffers().validate(
|
|
1835
|
+
{ slug, storeId, promotionId, pageSize },
|
|
1836
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1837
|
+
);
|
|
1838
|
+
if (warrning) {
|
|
1839
|
+
Logger({
|
|
1840
|
+
level: "WARN",
|
|
1841
|
+
message: "Parameter Validation warrnings for getLadderOffers",
|
|
1842
|
+
});
|
|
1843
|
+
Logger({ level: "WARN", message: warrning });
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1050
1846
|
const query_params = {};
|
|
1051
1847
|
query_params["slug"] = slug;
|
|
1052
1848
|
query_params["store_id"] = storeId;
|
|
@@ -1055,7 +1851,7 @@ class Cart {
|
|
|
1055
1851
|
|
|
1056
1852
|
const xHeaders = {};
|
|
1057
1853
|
|
|
1058
|
-
|
|
1854
|
+
const response = await APIClient.execute(
|
|
1059
1855
|
this._conf,
|
|
1060
1856
|
"get",
|
|
1061
1857
|
constructUrl({
|
|
@@ -1066,6 +1862,23 @@ class Cart {
|
|
|
1066
1862
|
undefined,
|
|
1067
1863
|
xHeaders
|
|
1068
1864
|
);
|
|
1865
|
+
|
|
1866
|
+
const {
|
|
1867
|
+
error: res_error,
|
|
1868
|
+
} = CartModel.LadderPriceOffers().validate(response, {
|
|
1869
|
+
abortEarly: false,
|
|
1870
|
+
allowUnknown: false,
|
|
1871
|
+
});
|
|
1872
|
+
|
|
1873
|
+
if (res_error) {
|
|
1874
|
+
Logger({
|
|
1875
|
+
level: "WARN",
|
|
1876
|
+
message: "Response Validation Warnnings for getLadderOffers",
|
|
1877
|
+
});
|
|
1878
|
+
Logger({ level: "WARN", message: res_error });
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
return response;
|
|
1069
1882
|
}
|
|
1070
1883
|
}
|
|
1071
1884
|
|