@gofynd/fdk-client-javascript 1.0.1 → 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 +414 -414
- package/documentation/application/CONTENT.md +15 -1
- package/documentation/application/ORDER.md +290 -290
- package/documentation/application/PAYMENT.md +255 -255
- package/documentation/application/POSCART.md +297 -297
- package/documentation/platform/CART.md +499 -499
- package/documentation/platform/CATALOG.md +3088 -2702
- package/documentation/platform/COMPANYPROFILE.md +201 -201
- package/documentation/platform/CONTENT.md +123 -1
- package/documentation/platform/ORDER.md +1233 -1158
- package/documentation/platform/PARTNER.md +7 -7
- package/documentation/platform/PAYMENT.md +83 -83
- package/package.json +1 -1
- package/sdk/application/ApplicationConfig.js +1 -1
- package/sdk/application/Cart/CartApplicationClient.js +619 -108
- package/sdk/application/Cart/CartApplicationModel.d.ts +7 -7
- package/sdk/application/Cart/CartApplicationModel.js +335 -335
- package/sdk/application/Catalog/CatalogApplicationClient.d.ts +1 -1
- package/sdk/application/Catalog/CatalogApplicationClient.js +730 -134
- package/sdk/application/Catalog/CatalogApplicationModel.d.ts +21 -21
- package/sdk/application/Catalog/CatalogApplicationModel.js +547 -547
- package/sdk/application/Common/CommonApplicationClient.js +48 -8
- package/sdk/application/Communication/CommunicationApplicationClient.js +75 -14
- package/sdk/application/Configuration/ConfigurationApplicationClient.d.ts +1 -1
- package/sdk/application/Configuration/ConfigurationApplicationClient.js +392 -66
- package/sdk/application/Content/ContentApplicationClient.js +444 -76
- package/sdk/application/Content/ContentApplicationModel.d.ts +1 -0
- package/sdk/application/Content/ContentApplicationModel.js +11 -1
- package/sdk/application/FileStorage/FileStorageApplicationClient.js +74 -12
- package/sdk/application/Lead/LeadApplicationClient.js +164 -30
- package/sdk/application/Logistic/LogisticApplicationClient.js +98 -16
- package/sdk/application/Order/OrderApplicationClient.d.ts +1 -1
- package/sdk/application/Order/OrderApplicationClient.js +287 -54
- package/sdk/application/Order/OrderApplicationModel.d.ts +19 -19
- package/sdk/application/Order/OrderApplicationModel.js +357 -357
- package/sdk/application/Payment/PaymentApplicationClient.js +961 -186
- package/sdk/application/Payment/PaymentApplicationModel.d.ts +3 -3
- package/sdk/application/Payment/PaymentApplicationModel.js +352 -352
- package/sdk/application/PosCart/PosCartApplicationClient.js +645 -114
- package/sdk/application/PosCart/PosCartApplicationModel.d.ts +15 -15
- package/sdk/application/PosCart/PosCartApplicationModel.js +389 -389
- package/sdk/application/Rewards/RewardsApplicationClient.js +168 -28
- package/sdk/application/Share/ShareApplicationClient.js +157 -32
- package/sdk/application/Theme/ThemeApplicationClient.js +94 -16
- package/sdk/application/User/UserApplicationClient.js +806 -148
- package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.d.ts +16 -8
- package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.js +191 -34
- package/sdk/platform/Analytics/AnalyticsPlatformClient.d.ts +8 -4
- package/sdk/platform/Analytics/AnalyticsPlatformClient.js +103 -16
- package/sdk/platform/AuditTrail/AuditTrailPlatformClient.d.ts +8 -4
- package/sdk/platform/AuditTrail/AuditTrailPlatformClient.js +103 -16
- package/sdk/platform/Billing/BillingPlatformClient.d.ts +24 -12
- package/sdk/platform/Billing/BillingPlatformClient.js +299 -54
- package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +34 -17
- package/sdk/platform/Cart/CartPlatformApplicationClient.js +409 -72
- package/sdk/platform/Cart/CartPlatformModel.d.ts +35 -35
- package/sdk/platform/Cart/CartPlatformModel.js +617 -617
- package/sdk/platform/Catalog/CatalogPlatformApplicationClient.d.ts +167 -114
- package/sdk/platform/Catalog/CatalogPlatformApplicationClient.js +1562 -453
- package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.d.ts +8 -8
- package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.js +39 -39
- package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +314 -196
- package/sdk/platform/Catalog/CatalogPlatformClient.js +2459 -718
- package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +103 -94
- package/sdk/platform/Catalog/CatalogPlatformModel.js +2063 -1797
- package/sdk/platform/Catalog/CatalogPlatformValidator.d.ts +17 -15
- package/sdk/platform/Catalog/CatalogPlatformValidator.js +95 -76
- package/sdk/platform/Common/CommonPlatformClient.d.ts +4 -2
- package/sdk/platform/Common/CommonPlatformClient.js +51 -8
- package/sdk/platform/Communication/CommunicationPlatformApplicationClient.d.ts +80 -40
- package/sdk/platform/Communication/CommunicationPlatformApplicationClient.js +1000 -168
- package/sdk/platform/Communication/CommunicationPlatformClient.d.ts +2 -1
- package/sdk/platform/Communication/CommunicationPlatformClient.js +28 -4
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.d.ts +27 -14
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.js +335 -54
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.d.ts +10 -10
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.js +278 -278
- package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.d.ts +56 -28
- package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.js +702 -118
- package/sdk/platform/Configuration/ConfigurationPlatformClient.d.ts +36 -18
- package/sdk/platform/Configuration/ConfigurationPlatformClient.js +457 -82
- package/sdk/platform/Content/ContentPlatformApplicationClient.d.ts +148 -67
- package/sdk/platform/Content/ContentPlatformApplicationClient.js +1724 -284
- 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 +270 -44
- package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.d.ts +8 -4
- package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.js +102 -16
- package/sdk/platform/FileStorage/FileStoragePlatformClient.d.ts +12 -6
- package/sdk/platform/FileStorage/FileStoragePlatformClient.js +150 -24
- package/sdk/platform/Inventory/InventoryPlatformClient.d.ts +27 -14
- package/sdk/platform/Inventory/InventoryPlatformClient.js +316 -52
- package/sdk/platform/Lead/LeadPlatformApplicationClient.d.ts +26 -13
- package/sdk/platform/Lead/LeadPlatformApplicationClient.js +311 -52
- package/sdk/platform/Lead/LeadPlatformClient.d.ts +22 -11
- package/sdk/platform/Lead/LeadPlatformClient.js +266 -44
- package/sdk/platform/OAuthClient.js +8 -8
- package/sdk/platform/Order/OrderPlatformApplicationClient.d.ts +6 -3
- package/sdk/platform/Order/OrderPlatformApplicationClient.js +78 -14
- package/sdk/platform/Order/OrderPlatformClient.d.ts +95 -43
- package/sdk/platform/Order/OrderPlatformClient.js +1062 -180
- package/sdk/platform/Order/OrderPlatformModel.d.ts +64 -60
- package/sdk/platform/Order/OrderPlatformModel.js +1481 -1425
- package/sdk/platform/Order/OrderPlatformValidator.js +5 -0
- package/sdk/platform/Partner/PartnerPlatformApplicationClient.d.ts +4 -2
- package/sdk/platform/Partner/PartnerPlatformApplicationClient.js +52 -8
- 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 +287 -56
- package/sdk/platform/Payment/PaymentPlatformClient.d.ts +21 -11
- package/sdk/platform/Payment/PaymentPlatformClient.js +263 -48
- package/sdk/platform/Payment/PaymentPlatformModel.js +122 -122
- package/sdk/platform/PlatformApplicationClient.d.ts +2959 -2787
- package/sdk/platform/PlatformApplicationClient.js +3420 -3212
- package/sdk/platform/PlatformClient.d.ts +2959 -2787
- package/sdk/platform/PlatformClient.js +3420 -3212
- package/sdk/platform/Rewards/RewardsPlatformApplicationClient.d.ts +26 -13
- package/sdk/platform/Rewards/RewardsPlatformApplicationClient.js +308 -54
- package/sdk/platform/Share/SharePlatformApplicationClient.d.ts +8 -4
- package/sdk/platform/Share/SharePlatformApplicationClient.js +94 -16
- package/sdk/platform/Theme/ThemePlatformApplicationClient.d.ts +47 -23
- package/sdk/platform/Theme/ThemePlatformApplicationClient.js +571 -96
- package/sdk/platform/User/UserPlatformApplicationClient.d.ts +24 -12
- package/sdk/platform/User/UserPlatformApplicationClient.js +296 -48
- package/sdk/platform/Webhook/WebhookPlatformClient.d.ts +12 -6
- package/sdk/platform/Webhook/WebhookPlatformClient.js +157 -30
- package/sdk/public/Configuration/ConfigurationPublicClient.js +51 -8
- package/sdk/public/Inventory/InventoryPublicClient.js +149 -26
- package/sdk/public/Webhook/WebhookPublicClient.js +51 -10
|
@@ -2,6 +2,8 @@ const Paginator = require("../../common/Paginator");
|
|
|
2
2
|
const PlatformAPIClient = require("../PlatformAPIClient");
|
|
3
3
|
const { FDKClientValidationError } = require("../../common/FDKError");
|
|
4
4
|
const CartValidator = require("./CartPlatformApplicationValidator");
|
|
5
|
+
const CartModel = require("./CartPlatformModel");
|
|
6
|
+
const { Logger } = require("./../../common/Logger");
|
|
5
7
|
|
|
6
8
|
class Cart {
|
|
7
9
|
constructor(config, applicationId) {
|
|
@@ -19,10 +21,11 @@ class Cart {
|
|
|
19
21
|
* @param {boolean} [arg.isDisplay] -
|
|
20
22
|
* @param {string} [arg.typeSlug] -
|
|
21
23
|
* @param {string} [arg.code] -
|
|
24
|
+
* @returns {Promise<CouponsResponse>} - Success response
|
|
22
25
|
* @summary: Get with single coupon details or coupon list
|
|
23
26
|
* @description: Get coupon list with pagination
|
|
24
27
|
*/
|
|
25
|
-
getCoupons({
|
|
28
|
+
async getCoupons({
|
|
26
29
|
pageNo,
|
|
27
30
|
pageSize,
|
|
28
31
|
isArchived,
|
|
@@ -64,8 +67,11 @@ class Cart {
|
|
|
64
67
|
{ abortEarly: false, allowUnknown: false }
|
|
65
68
|
);
|
|
66
69
|
if (warrning) {
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
Logger({
|
|
71
|
+
level: "WARN",
|
|
72
|
+
message: "Parameter Validation warrnings for getCoupons",
|
|
73
|
+
});
|
|
74
|
+
Logger({ level: "WARN", message: warrning });
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
const query_params = {};
|
|
@@ -78,13 +84,28 @@ class Cart {
|
|
|
78
84
|
query_params["type_slug"] = typeSlug;
|
|
79
85
|
query_params["code"] = code;
|
|
80
86
|
|
|
81
|
-
|
|
87
|
+
const response = await PlatformAPIClient.execute(
|
|
82
88
|
this.config,
|
|
83
89
|
"get",
|
|
84
90
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon`,
|
|
85
91
|
query_params,
|
|
86
92
|
undefined
|
|
87
93
|
);
|
|
94
|
+
|
|
95
|
+
const { error: res_error } = CartModel.CouponsResponse().validate(
|
|
96
|
+
response,
|
|
97
|
+
{ abortEarly: false, allowUnknown: false }
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
if (res_error) {
|
|
101
|
+
Logger({
|
|
102
|
+
level: "WARN",
|
|
103
|
+
message: "Response Validation Warnnings for getCoupons",
|
|
104
|
+
});
|
|
105
|
+
Logger({ level: "WARN", message: res_error });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return response;
|
|
88
109
|
}
|
|
89
110
|
|
|
90
111
|
/**
|
|
@@ -142,10 +163,11 @@ class Cart {
|
|
|
142
163
|
/**
|
|
143
164
|
* @param {Object} arg - Arg object.
|
|
144
165
|
* @param {CouponAdd} arg.body
|
|
166
|
+
* @returns {Promise<SuccessMessage>} - Success response
|
|
145
167
|
* @summary: Create new coupon
|
|
146
168
|
* @description: Create new coupon
|
|
147
169
|
*/
|
|
148
|
-
createCoupon({ body } = {}) {
|
|
170
|
+
async createCoupon({ body } = {}) {
|
|
149
171
|
const { error } = CartValidator.createCoupon().validate(
|
|
150
172
|
{
|
|
151
173
|
body,
|
|
@@ -164,28 +186,47 @@ class Cart {
|
|
|
164
186
|
{ abortEarly: false, allowUnknown: false }
|
|
165
187
|
);
|
|
166
188
|
if (warrning) {
|
|
167
|
-
|
|
168
|
-
|
|
189
|
+
Logger({
|
|
190
|
+
level: "WARN",
|
|
191
|
+
message: "Parameter Validation warrnings for createCoupon",
|
|
192
|
+
});
|
|
193
|
+
Logger({ level: "WARN", message: warrning });
|
|
169
194
|
}
|
|
170
195
|
|
|
171
196
|
const query_params = {};
|
|
172
197
|
|
|
173
|
-
|
|
198
|
+
const response = await PlatformAPIClient.execute(
|
|
174
199
|
this.config,
|
|
175
200
|
"post",
|
|
176
201
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon`,
|
|
177
202
|
query_params,
|
|
178
203
|
body
|
|
179
204
|
);
|
|
205
|
+
|
|
206
|
+
const { error: res_error } = CartModel.SuccessMessage().validate(response, {
|
|
207
|
+
abortEarly: false,
|
|
208
|
+
allowUnknown: false,
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
if (res_error) {
|
|
212
|
+
Logger({
|
|
213
|
+
level: "WARN",
|
|
214
|
+
message: "Response Validation Warnnings for createCoupon",
|
|
215
|
+
});
|
|
216
|
+
Logger({ level: "WARN", message: res_error });
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return response;
|
|
180
220
|
}
|
|
181
221
|
|
|
182
222
|
/**
|
|
183
223
|
* @param {Object} arg - Arg object.
|
|
184
224
|
* @param {string} arg.id -
|
|
225
|
+
* @returns {Promise<CouponUpdate>} - Success response
|
|
185
226
|
* @summary: Get with single coupon details or coupon list
|
|
186
227
|
* @description: Get single coupon details with `id` in path param
|
|
187
228
|
*/
|
|
188
|
-
getCouponById({ id } = {}) {
|
|
229
|
+
async getCouponById({ id } = {}) {
|
|
189
230
|
const { error } = CartValidator.getCouponById().validate(
|
|
190
231
|
{
|
|
191
232
|
id,
|
|
@@ -204,29 +245,48 @@ class Cart {
|
|
|
204
245
|
{ abortEarly: false, allowUnknown: false }
|
|
205
246
|
);
|
|
206
247
|
if (warrning) {
|
|
207
|
-
|
|
208
|
-
|
|
248
|
+
Logger({
|
|
249
|
+
level: "WARN",
|
|
250
|
+
message: "Parameter Validation warrnings for getCouponById",
|
|
251
|
+
});
|
|
252
|
+
Logger({ level: "WARN", message: warrning });
|
|
209
253
|
}
|
|
210
254
|
|
|
211
255
|
const query_params = {};
|
|
212
256
|
|
|
213
|
-
|
|
257
|
+
const response = await PlatformAPIClient.execute(
|
|
214
258
|
this.config,
|
|
215
259
|
"get",
|
|
216
260
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon/${id}`,
|
|
217
261
|
query_params,
|
|
218
262
|
undefined
|
|
219
263
|
);
|
|
264
|
+
|
|
265
|
+
const { error: res_error } = CartModel.CouponUpdate().validate(response, {
|
|
266
|
+
abortEarly: false,
|
|
267
|
+
allowUnknown: false,
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
if (res_error) {
|
|
271
|
+
Logger({
|
|
272
|
+
level: "WARN",
|
|
273
|
+
message: "Response Validation Warnnings for getCouponById",
|
|
274
|
+
});
|
|
275
|
+
Logger({ level: "WARN", message: res_error });
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return response;
|
|
220
279
|
}
|
|
221
280
|
|
|
222
281
|
/**
|
|
223
282
|
* @param {Object} arg - Arg object.
|
|
224
283
|
* @param {string} arg.id -
|
|
225
284
|
* @param {CouponUpdate} arg.body
|
|
285
|
+
* @returns {Promise<SuccessMessage>} - Success response
|
|
226
286
|
* @summary: Update existing coupon configuration
|
|
227
287
|
* @description: Update coupon with id sent in `id`
|
|
228
288
|
*/
|
|
229
|
-
updateCoupon({ id, body } = {}) {
|
|
289
|
+
async updateCoupon({ id, body } = {}) {
|
|
230
290
|
const { error } = CartValidator.updateCoupon().validate(
|
|
231
291
|
{
|
|
232
292
|
id,
|
|
@@ -247,29 +307,48 @@ class Cart {
|
|
|
247
307
|
{ abortEarly: false, allowUnknown: false }
|
|
248
308
|
);
|
|
249
309
|
if (warrning) {
|
|
250
|
-
|
|
251
|
-
|
|
310
|
+
Logger({
|
|
311
|
+
level: "WARN",
|
|
312
|
+
message: "Parameter Validation warrnings for updateCoupon",
|
|
313
|
+
});
|
|
314
|
+
Logger({ level: "WARN", message: warrning });
|
|
252
315
|
}
|
|
253
316
|
|
|
254
317
|
const query_params = {};
|
|
255
318
|
|
|
256
|
-
|
|
319
|
+
const response = await PlatformAPIClient.execute(
|
|
257
320
|
this.config,
|
|
258
321
|
"put",
|
|
259
322
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon/${id}`,
|
|
260
323
|
query_params,
|
|
261
324
|
body
|
|
262
325
|
);
|
|
326
|
+
|
|
327
|
+
const { error: res_error } = CartModel.SuccessMessage().validate(response, {
|
|
328
|
+
abortEarly: false,
|
|
329
|
+
allowUnknown: false,
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
if (res_error) {
|
|
333
|
+
Logger({
|
|
334
|
+
level: "WARN",
|
|
335
|
+
message: "Response Validation Warnnings for updateCoupon",
|
|
336
|
+
});
|
|
337
|
+
Logger({ level: "WARN", message: res_error });
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return response;
|
|
263
341
|
}
|
|
264
342
|
|
|
265
343
|
/**
|
|
266
344
|
* @param {Object} arg - Arg object.
|
|
267
345
|
* @param {string} arg.id -
|
|
268
346
|
* @param {CouponPartialUpdate} arg.body
|
|
347
|
+
* @returns {Promise<SuccessMessage>} - Success response
|
|
269
348
|
* @summary: Update coupon archive state and schedule
|
|
270
349
|
* @description: Update archive/unarchive and change schedule for coupon
|
|
271
350
|
*/
|
|
272
|
-
updateCouponPartially({ id, body } = {}) {
|
|
351
|
+
async updateCouponPartially({ id, body } = {}) {
|
|
273
352
|
const { error } = CartValidator.updateCouponPartially().validate(
|
|
274
353
|
{
|
|
275
354
|
id,
|
|
@@ -290,19 +369,37 @@ class Cart {
|
|
|
290
369
|
{ abortEarly: false, allowUnknown: false }
|
|
291
370
|
);
|
|
292
371
|
if (warrning) {
|
|
293
|
-
|
|
294
|
-
|
|
372
|
+
Logger({
|
|
373
|
+
level: "WARN",
|
|
374
|
+
message: "Parameter Validation warrnings for updateCouponPartially",
|
|
375
|
+
});
|
|
376
|
+
Logger({ level: "WARN", message: warrning });
|
|
295
377
|
}
|
|
296
378
|
|
|
297
379
|
const query_params = {};
|
|
298
380
|
|
|
299
|
-
|
|
381
|
+
const response = await PlatformAPIClient.execute(
|
|
300
382
|
this.config,
|
|
301
383
|
"patch",
|
|
302
384
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon/${id}`,
|
|
303
385
|
query_params,
|
|
304
386
|
body
|
|
305
387
|
);
|
|
388
|
+
|
|
389
|
+
const { error: res_error } = CartModel.SuccessMessage().validate(response, {
|
|
390
|
+
abortEarly: false,
|
|
391
|
+
allowUnknown: false,
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
if (res_error) {
|
|
395
|
+
Logger({
|
|
396
|
+
level: "WARN",
|
|
397
|
+
message: "Response Validation Warnnings for updateCouponPartially",
|
|
398
|
+
});
|
|
399
|
+
Logger({ level: "WARN", message: res_error });
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return response;
|
|
306
403
|
}
|
|
307
404
|
|
|
308
405
|
/**
|
|
@@ -315,10 +412,11 @@ class Cart {
|
|
|
315
412
|
* @param {string} [arg.promotionType] -
|
|
316
413
|
* @param {string} [arg.fpPanel] -
|
|
317
414
|
* @param {string} [arg.promotionId] -
|
|
415
|
+
* @returns {Promise<PromotionsResponse>} - Success response
|
|
318
416
|
* @summary: Get promotion list
|
|
319
417
|
* @description: Get promotion list with pagination
|
|
320
418
|
*/
|
|
321
|
-
getPromotions({
|
|
419
|
+
async getPromotions({
|
|
322
420
|
pageNo,
|
|
323
421
|
pageSize,
|
|
324
422
|
q,
|
|
@@ -360,8 +458,11 @@ class Cart {
|
|
|
360
458
|
{ abortEarly: false, allowUnknown: false }
|
|
361
459
|
);
|
|
362
460
|
if (warrning) {
|
|
363
|
-
|
|
364
|
-
|
|
461
|
+
Logger({
|
|
462
|
+
level: "WARN",
|
|
463
|
+
message: "Parameter Validation warrnings for getPromotions",
|
|
464
|
+
});
|
|
465
|
+
Logger({ level: "WARN", message: warrning });
|
|
365
466
|
}
|
|
366
467
|
|
|
367
468
|
const query_params = {};
|
|
@@ -374,13 +475,30 @@ class Cart {
|
|
|
374
475
|
query_params["fp_panel"] = fpPanel;
|
|
375
476
|
query_params["promotion_id"] = promotionId;
|
|
376
477
|
|
|
377
|
-
|
|
478
|
+
const response = await PlatformAPIClient.execute(
|
|
378
479
|
this.config,
|
|
379
480
|
"get",
|
|
380
481
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion`,
|
|
381
482
|
query_params,
|
|
382
483
|
undefined
|
|
383
484
|
);
|
|
485
|
+
|
|
486
|
+
const {
|
|
487
|
+
error: res_error,
|
|
488
|
+
} = CartModel.PromotionsResponse().validate(response, {
|
|
489
|
+
abortEarly: false,
|
|
490
|
+
allowUnknown: false,
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
if (res_error) {
|
|
494
|
+
Logger({
|
|
495
|
+
level: "WARN",
|
|
496
|
+
message: "Response Validation Warnnings for getPromotions",
|
|
497
|
+
});
|
|
498
|
+
Logger({ level: "WARN", message: res_error });
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
return response;
|
|
384
502
|
}
|
|
385
503
|
|
|
386
504
|
/**
|
|
@@ -438,10 +556,11 @@ class Cart {
|
|
|
438
556
|
/**
|
|
439
557
|
* @param {Object} arg - Arg object.
|
|
440
558
|
* @param {PromotionAdd} arg.body
|
|
559
|
+
* @returns {Promise<PromotionAdd>} - Success response
|
|
441
560
|
* @summary: Create new promotion
|
|
442
561
|
* @description: Create new promotion
|
|
443
562
|
*/
|
|
444
|
-
createPromotion({ body } = {}) {
|
|
563
|
+
async createPromotion({ body } = {}) {
|
|
445
564
|
const { error } = CartValidator.createPromotion().validate(
|
|
446
565
|
{
|
|
447
566
|
body,
|
|
@@ -460,28 +579,47 @@ class Cart {
|
|
|
460
579
|
{ abortEarly: false, allowUnknown: false }
|
|
461
580
|
);
|
|
462
581
|
if (warrning) {
|
|
463
|
-
|
|
464
|
-
|
|
582
|
+
Logger({
|
|
583
|
+
level: "WARN",
|
|
584
|
+
message: "Parameter Validation warrnings for createPromotion",
|
|
585
|
+
});
|
|
586
|
+
Logger({ level: "WARN", message: warrning });
|
|
465
587
|
}
|
|
466
588
|
|
|
467
589
|
const query_params = {};
|
|
468
590
|
|
|
469
|
-
|
|
591
|
+
const response = await PlatformAPIClient.execute(
|
|
470
592
|
this.config,
|
|
471
593
|
"post",
|
|
472
594
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion`,
|
|
473
595
|
query_params,
|
|
474
596
|
body
|
|
475
597
|
);
|
|
598
|
+
|
|
599
|
+
const { error: res_error } = CartModel.PromotionAdd().validate(response, {
|
|
600
|
+
abortEarly: false,
|
|
601
|
+
allowUnknown: false,
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
if (res_error) {
|
|
605
|
+
Logger({
|
|
606
|
+
level: "WARN",
|
|
607
|
+
message: "Response Validation Warnnings for createPromotion",
|
|
608
|
+
});
|
|
609
|
+
Logger({ level: "WARN", message: res_error });
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
return response;
|
|
476
613
|
}
|
|
477
614
|
|
|
478
615
|
/**
|
|
479
616
|
* @param {Object} arg - Arg object.
|
|
480
617
|
* @param {string} arg.id -
|
|
618
|
+
* @returns {Promise<PromotionUpdate>} - Success response
|
|
481
619
|
* @summary: Get with single promotion details or promotion list
|
|
482
620
|
* @description: Get single promotion details with `id` in path param
|
|
483
621
|
*/
|
|
484
|
-
getPromotionById({ id } = {}) {
|
|
622
|
+
async getPromotionById({ id } = {}) {
|
|
485
623
|
const { error } = CartValidator.getPromotionById().validate(
|
|
486
624
|
{
|
|
487
625
|
id,
|
|
@@ -500,29 +638,48 @@ class Cart {
|
|
|
500
638
|
{ abortEarly: false, allowUnknown: false }
|
|
501
639
|
);
|
|
502
640
|
if (warrning) {
|
|
503
|
-
|
|
504
|
-
|
|
641
|
+
Logger({
|
|
642
|
+
level: "WARN",
|
|
643
|
+
message: "Parameter Validation warrnings for getPromotionById",
|
|
644
|
+
});
|
|
645
|
+
Logger({ level: "WARN", message: warrning });
|
|
505
646
|
}
|
|
506
647
|
|
|
507
648
|
const query_params = {};
|
|
508
649
|
|
|
509
|
-
|
|
650
|
+
const response = await PlatformAPIClient.execute(
|
|
510
651
|
this.config,
|
|
511
652
|
"get",
|
|
512
653
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion/${id}`,
|
|
513
654
|
query_params,
|
|
514
655
|
undefined
|
|
515
656
|
);
|
|
657
|
+
|
|
658
|
+
const { error: res_error } = CartModel.PromotionUpdate().validate(
|
|
659
|
+
response,
|
|
660
|
+
{ abortEarly: false, allowUnknown: false }
|
|
661
|
+
);
|
|
662
|
+
|
|
663
|
+
if (res_error) {
|
|
664
|
+
Logger({
|
|
665
|
+
level: "WARN",
|
|
666
|
+
message: "Response Validation Warnnings for getPromotionById",
|
|
667
|
+
});
|
|
668
|
+
Logger({ level: "WARN", message: res_error });
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
return response;
|
|
516
672
|
}
|
|
517
673
|
|
|
518
674
|
/**
|
|
519
675
|
* @param {Object} arg - Arg object.
|
|
520
676
|
* @param {string} arg.id -
|
|
521
677
|
* @param {PromotionUpdate} arg.body
|
|
678
|
+
* @returns {Promise<PromotionUpdate>} - Success response
|
|
522
679
|
* @summary: Update existing promotion configuration
|
|
523
680
|
* @description: Update promotion with id sent in `id`
|
|
524
681
|
*/
|
|
525
|
-
updatePromotion({ id, body } = {}) {
|
|
682
|
+
async updatePromotion({ id, body } = {}) {
|
|
526
683
|
const { error } = CartValidator.updatePromotion().validate(
|
|
527
684
|
{
|
|
528
685
|
id,
|
|
@@ -543,29 +700,48 @@ class Cart {
|
|
|
543
700
|
{ abortEarly: false, allowUnknown: false }
|
|
544
701
|
);
|
|
545
702
|
if (warrning) {
|
|
546
|
-
|
|
547
|
-
|
|
703
|
+
Logger({
|
|
704
|
+
level: "WARN",
|
|
705
|
+
message: "Parameter Validation warrnings for updatePromotion",
|
|
706
|
+
});
|
|
707
|
+
Logger({ level: "WARN", message: warrning });
|
|
548
708
|
}
|
|
549
709
|
|
|
550
710
|
const query_params = {};
|
|
551
711
|
|
|
552
|
-
|
|
712
|
+
const response = await PlatformAPIClient.execute(
|
|
553
713
|
this.config,
|
|
554
714
|
"put",
|
|
555
715
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion/${id}`,
|
|
556
716
|
query_params,
|
|
557
717
|
body
|
|
558
718
|
);
|
|
719
|
+
|
|
720
|
+
const { error: res_error } = CartModel.PromotionUpdate().validate(
|
|
721
|
+
response,
|
|
722
|
+
{ abortEarly: false, allowUnknown: false }
|
|
723
|
+
);
|
|
724
|
+
|
|
725
|
+
if (res_error) {
|
|
726
|
+
Logger({
|
|
727
|
+
level: "WARN",
|
|
728
|
+
message: "Response Validation Warnnings for updatePromotion",
|
|
729
|
+
});
|
|
730
|
+
Logger({ level: "WARN", message: res_error });
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
return response;
|
|
559
734
|
}
|
|
560
735
|
|
|
561
736
|
/**
|
|
562
737
|
* @param {Object} arg - Arg object.
|
|
563
738
|
* @param {string} arg.id -
|
|
564
739
|
* @param {PromotionPartialUpdate} arg.body
|
|
740
|
+
* @returns {Promise<SuccessMessage>} - Success response
|
|
565
741
|
* @summary: Update promotion publish state and schedule
|
|
566
742
|
* @description: Update publish/unpublish and change schedule for promotion
|
|
567
743
|
*/
|
|
568
|
-
updatePromotionPartially({ id, body } = {}) {
|
|
744
|
+
async updatePromotionPartially({ id, body } = {}) {
|
|
569
745
|
const { error } = CartValidator.updatePromotionPartially().validate(
|
|
570
746
|
{
|
|
571
747
|
id,
|
|
@@ -588,30 +764,47 @@ class Cart {
|
|
|
588
764
|
{ abortEarly: false, allowUnknown: false }
|
|
589
765
|
);
|
|
590
766
|
if (warrning) {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
767
|
+
Logger({
|
|
768
|
+
level: "WARN",
|
|
769
|
+
message: "Parameter Validation warrnings for updatePromotionPartially",
|
|
770
|
+
});
|
|
771
|
+
Logger({ level: "WARN", message: warrning });
|
|
595
772
|
}
|
|
596
773
|
|
|
597
774
|
const query_params = {};
|
|
598
775
|
|
|
599
|
-
|
|
776
|
+
const response = await PlatformAPIClient.execute(
|
|
600
777
|
this.config,
|
|
601
778
|
"patch",
|
|
602
779
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion/${id}`,
|
|
603
780
|
query_params,
|
|
604
781
|
body
|
|
605
782
|
);
|
|
783
|
+
|
|
784
|
+
const { error: res_error } = CartModel.SuccessMessage().validate(response, {
|
|
785
|
+
abortEarly: false,
|
|
786
|
+
allowUnknown: false,
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
if (res_error) {
|
|
790
|
+
Logger({
|
|
791
|
+
level: "WARN",
|
|
792
|
+
message: "Response Validation Warnnings for updatePromotionPartially",
|
|
793
|
+
});
|
|
794
|
+
Logger({ level: "WARN", message: res_error });
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
return response;
|
|
606
798
|
}
|
|
607
799
|
|
|
608
800
|
/**
|
|
609
801
|
* @param {Object} arg - Arg object.
|
|
610
802
|
* @param {OpenapiCartDetailsRequest} arg.body
|
|
803
|
+
* @returns {Promise<OpenapiCartDetailsResponse>} - Success response
|
|
611
804
|
* @summary: Fetch Cart Details
|
|
612
805
|
* @description: Get all the details of cart for a list of provided `cart_items`
|
|
613
806
|
*/
|
|
614
|
-
fetchAndvalidateCartItems({ body } = {}) {
|
|
807
|
+
async fetchAndvalidateCartItems({ body } = {}) {
|
|
615
808
|
const { error } = CartValidator.fetchAndvalidateCartItems().validate(
|
|
616
809
|
{
|
|
617
810
|
body,
|
|
@@ -632,30 +825,49 @@ class Cart {
|
|
|
632
825
|
{ abortEarly: false, allowUnknown: false }
|
|
633
826
|
);
|
|
634
827
|
if (warrning) {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
828
|
+
Logger({
|
|
829
|
+
level: "WARN",
|
|
830
|
+
message: "Parameter Validation warrnings for fetchAndvalidateCartItems",
|
|
831
|
+
});
|
|
832
|
+
Logger({ level: "WARN", message: warrning });
|
|
639
833
|
}
|
|
640
834
|
|
|
641
835
|
const query_params = {};
|
|
642
836
|
|
|
643
|
-
|
|
837
|
+
const response = await PlatformAPIClient.execute(
|
|
644
838
|
this.config,
|
|
645
839
|
"post",
|
|
646
840
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/cart/validate`,
|
|
647
841
|
query_params,
|
|
648
842
|
body
|
|
649
843
|
);
|
|
844
|
+
|
|
845
|
+
const {
|
|
846
|
+
error: res_error,
|
|
847
|
+
} = CartModel.OpenapiCartDetailsResponse().validate(response, {
|
|
848
|
+
abortEarly: false,
|
|
849
|
+
allowUnknown: false,
|
|
850
|
+
});
|
|
851
|
+
|
|
852
|
+
if (res_error) {
|
|
853
|
+
Logger({
|
|
854
|
+
level: "WARN",
|
|
855
|
+
message: "Response Validation Warnnings for fetchAndvalidateCartItems",
|
|
856
|
+
});
|
|
857
|
+
Logger({ level: "WARN", message: res_error });
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
return response;
|
|
650
861
|
}
|
|
651
862
|
|
|
652
863
|
/**
|
|
653
864
|
* @param {Object} arg - Arg object.
|
|
654
865
|
* @param {OpenApiCartServiceabilityRequest} arg.body
|
|
866
|
+
* @returns {Promise<OpenApiCartServiceabilityResponse>} - Success response
|
|
655
867
|
* @summary: Check Pincode Serviceability
|
|
656
868
|
* @description: Check Pincode serviceability for cart items provided in `cart_items` and address pincode in `shipping_address`
|
|
657
869
|
*/
|
|
658
|
-
checkCartServiceability({ body } = {}) {
|
|
870
|
+
async checkCartServiceability({ body } = {}) {
|
|
659
871
|
const { error } = CartValidator.checkCartServiceability().validate(
|
|
660
872
|
{
|
|
661
873
|
body,
|
|
@@ -676,28 +888,49 @@ class Cart {
|
|
|
676
888
|
{ abortEarly: false, allowUnknown: false }
|
|
677
889
|
);
|
|
678
890
|
if (warrning) {
|
|
679
|
-
|
|
680
|
-
|
|
891
|
+
Logger({
|
|
892
|
+
level: "WARN",
|
|
893
|
+
message: "Parameter Validation warrnings for checkCartServiceability",
|
|
894
|
+
});
|
|
895
|
+
Logger({ level: "WARN", message: warrning });
|
|
681
896
|
}
|
|
682
897
|
|
|
683
898
|
const query_params = {};
|
|
684
899
|
|
|
685
|
-
|
|
900
|
+
const response = await PlatformAPIClient.execute(
|
|
686
901
|
this.config,
|
|
687
902
|
"post",
|
|
688
903
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/cart/serviceability`,
|
|
689
904
|
query_params,
|
|
690
905
|
body
|
|
691
906
|
);
|
|
907
|
+
|
|
908
|
+
const {
|
|
909
|
+
error: res_error,
|
|
910
|
+
} = CartModel.OpenApiCartServiceabilityResponse().validate(response, {
|
|
911
|
+
abortEarly: false,
|
|
912
|
+
allowUnknown: false,
|
|
913
|
+
});
|
|
914
|
+
|
|
915
|
+
if (res_error) {
|
|
916
|
+
Logger({
|
|
917
|
+
level: "WARN",
|
|
918
|
+
message: "Response Validation Warnnings for checkCartServiceability",
|
|
919
|
+
});
|
|
920
|
+
Logger({ level: "WARN", message: res_error });
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
return response;
|
|
692
924
|
}
|
|
693
925
|
|
|
694
926
|
/**
|
|
695
927
|
* @param {Object} arg - Arg object.
|
|
696
928
|
* @param {OpenApiPlatformCheckoutReq} arg.body
|
|
929
|
+
* @returns {Promise<OpenApiCheckoutResponse>} - Success response
|
|
697
930
|
* @summary: Create Fynd order with cart details
|
|
698
931
|
* @description: Generate Fynd order for cart details send with provided `cart_items`
|
|
699
932
|
*/
|
|
700
|
-
checkoutCart({ body } = {}) {
|
|
933
|
+
async checkoutCart({ body } = {}) {
|
|
701
934
|
const { error } = CartValidator.checkoutCart().validate(
|
|
702
935
|
{
|
|
703
936
|
body,
|
|
@@ -716,19 +949,39 @@ class Cart {
|
|
|
716
949
|
{ abortEarly: false, allowUnknown: false }
|
|
717
950
|
);
|
|
718
951
|
if (warrning) {
|
|
719
|
-
|
|
720
|
-
|
|
952
|
+
Logger({
|
|
953
|
+
level: "WARN",
|
|
954
|
+
message: "Parameter Validation warrnings for checkoutCart",
|
|
955
|
+
});
|
|
956
|
+
Logger({ level: "WARN", message: warrning });
|
|
721
957
|
}
|
|
722
958
|
|
|
723
959
|
const query_params = {};
|
|
724
960
|
|
|
725
|
-
|
|
961
|
+
const response = await PlatformAPIClient.execute(
|
|
726
962
|
this.config,
|
|
727
963
|
"post",
|
|
728
964
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/cart/checkout`,
|
|
729
965
|
query_params,
|
|
730
966
|
body
|
|
731
967
|
);
|
|
968
|
+
|
|
969
|
+
const {
|
|
970
|
+
error: res_error,
|
|
971
|
+
} = CartModel.OpenApiCheckoutResponse().validate(response, {
|
|
972
|
+
abortEarly: false,
|
|
973
|
+
allowUnknown: false,
|
|
974
|
+
});
|
|
975
|
+
|
|
976
|
+
if (res_error) {
|
|
977
|
+
Logger({
|
|
978
|
+
level: "WARN",
|
|
979
|
+
message: "Response Validation Warnnings for checkoutCart",
|
|
980
|
+
});
|
|
981
|
+
Logger({ level: "WARN", message: res_error });
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
return response;
|
|
732
985
|
}
|
|
733
986
|
|
|
734
987
|
/**
|
|
@@ -740,10 +993,11 @@ class Cart {
|
|
|
740
993
|
* @param {boolean} [arg.anonymousCart] -
|
|
741
994
|
* @param {string} [arg.lastId] -
|
|
742
995
|
* @param {string} [arg.sortOn] -
|
|
996
|
+
* @returns {Promise<AbandonedCartResponse>} - Success response
|
|
743
997
|
* @summary: Get with abandoned cart list
|
|
744
998
|
* @description: Get abandoned cart list with pagination
|
|
745
999
|
*/
|
|
746
|
-
getAbandonedCart({
|
|
1000
|
+
async getAbandonedCart({
|
|
747
1001
|
pageNo,
|
|
748
1002
|
pageSize,
|
|
749
1003
|
fromDate,
|
|
@@ -782,8 +1036,11 @@ class Cart {
|
|
|
782
1036
|
{ abortEarly: false, allowUnknown: false }
|
|
783
1037
|
);
|
|
784
1038
|
if (warrning) {
|
|
785
|
-
|
|
786
|
-
|
|
1039
|
+
Logger({
|
|
1040
|
+
level: "WARN",
|
|
1041
|
+
message: "Parameter Validation warrnings for getAbandonedCart",
|
|
1042
|
+
});
|
|
1043
|
+
Logger({ level: "WARN", message: warrning });
|
|
787
1044
|
}
|
|
788
1045
|
|
|
789
1046
|
const query_params = {};
|
|
@@ -795,13 +1052,30 @@ class Cart {
|
|
|
795
1052
|
query_params["last_id"] = lastId;
|
|
796
1053
|
query_params["sort_on"] = sortOn;
|
|
797
1054
|
|
|
798
|
-
|
|
1055
|
+
const response = await PlatformAPIClient.execute(
|
|
799
1056
|
this.config,
|
|
800
1057
|
"get",
|
|
801
1058
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/abandoned/carts`,
|
|
802
1059
|
query_params,
|
|
803
1060
|
undefined
|
|
804
1061
|
);
|
|
1062
|
+
|
|
1063
|
+
const {
|
|
1064
|
+
error: res_error,
|
|
1065
|
+
} = CartModel.AbandonedCartResponse().validate(response, {
|
|
1066
|
+
abortEarly: false,
|
|
1067
|
+
allowUnknown: false,
|
|
1068
|
+
});
|
|
1069
|
+
|
|
1070
|
+
if (res_error) {
|
|
1071
|
+
Logger({
|
|
1072
|
+
level: "WARN",
|
|
1073
|
+
message: "Response Validation Warnnings for getAbandonedCart",
|
|
1074
|
+
});
|
|
1075
|
+
Logger({ level: "WARN", message: res_error });
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
return response;
|
|
805
1079
|
}
|
|
806
1080
|
|
|
807
1081
|
/**
|
|
@@ -858,10 +1132,11 @@ class Cart {
|
|
|
858
1132
|
* @param {string} [arg.id] -
|
|
859
1133
|
* @param {boolean} [arg.i] -
|
|
860
1134
|
* @param {boolean} [arg.b] -
|
|
1135
|
+
* @returns {Promise<CartDetailResponse>} - Success response
|
|
861
1136
|
* @summary: Fetch all items added to the cart
|
|
862
1137
|
* @description: Use this API to get details of all the items added to a cart.
|
|
863
1138
|
*/
|
|
864
|
-
getAbandonedCartDetails({ id, i, b } = {}) {
|
|
1139
|
+
async getAbandonedCartDetails({ id, i, b } = {}) {
|
|
865
1140
|
const { error } = CartValidator.getAbandonedCartDetails().validate(
|
|
866
1141
|
{
|
|
867
1142
|
id,
|
|
@@ -886,8 +1161,11 @@ class Cart {
|
|
|
886
1161
|
{ abortEarly: false, allowUnknown: false }
|
|
887
1162
|
);
|
|
888
1163
|
if (warrning) {
|
|
889
|
-
|
|
890
|
-
|
|
1164
|
+
Logger({
|
|
1165
|
+
level: "WARN",
|
|
1166
|
+
message: "Parameter Validation warrnings for getAbandonedCartDetails",
|
|
1167
|
+
});
|
|
1168
|
+
Logger({ level: "WARN", message: warrning });
|
|
891
1169
|
}
|
|
892
1170
|
|
|
893
1171
|
const query_params = {};
|
|
@@ -895,13 +1173,30 @@ class Cart {
|
|
|
895
1173
|
query_params["i"] = i;
|
|
896
1174
|
query_params["b"] = b;
|
|
897
1175
|
|
|
898
|
-
|
|
1176
|
+
const response = await PlatformAPIClient.execute(
|
|
899
1177
|
this.config,
|
|
900
1178
|
"get",
|
|
901
1179
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/abandoned/cart/detail`,
|
|
902
1180
|
query_params,
|
|
903
1181
|
undefined
|
|
904
1182
|
);
|
|
1183
|
+
|
|
1184
|
+
const {
|
|
1185
|
+
error: res_error,
|
|
1186
|
+
} = CartModel.CartDetailResponse().validate(response, {
|
|
1187
|
+
abortEarly: false,
|
|
1188
|
+
allowUnknown: false,
|
|
1189
|
+
});
|
|
1190
|
+
|
|
1191
|
+
if (res_error) {
|
|
1192
|
+
Logger({
|
|
1193
|
+
level: "WARN",
|
|
1194
|
+
message: "Response Validation Warnnings for getAbandonedCartDetails",
|
|
1195
|
+
});
|
|
1196
|
+
Logger({ level: "WARN", message: res_error });
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
return response;
|
|
905
1200
|
}
|
|
906
1201
|
|
|
907
1202
|
/**
|
|
@@ -909,10 +1204,11 @@ class Cart {
|
|
|
909
1204
|
* @param {string} arg.cartId - Current Cart _id
|
|
910
1205
|
* @param {boolean} [arg.b] -
|
|
911
1206
|
* @param {AddCartRequest} arg.body
|
|
1207
|
+
* @returns {Promise<AddCartDetailResponse>} - Success response
|
|
912
1208
|
* @summary: Add items to abandoned cart
|
|
913
1209
|
* @description: Use this API to add items to the abandoned cart.
|
|
914
1210
|
*/
|
|
915
|
-
addItems({ cartId, body, b } = {}) {
|
|
1211
|
+
async addItems({ cartId, body, b } = {}) {
|
|
916
1212
|
const { error } = CartValidator.addItems().validate(
|
|
917
1213
|
{
|
|
918
1214
|
cartId,
|
|
@@ -935,20 +1231,40 @@ class Cart {
|
|
|
935
1231
|
{ abortEarly: false, allowUnknown: false }
|
|
936
1232
|
);
|
|
937
1233
|
if (warrning) {
|
|
938
|
-
|
|
939
|
-
|
|
1234
|
+
Logger({
|
|
1235
|
+
level: "WARN",
|
|
1236
|
+
message: "Parameter Validation warrnings for addItems",
|
|
1237
|
+
});
|
|
1238
|
+
Logger({ level: "WARN", message: warrning });
|
|
940
1239
|
}
|
|
941
1240
|
|
|
942
1241
|
const query_params = {};
|
|
943
1242
|
query_params["b"] = b;
|
|
944
1243
|
|
|
945
|
-
|
|
1244
|
+
const response = await PlatformAPIClient.execute(
|
|
946
1245
|
this.config,
|
|
947
1246
|
"post",
|
|
948
1247
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/abandoned/carts/${cartId}`,
|
|
949
1248
|
query_params,
|
|
950
1249
|
body
|
|
951
1250
|
);
|
|
1251
|
+
|
|
1252
|
+
const {
|
|
1253
|
+
error: res_error,
|
|
1254
|
+
} = CartModel.AddCartDetailResponse().validate(response, {
|
|
1255
|
+
abortEarly: false,
|
|
1256
|
+
allowUnknown: false,
|
|
1257
|
+
});
|
|
1258
|
+
|
|
1259
|
+
if (res_error) {
|
|
1260
|
+
Logger({
|
|
1261
|
+
level: "WARN",
|
|
1262
|
+
message: "Response Validation Warnnings for addItems",
|
|
1263
|
+
});
|
|
1264
|
+
Logger({ level: "WARN", message: res_error });
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
return response;
|
|
952
1268
|
}
|
|
953
1269
|
|
|
954
1270
|
/**
|
|
@@ -956,10 +1272,11 @@ class Cart {
|
|
|
956
1272
|
* @param {string} arg.cartId - Current Cart _id
|
|
957
1273
|
* @param {boolean} [arg.b] -
|
|
958
1274
|
* @param {UpdateCartRequest} arg.body
|
|
1275
|
+
* @returns {Promise<UpdateCartDetailResponse>} - Success response
|
|
959
1276
|
* @summary: Update items in the abandoned cart
|
|
960
1277
|
* @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>
|
|
961
1278
|
*/
|
|
962
|
-
updateCart({ cartId, body, b } = {}) {
|
|
1279
|
+
async updateCart({ cartId, body, b } = {}) {
|
|
963
1280
|
const { error } = CartValidator.updateCart().validate(
|
|
964
1281
|
{
|
|
965
1282
|
cartId,
|
|
@@ -982,20 +1299,40 @@ class Cart {
|
|
|
982
1299
|
{ abortEarly: false, allowUnknown: false }
|
|
983
1300
|
);
|
|
984
1301
|
if (warrning) {
|
|
985
|
-
|
|
986
|
-
|
|
1302
|
+
Logger({
|
|
1303
|
+
level: "WARN",
|
|
1304
|
+
message: "Parameter Validation warrnings for updateCart",
|
|
1305
|
+
});
|
|
1306
|
+
Logger({ level: "WARN", message: warrning });
|
|
987
1307
|
}
|
|
988
1308
|
|
|
989
1309
|
const query_params = {};
|
|
990
1310
|
query_params["b"] = b;
|
|
991
1311
|
|
|
992
|
-
|
|
1312
|
+
const response = await PlatformAPIClient.execute(
|
|
993
1313
|
this.config,
|
|
994
1314
|
"put",
|
|
995
1315
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/abandoned/carts/${cartId}`,
|
|
996
1316
|
query_params,
|
|
997
1317
|
body
|
|
998
1318
|
);
|
|
1319
|
+
|
|
1320
|
+
const {
|
|
1321
|
+
error: res_error,
|
|
1322
|
+
} = CartModel.UpdateCartDetailResponse().validate(response, {
|
|
1323
|
+
abortEarly: false,
|
|
1324
|
+
allowUnknown: false,
|
|
1325
|
+
});
|
|
1326
|
+
|
|
1327
|
+
if (res_error) {
|
|
1328
|
+
Logger({
|
|
1329
|
+
level: "WARN",
|
|
1330
|
+
message: "Response Validation Warnnings for updateCart",
|
|
1331
|
+
});
|
|
1332
|
+
Logger({ level: "WARN", message: res_error });
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
return response;
|
|
999
1336
|
}
|
|
1000
1337
|
}
|
|
1001
1338
|
module.exports = Cart;
|