@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
|
@@ -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,
|
|
@@ -49,6 +52,28 @@ class Cart {
|
|
|
49
52
|
return Promise.reject(new FDKClientValidationError(error));
|
|
50
53
|
}
|
|
51
54
|
|
|
55
|
+
// Showing warrnings if extra unknown parameters are found
|
|
56
|
+
const { error: warrning } = CartValidator.getCoupons().validate(
|
|
57
|
+
{
|
|
58
|
+
pageNo,
|
|
59
|
+
pageSize,
|
|
60
|
+
isArchived,
|
|
61
|
+
title,
|
|
62
|
+
isPublic,
|
|
63
|
+
isDisplay,
|
|
64
|
+
typeSlug,
|
|
65
|
+
code,
|
|
66
|
+
},
|
|
67
|
+
{ abortEarly: false, allowUnknown: false }
|
|
68
|
+
);
|
|
69
|
+
if (warrning) {
|
|
70
|
+
Logger({
|
|
71
|
+
level: "WARN",
|
|
72
|
+
message: "Parameter Validation warrnings for getCoupons",
|
|
73
|
+
});
|
|
74
|
+
Logger({ level: "WARN", message: warrning });
|
|
75
|
+
}
|
|
76
|
+
|
|
52
77
|
const query_params = {};
|
|
53
78
|
query_params["page_no"] = pageNo;
|
|
54
79
|
query_params["page_size"] = pageSize;
|
|
@@ -59,13 +84,28 @@ class Cart {
|
|
|
59
84
|
query_params["type_slug"] = typeSlug;
|
|
60
85
|
query_params["code"] = code;
|
|
61
86
|
|
|
62
|
-
|
|
87
|
+
const response = await PlatformAPIClient.execute(
|
|
63
88
|
this.config,
|
|
64
89
|
"get",
|
|
65
90
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon`,
|
|
66
91
|
query_params,
|
|
67
92
|
undefined
|
|
68
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;
|
|
69
109
|
}
|
|
70
110
|
|
|
71
111
|
/**
|
|
@@ -123,10 +163,11 @@ class Cart {
|
|
|
123
163
|
/**
|
|
124
164
|
* @param {Object} arg - Arg object.
|
|
125
165
|
* @param {CouponAdd} arg.body
|
|
166
|
+
* @returns {Promise<SuccessMessage>} - Success response
|
|
126
167
|
* @summary: Create new coupon
|
|
127
168
|
* @description: Create new coupon
|
|
128
169
|
*/
|
|
129
|
-
createCoupon({ body } = {}) {
|
|
170
|
+
async createCoupon({ body } = {}) {
|
|
130
171
|
const { error } = CartValidator.createCoupon().validate(
|
|
131
172
|
{
|
|
132
173
|
body,
|
|
@@ -137,24 +178,55 @@ class Cart {
|
|
|
137
178
|
return Promise.reject(new FDKClientValidationError(error));
|
|
138
179
|
}
|
|
139
180
|
|
|
181
|
+
// Showing warrnings if extra unknown parameters are found
|
|
182
|
+
const { error: warrning } = CartValidator.createCoupon().validate(
|
|
183
|
+
{
|
|
184
|
+
body,
|
|
185
|
+
},
|
|
186
|
+
{ abortEarly: false, allowUnknown: false }
|
|
187
|
+
);
|
|
188
|
+
if (warrning) {
|
|
189
|
+
Logger({
|
|
190
|
+
level: "WARN",
|
|
191
|
+
message: "Parameter Validation warrnings for createCoupon",
|
|
192
|
+
});
|
|
193
|
+
Logger({ level: "WARN", message: warrning });
|
|
194
|
+
}
|
|
195
|
+
|
|
140
196
|
const query_params = {};
|
|
141
197
|
|
|
142
|
-
|
|
198
|
+
const response = await PlatformAPIClient.execute(
|
|
143
199
|
this.config,
|
|
144
200
|
"post",
|
|
145
201
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon`,
|
|
146
202
|
query_params,
|
|
147
203
|
body
|
|
148
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;
|
|
149
220
|
}
|
|
150
221
|
|
|
151
222
|
/**
|
|
152
223
|
* @param {Object} arg - Arg object.
|
|
153
224
|
* @param {string} arg.id -
|
|
225
|
+
* @returns {Promise<CouponUpdate>} - Success response
|
|
154
226
|
* @summary: Get with single coupon details or coupon list
|
|
155
227
|
* @description: Get single coupon details with `id` in path param
|
|
156
228
|
*/
|
|
157
|
-
getCouponById({ id } = {}) {
|
|
229
|
+
async getCouponById({ id } = {}) {
|
|
158
230
|
const { error } = CartValidator.getCouponById().validate(
|
|
159
231
|
{
|
|
160
232
|
id,
|
|
@@ -165,25 +237,56 @@ class Cart {
|
|
|
165
237
|
return Promise.reject(new FDKClientValidationError(error));
|
|
166
238
|
}
|
|
167
239
|
|
|
240
|
+
// Showing warrnings if extra unknown parameters are found
|
|
241
|
+
const { error: warrning } = CartValidator.getCouponById().validate(
|
|
242
|
+
{
|
|
243
|
+
id,
|
|
244
|
+
},
|
|
245
|
+
{ abortEarly: false, allowUnknown: false }
|
|
246
|
+
);
|
|
247
|
+
if (warrning) {
|
|
248
|
+
Logger({
|
|
249
|
+
level: "WARN",
|
|
250
|
+
message: "Parameter Validation warrnings for getCouponById",
|
|
251
|
+
});
|
|
252
|
+
Logger({ level: "WARN", message: warrning });
|
|
253
|
+
}
|
|
254
|
+
|
|
168
255
|
const query_params = {};
|
|
169
256
|
|
|
170
|
-
|
|
257
|
+
const response = await PlatformAPIClient.execute(
|
|
171
258
|
this.config,
|
|
172
259
|
"get",
|
|
173
260
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon/${id}`,
|
|
174
261
|
query_params,
|
|
175
262
|
undefined
|
|
176
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;
|
|
177
279
|
}
|
|
178
280
|
|
|
179
281
|
/**
|
|
180
282
|
* @param {Object} arg - Arg object.
|
|
181
283
|
* @param {string} arg.id -
|
|
182
284
|
* @param {CouponUpdate} arg.body
|
|
285
|
+
* @returns {Promise<SuccessMessage>} - Success response
|
|
183
286
|
* @summary: Update existing coupon configuration
|
|
184
287
|
* @description: Update coupon with id sent in `id`
|
|
185
288
|
*/
|
|
186
|
-
updateCoupon({ id, body } = {}) {
|
|
289
|
+
async updateCoupon({ id, body } = {}) {
|
|
187
290
|
const { error } = CartValidator.updateCoupon().validate(
|
|
188
291
|
{
|
|
189
292
|
id,
|
|
@@ -195,25 +298,57 @@ class Cart {
|
|
|
195
298
|
return Promise.reject(new FDKClientValidationError(error));
|
|
196
299
|
}
|
|
197
300
|
|
|
301
|
+
// Showing warrnings if extra unknown parameters are found
|
|
302
|
+
const { error: warrning } = CartValidator.updateCoupon().validate(
|
|
303
|
+
{
|
|
304
|
+
id,
|
|
305
|
+
body,
|
|
306
|
+
},
|
|
307
|
+
{ abortEarly: false, allowUnknown: false }
|
|
308
|
+
);
|
|
309
|
+
if (warrning) {
|
|
310
|
+
Logger({
|
|
311
|
+
level: "WARN",
|
|
312
|
+
message: "Parameter Validation warrnings for updateCoupon",
|
|
313
|
+
});
|
|
314
|
+
Logger({ level: "WARN", message: warrning });
|
|
315
|
+
}
|
|
316
|
+
|
|
198
317
|
const query_params = {};
|
|
199
318
|
|
|
200
|
-
|
|
319
|
+
const response = await PlatformAPIClient.execute(
|
|
201
320
|
this.config,
|
|
202
321
|
"put",
|
|
203
322
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon/${id}`,
|
|
204
323
|
query_params,
|
|
205
324
|
body
|
|
206
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;
|
|
207
341
|
}
|
|
208
342
|
|
|
209
343
|
/**
|
|
210
344
|
* @param {Object} arg - Arg object.
|
|
211
345
|
* @param {string} arg.id -
|
|
212
346
|
* @param {CouponPartialUpdate} arg.body
|
|
347
|
+
* @returns {Promise<SuccessMessage>} - Success response
|
|
213
348
|
* @summary: Update coupon archive state and schedule
|
|
214
349
|
* @description: Update archive/unarchive and change schedule for coupon
|
|
215
350
|
*/
|
|
216
|
-
updateCouponPartially({ id, body } = {}) {
|
|
351
|
+
async updateCouponPartially({ id, body } = {}) {
|
|
217
352
|
const { error } = CartValidator.updateCouponPartially().validate(
|
|
218
353
|
{
|
|
219
354
|
id,
|
|
@@ -225,15 +360,46 @@ class Cart {
|
|
|
225
360
|
return Promise.reject(new FDKClientValidationError(error));
|
|
226
361
|
}
|
|
227
362
|
|
|
363
|
+
// Showing warrnings if extra unknown parameters are found
|
|
364
|
+
const { error: warrning } = CartValidator.updateCouponPartially().validate(
|
|
365
|
+
{
|
|
366
|
+
id,
|
|
367
|
+
body,
|
|
368
|
+
},
|
|
369
|
+
{ abortEarly: false, allowUnknown: false }
|
|
370
|
+
);
|
|
371
|
+
if (warrning) {
|
|
372
|
+
Logger({
|
|
373
|
+
level: "WARN",
|
|
374
|
+
message: "Parameter Validation warrnings for updateCouponPartially",
|
|
375
|
+
});
|
|
376
|
+
Logger({ level: "WARN", message: warrning });
|
|
377
|
+
}
|
|
378
|
+
|
|
228
379
|
const query_params = {};
|
|
229
380
|
|
|
230
|
-
|
|
381
|
+
const response = await PlatformAPIClient.execute(
|
|
231
382
|
this.config,
|
|
232
383
|
"patch",
|
|
233
384
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/coupon/${id}`,
|
|
234
385
|
query_params,
|
|
235
386
|
body
|
|
236
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;
|
|
237
403
|
}
|
|
238
404
|
|
|
239
405
|
/**
|
|
@@ -246,10 +412,11 @@ class Cart {
|
|
|
246
412
|
* @param {string} [arg.promotionType] -
|
|
247
413
|
* @param {string} [arg.fpPanel] -
|
|
248
414
|
* @param {string} [arg.promotionId] -
|
|
415
|
+
* @returns {Promise<PromotionsResponse>} - Success response
|
|
249
416
|
* @summary: Get promotion list
|
|
250
417
|
* @description: Get promotion list with pagination
|
|
251
418
|
*/
|
|
252
|
-
getPromotions({
|
|
419
|
+
async getPromotions({
|
|
253
420
|
pageNo,
|
|
254
421
|
pageSize,
|
|
255
422
|
q,
|
|
@@ -276,6 +443,28 @@ class Cart {
|
|
|
276
443
|
return Promise.reject(new FDKClientValidationError(error));
|
|
277
444
|
}
|
|
278
445
|
|
|
446
|
+
// Showing warrnings if extra unknown parameters are found
|
|
447
|
+
const { error: warrning } = CartValidator.getPromotions().validate(
|
|
448
|
+
{
|
|
449
|
+
pageNo,
|
|
450
|
+
pageSize,
|
|
451
|
+
q,
|
|
452
|
+
isActive,
|
|
453
|
+
promoGroup,
|
|
454
|
+
promotionType,
|
|
455
|
+
fpPanel,
|
|
456
|
+
promotionId,
|
|
457
|
+
},
|
|
458
|
+
{ abortEarly: false, allowUnknown: false }
|
|
459
|
+
);
|
|
460
|
+
if (warrning) {
|
|
461
|
+
Logger({
|
|
462
|
+
level: "WARN",
|
|
463
|
+
message: "Parameter Validation warrnings for getPromotions",
|
|
464
|
+
});
|
|
465
|
+
Logger({ level: "WARN", message: warrning });
|
|
466
|
+
}
|
|
467
|
+
|
|
279
468
|
const query_params = {};
|
|
280
469
|
query_params["page_no"] = pageNo;
|
|
281
470
|
query_params["page_size"] = pageSize;
|
|
@@ -286,13 +475,30 @@ class Cart {
|
|
|
286
475
|
query_params["fp_panel"] = fpPanel;
|
|
287
476
|
query_params["promotion_id"] = promotionId;
|
|
288
477
|
|
|
289
|
-
|
|
478
|
+
const response = await PlatformAPIClient.execute(
|
|
290
479
|
this.config,
|
|
291
480
|
"get",
|
|
292
481
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion`,
|
|
293
482
|
query_params,
|
|
294
483
|
undefined
|
|
295
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;
|
|
296
502
|
}
|
|
297
503
|
|
|
298
504
|
/**
|
|
@@ -350,10 +556,11 @@ class Cart {
|
|
|
350
556
|
/**
|
|
351
557
|
* @param {Object} arg - Arg object.
|
|
352
558
|
* @param {PromotionAdd} arg.body
|
|
559
|
+
* @returns {Promise<PromotionAdd>} - Success response
|
|
353
560
|
* @summary: Create new promotion
|
|
354
561
|
* @description: Create new promotion
|
|
355
562
|
*/
|
|
356
|
-
createPromotion({ body } = {}) {
|
|
563
|
+
async createPromotion({ body } = {}) {
|
|
357
564
|
const { error } = CartValidator.createPromotion().validate(
|
|
358
565
|
{
|
|
359
566
|
body,
|
|
@@ -364,24 +571,55 @@ class Cart {
|
|
|
364
571
|
return Promise.reject(new FDKClientValidationError(error));
|
|
365
572
|
}
|
|
366
573
|
|
|
574
|
+
// Showing warrnings if extra unknown parameters are found
|
|
575
|
+
const { error: warrning } = CartValidator.createPromotion().validate(
|
|
576
|
+
{
|
|
577
|
+
body,
|
|
578
|
+
},
|
|
579
|
+
{ abortEarly: false, allowUnknown: false }
|
|
580
|
+
);
|
|
581
|
+
if (warrning) {
|
|
582
|
+
Logger({
|
|
583
|
+
level: "WARN",
|
|
584
|
+
message: "Parameter Validation warrnings for createPromotion",
|
|
585
|
+
});
|
|
586
|
+
Logger({ level: "WARN", message: warrning });
|
|
587
|
+
}
|
|
588
|
+
|
|
367
589
|
const query_params = {};
|
|
368
590
|
|
|
369
|
-
|
|
591
|
+
const response = await PlatformAPIClient.execute(
|
|
370
592
|
this.config,
|
|
371
593
|
"post",
|
|
372
594
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion`,
|
|
373
595
|
query_params,
|
|
374
596
|
body
|
|
375
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;
|
|
376
613
|
}
|
|
377
614
|
|
|
378
615
|
/**
|
|
379
616
|
* @param {Object} arg - Arg object.
|
|
380
617
|
* @param {string} arg.id -
|
|
618
|
+
* @returns {Promise<PromotionUpdate>} - Success response
|
|
381
619
|
* @summary: Get with single promotion details or promotion list
|
|
382
620
|
* @description: Get single promotion details with `id` in path param
|
|
383
621
|
*/
|
|
384
|
-
getPromotionById({ id } = {}) {
|
|
622
|
+
async getPromotionById({ id } = {}) {
|
|
385
623
|
const { error } = CartValidator.getPromotionById().validate(
|
|
386
624
|
{
|
|
387
625
|
id,
|
|
@@ -392,25 +630,56 @@ class Cart {
|
|
|
392
630
|
return Promise.reject(new FDKClientValidationError(error));
|
|
393
631
|
}
|
|
394
632
|
|
|
633
|
+
// Showing warrnings if extra unknown parameters are found
|
|
634
|
+
const { error: warrning } = CartValidator.getPromotionById().validate(
|
|
635
|
+
{
|
|
636
|
+
id,
|
|
637
|
+
},
|
|
638
|
+
{ abortEarly: false, allowUnknown: false }
|
|
639
|
+
);
|
|
640
|
+
if (warrning) {
|
|
641
|
+
Logger({
|
|
642
|
+
level: "WARN",
|
|
643
|
+
message: "Parameter Validation warrnings for getPromotionById",
|
|
644
|
+
});
|
|
645
|
+
Logger({ level: "WARN", message: warrning });
|
|
646
|
+
}
|
|
647
|
+
|
|
395
648
|
const query_params = {};
|
|
396
649
|
|
|
397
|
-
|
|
650
|
+
const response = await PlatformAPIClient.execute(
|
|
398
651
|
this.config,
|
|
399
652
|
"get",
|
|
400
653
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion/${id}`,
|
|
401
654
|
query_params,
|
|
402
655
|
undefined
|
|
403
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;
|
|
404
672
|
}
|
|
405
673
|
|
|
406
674
|
/**
|
|
407
675
|
* @param {Object} arg - Arg object.
|
|
408
676
|
* @param {string} arg.id -
|
|
409
677
|
* @param {PromotionUpdate} arg.body
|
|
678
|
+
* @returns {Promise<PromotionUpdate>} - Success response
|
|
410
679
|
* @summary: Update existing promotion configuration
|
|
411
680
|
* @description: Update promotion with id sent in `id`
|
|
412
681
|
*/
|
|
413
|
-
updatePromotion({ id, body } = {}) {
|
|
682
|
+
async updatePromotion({ id, body } = {}) {
|
|
414
683
|
const { error } = CartValidator.updatePromotion().validate(
|
|
415
684
|
{
|
|
416
685
|
id,
|
|
@@ -422,25 +691,57 @@ class Cart {
|
|
|
422
691
|
return Promise.reject(new FDKClientValidationError(error));
|
|
423
692
|
}
|
|
424
693
|
|
|
694
|
+
// Showing warrnings if extra unknown parameters are found
|
|
695
|
+
const { error: warrning } = CartValidator.updatePromotion().validate(
|
|
696
|
+
{
|
|
697
|
+
id,
|
|
698
|
+
body,
|
|
699
|
+
},
|
|
700
|
+
{ abortEarly: false, allowUnknown: false }
|
|
701
|
+
);
|
|
702
|
+
if (warrning) {
|
|
703
|
+
Logger({
|
|
704
|
+
level: "WARN",
|
|
705
|
+
message: "Parameter Validation warrnings for updatePromotion",
|
|
706
|
+
});
|
|
707
|
+
Logger({ level: "WARN", message: warrning });
|
|
708
|
+
}
|
|
709
|
+
|
|
425
710
|
const query_params = {};
|
|
426
711
|
|
|
427
|
-
|
|
712
|
+
const response = await PlatformAPIClient.execute(
|
|
428
713
|
this.config,
|
|
429
714
|
"put",
|
|
430
715
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion/${id}`,
|
|
431
716
|
query_params,
|
|
432
717
|
body
|
|
433
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;
|
|
434
734
|
}
|
|
435
735
|
|
|
436
736
|
/**
|
|
437
737
|
* @param {Object} arg - Arg object.
|
|
438
738
|
* @param {string} arg.id -
|
|
439
739
|
* @param {PromotionPartialUpdate} arg.body
|
|
740
|
+
* @returns {Promise<SuccessMessage>} - Success response
|
|
440
741
|
* @summary: Update promotion publish state and schedule
|
|
441
742
|
* @description: Update publish/unpublish and change schedule for promotion
|
|
442
743
|
*/
|
|
443
|
-
updatePromotionPartially({ id, body } = {}) {
|
|
744
|
+
async updatePromotionPartially({ id, body } = {}) {
|
|
444
745
|
const { error } = CartValidator.updatePromotionPartially().validate(
|
|
445
746
|
{
|
|
446
747
|
id,
|
|
@@ -452,24 +753,58 @@ class Cart {
|
|
|
452
753
|
return Promise.reject(new FDKClientValidationError(error));
|
|
453
754
|
}
|
|
454
755
|
|
|
756
|
+
// Showing warrnings if extra unknown parameters are found
|
|
757
|
+
const {
|
|
758
|
+
error: warrning,
|
|
759
|
+
} = CartValidator.updatePromotionPartially().validate(
|
|
760
|
+
{
|
|
761
|
+
id,
|
|
762
|
+
body,
|
|
763
|
+
},
|
|
764
|
+
{ abortEarly: false, allowUnknown: false }
|
|
765
|
+
);
|
|
766
|
+
if (warrning) {
|
|
767
|
+
Logger({
|
|
768
|
+
level: "WARN",
|
|
769
|
+
message: "Parameter Validation warrnings for updatePromotionPartially",
|
|
770
|
+
});
|
|
771
|
+
Logger({ level: "WARN", message: warrning });
|
|
772
|
+
}
|
|
773
|
+
|
|
455
774
|
const query_params = {};
|
|
456
775
|
|
|
457
|
-
|
|
776
|
+
const response = await PlatformAPIClient.execute(
|
|
458
777
|
this.config,
|
|
459
778
|
"patch",
|
|
460
779
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/promotion/${id}`,
|
|
461
780
|
query_params,
|
|
462
781
|
body
|
|
463
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;
|
|
464
798
|
}
|
|
465
799
|
|
|
466
800
|
/**
|
|
467
801
|
* @param {Object} arg - Arg object.
|
|
468
802
|
* @param {OpenapiCartDetailsRequest} arg.body
|
|
803
|
+
* @returns {Promise<OpenapiCartDetailsResponse>} - Success response
|
|
469
804
|
* @summary: Fetch Cart Details
|
|
470
805
|
* @description: Get all the details of cart for a list of provided `cart_items`
|
|
471
806
|
*/
|
|
472
|
-
fetchAndvalidateCartItems({ body } = {}) {
|
|
807
|
+
async fetchAndvalidateCartItems({ body } = {}) {
|
|
473
808
|
const { error } = CartValidator.fetchAndvalidateCartItems().validate(
|
|
474
809
|
{
|
|
475
810
|
body,
|
|
@@ -480,24 +815,59 @@ class Cart {
|
|
|
480
815
|
return Promise.reject(new FDKClientValidationError(error));
|
|
481
816
|
}
|
|
482
817
|
|
|
818
|
+
// Showing warrnings if extra unknown parameters are found
|
|
819
|
+
const {
|
|
820
|
+
error: warrning,
|
|
821
|
+
} = CartValidator.fetchAndvalidateCartItems().validate(
|
|
822
|
+
{
|
|
823
|
+
body,
|
|
824
|
+
},
|
|
825
|
+
{ abortEarly: false, allowUnknown: false }
|
|
826
|
+
);
|
|
827
|
+
if (warrning) {
|
|
828
|
+
Logger({
|
|
829
|
+
level: "WARN",
|
|
830
|
+
message: "Parameter Validation warrnings for fetchAndvalidateCartItems",
|
|
831
|
+
});
|
|
832
|
+
Logger({ level: "WARN", message: warrning });
|
|
833
|
+
}
|
|
834
|
+
|
|
483
835
|
const query_params = {};
|
|
484
836
|
|
|
485
|
-
|
|
837
|
+
const response = await PlatformAPIClient.execute(
|
|
486
838
|
this.config,
|
|
487
839
|
"post",
|
|
488
840
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/cart/validate`,
|
|
489
841
|
query_params,
|
|
490
842
|
body
|
|
491
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;
|
|
492
861
|
}
|
|
493
862
|
|
|
494
863
|
/**
|
|
495
864
|
* @param {Object} arg - Arg object.
|
|
496
865
|
* @param {OpenApiCartServiceabilityRequest} arg.body
|
|
866
|
+
* @returns {Promise<OpenApiCartServiceabilityResponse>} - Success response
|
|
497
867
|
* @summary: Check Pincode Serviceability
|
|
498
868
|
* @description: Check Pincode serviceability for cart items provided in `cart_items` and address pincode in `shipping_address`
|
|
499
869
|
*/
|
|
500
|
-
checkCartServiceability({ body } = {}) {
|
|
870
|
+
async checkCartServiceability({ body } = {}) {
|
|
501
871
|
const { error } = CartValidator.checkCartServiceability().validate(
|
|
502
872
|
{
|
|
503
873
|
body,
|
|
@@ -508,24 +878,59 @@ class Cart {
|
|
|
508
878
|
return Promise.reject(new FDKClientValidationError(error));
|
|
509
879
|
}
|
|
510
880
|
|
|
881
|
+
// Showing warrnings if extra unknown parameters are found
|
|
882
|
+
const {
|
|
883
|
+
error: warrning,
|
|
884
|
+
} = CartValidator.checkCartServiceability().validate(
|
|
885
|
+
{
|
|
886
|
+
body,
|
|
887
|
+
},
|
|
888
|
+
{ abortEarly: false, allowUnknown: false }
|
|
889
|
+
);
|
|
890
|
+
if (warrning) {
|
|
891
|
+
Logger({
|
|
892
|
+
level: "WARN",
|
|
893
|
+
message: "Parameter Validation warrnings for checkCartServiceability",
|
|
894
|
+
});
|
|
895
|
+
Logger({ level: "WARN", message: warrning });
|
|
896
|
+
}
|
|
897
|
+
|
|
511
898
|
const query_params = {};
|
|
512
899
|
|
|
513
|
-
|
|
900
|
+
const response = await PlatformAPIClient.execute(
|
|
514
901
|
this.config,
|
|
515
902
|
"post",
|
|
516
903
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/cart/serviceability`,
|
|
517
904
|
query_params,
|
|
518
905
|
body
|
|
519
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;
|
|
520
924
|
}
|
|
521
925
|
|
|
522
926
|
/**
|
|
523
927
|
* @param {Object} arg - Arg object.
|
|
524
928
|
* @param {OpenApiPlatformCheckoutReq} arg.body
|
|
929
|
+
* @returns {Promise<OpenApiCheckoutResponse>} - Success response
|
|
525
930
|
* @summary: Create Fynd order with cart details
|
|
526
931
|
* @description: Generate Fynd order for cart details send with provided `cart_items`
|
|
527
932
|
*/
|
|
528
|
-
checkoutCart({ body } = {}) {
|
|
933
|
+
async checkoutCart({ body } = {}) {
|
|
529
934
|
const { error } = CartValidator.checkoutCart().validate(
|
|
530
935
|
{
|
|
531
936
|
body,
|
|
@@ -536,15 +941,47 @@ class Cart {
|
|
|
536
941
|
return Promise.reject(new FDKClientValidationError(error));
|
|
537
942
|
}
|
|
538
943
|
|
|
944
|
+
// Showing warrnings if extra unknown parameters are found
|
|
945
|
+
const { error: warrning } = CartValidator.checkoutCart().validate(
|
|
946
|
+
{
|
|
947
|
+
body,
|
|
948
|
+
},
|
|
949
|
+
{ abortEarly: false, allowUnknown: false }
|
|
950
|
+
);
|
|
951
|
+
if (warrning) {
|
|
952
|
+
Logger({
|
|
953
|
+
level: "WARN",
|
|
954
|
+
message: "Parameter Validation warrnings for checkoutCart",
|
|
955
|
+
});
|
|
956
|
+
Logger({ level: "WARN", message: warrning });
|
|
957
|
+
}
|
|
958
|
+
|
|
539
959
|
const query_params = {};
|
|
540
960
|
|
|
541
|
-
|
|
961
|
+
const response = await PlatformAPIClient.execute(
|
|
542
962
|
this.config,
|
|
543
963
|
"post",
|
|
544
964
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/cart/checkout`,
|
|
545
965
|
query_params,
|
|
546
966
|
body
|
|
547
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;
|
|
548
985
|
}
|
|
549
986
|
|
|
550
987
|
/**
|
|
@@ -556,10 +993,11 @@ class Cart {
|
|
|
556
993
|
* @param {boolean} [arg.anonymousCart] -
|
|
557
994
|
* @param {string} [arg.lastId] -
|
|
558
995
|
* @param {string} [arg.sortOn] -
|
|
996
|
+
* @returns {Promise<AbandonedCartResponse>} - Success response
|
|
559
997
|
* @summary: Get with abandoned cart list
|
|
560
998
|
* @description: Get abandoned cart list with pagination
|
|
561
999
|
*/
|
|
562
|
-
getAbandonedCart({
|
|
1000
|
+
async getAbandonedCart({
|
|
563
1001
|
pageNo,
|
|
564
1002
|
pageSize,
|
|
565
1003
|
fromDate,
|
|
@@ -584,6 +1022,27 @@ class Cart {
|
|
|
584
1022
|
return Promise.reject(new FDKClientValidationError(error));
|
|
585
1023
|
}
|
|
586
1024
|
|
|
1025
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1026
|
+
const { error: warrning } = CartValidator.getAbandonedCart().validate(
|
|
1027
|
+
{
|
|
1028
|
+
pageNo,
|
|
1029
|
+
pageSize,
|
|
1030
|
+
fromDate,
|
|
1031
|
+
toDate,
|
|
1032
|
+
anonymousCart,
|
|
1033
|
+
lastId,
|
|
1034
|
+
sortOn,
|
|
1035
|
+
},
|
|
1036
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1037
|
+
);
|
|
1038
|
+
if (warrning) {
|
|
1039
|
+
Logger({
|
|
1040
|
+
level: "WARN",
|
|
1041
|
+
message: "Parameter Validation warrnings for getAbandonedCart",
|
|
1042
|
+
});
|
|
1043
|
+
Logger({ level: "WARN", message: warrning });
|
|
1044
|
+
}
|
|
1045
|
+
|
|
587
1046
|
const query_params = {};
|
|
588
1047
|
query_params["page_no"] = pageNo;
|
|
589
1048
|
query_params["page_size"] = pageSize;
|
|
@@ -593,13 +1052,30 @@ class Cart {
|
|
|
593
1052
|
query_params["last_id"] = lastId;
|
|
594
1053
|
query_params["sort_on"] = sortOn;
|
|
595
1054
|
|
|
596
|
-
|
|
1055
|
+
const response = await PlatformAPIClient.execute(
|
|
597
1056
|
this.config,
|
|
598
1057
|
"get",
|
|
599
1058
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/abandoned/carts`,
|
|
600
1059
|
query_params,
|
|
601
1060
|
undefined
|
|
602
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;
|
|
603
1079
|
}
|
|
604
1080
|
|
|
605
1081
|
/**
|
|
@@ -656,10 +1132,11 @@ class Cart {
|
|
|
656
1132
|
* @param {string} [arg.id] -
|
|
657
1133
|
* @param {boolean} [arg.i] -
|
|
658
1134
|
* @param {boolean} [arg.b] -
|
|
1135
|
+
* @returns {Promise<CartDetailResponse>} - Success response
|
|
659
1136
|
* @summary: Fetch all items added to the cart
|
|
660
1137
|
* @description: Use this API to get details of all the items added to a cart.
|
|
661
1138
|
*/
|
|
662
|
-
getAbandonedCartDetails({ id, i, b } = {}) {
|
|
1139
|
+
async getAbandonedCartDetails({ id, i, b } = {}) {
|
|
663
1140
|
const { error } = CartValidator.getAbandonedCartDetails().validate(
|
|
664
1141
|
{
|
|
665
1142
|
id,
|
|
@@ -672,18 +1149,54 @@ class Cart {
|
|
|
672
1149
|
return Promise.reject(new FDKClientValidationError(error));
|
|
673
1150
|
}
|
|
674
1151
|
|
|
1152
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1153
|
+
const {
|
|
1154
|
+
error: warrning,
|
|
1155
|
+
} = CartValidator.getAbandonedCartDetails().validate(
|
|
1156
|
+
{
|
|
1157
|
+
id,
|
|
1158
|
+
i,
|
|
1159
|
+
b,
|
|
1160
|
+
},
|
|
1161
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1162
|
+
);
|
|
1163
|
+
if (warrning) {
|
|
1164
|
+
Logger({
|
|
1165
|
+
level: "WARN",
|
|
1166
|
+
message: "Parameter Validation warrnings for getAbandonedCartDetails",
|
|
1167
|
+
});
|
|
1168
|
+
Logger({ level: "WARN", message: warrning });
|
|
1169
|
+
}
|
|
1170
|
+
|
|
675
1171
|
const query_params = {};
|
|
676
1172
|
query_params["id"] = id;
|
|
677
1173
|
query_params["i"] = i;
|
|
678
1174
|
query_params["b"] = b;
|
|
679
1175
|
|
|
680
|
-
|
|
1176
|
+
const response = await PlatformAPIClient.execute(
|
|
681
1177
|
this.config,
|
|
682
1178
|
"get",
|
|
683
1179
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/abandoned/cart/detail`,
|
|
684
1180
|
query_params,
|
|
685
1181
|
undefined
|
|
686
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;
|
|
687
1200
|
}
|
|
688
1201
|
|
|
689
1202
|
/**
|
|
@@ -691,10 +1204,11 @@ class Cart {
|
|
|
691
1204
|
* @param {string} arg.cartId - Current Cart _id
|
|
692
1205
|
* @param {boolean} [arg.b] -
|
|
693
1206
|
* @param {AddCartRequest} arg.body
|
|
1207
|
+
* @returns {Promise<AddCartDetailResponse>} - Success response
|
|
694
1208
|
* @summary: Add items to abandoned cart
|
|
695
1209
|
* @description: Use this API to add items to the abandoned cart.
|
|
696
1210
|
*/
|
|
697
|
-
addItems({ cartId, body, b } = {}) {
|
|
1211
|
+
async addItems({ cartId, body, b } = {}) {
|
|
698
1212
|
const { error } = CartValidator.addItems().validate(
|
|
699
1213
|
{
|
|
700
1214
|
cartId,
|
|
@@ -707,16 +1221,50 @@ class Cart {
|
|
|
707
1221
|
return Promise.reject(new FDKClientValidationError(error));
|
|
708
1222
|
}
|
|
709
1223
|
|
|
1224
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1225
|
+
const { error: warrning } = CartValidator.addItems().validate(
|
|
1226
|
+
{
|
|
1227
|
+
cartId,
|
|
1228
|
+
body,
|
|
1229
|
+
b,
|
|
1230
|
+
},
|
|
1231
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1232
|
+
);
|
|
1233
|
+
if (warrning) {
|
|
1234
|
+
Logger({
|
|
1235
|
+
level: "WARN",
|
|
1236
|
+
message: "Parameter Validation warrnings for addItems",
|
|
1237
|
+
});
|
|
1238
|
+
Logger({ level: "WARN", message: warrning });
|
|
1239
|
+
}
|
|
1240
|
+
|
|
710
1241
|
const query_params = {};
|
|
711
1242
|
query_params["b"] = b;
|
|
712
1243
|
|
|
713
|
-
|
|
1244
|
+
const response = await PlatformAPIClient.execute(
|
|
714
1245
|
this.config,
|
|
715
1246
|
"post",
|
|
716
1247
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/abandoned/carts/${cartId}`,
|
|
717
1248
|
query_params,
|
|
718
1249
|
body
|
|
719
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;
|
|
720
1268
|
}
|
|
721
1269
|
|
|
722
1270
|
/**
|
|
@@ -724,10 +1272,11 @@ class Cart {
|
|
|
724
1272
|
* @param {string} arg.cartId - Current Cart _id
|
|
725
1273
|
* @param {boolean} [arg.b] -
|
|
726
1274
|
* @param {UpdateCartRequest} arg.body
|
|
1275
|
+
* @returns {Promise<UpdateCartDetailResponse>} - Success response
|
|
727
1276
|
* @summary: Update items in the abandoned cart
|
|
728
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>
|
|
729
1278
|
*/
|
|
730
|
-
updateCart({ cartId, body, b } = {}) {
|
|
1279
|
+
async updateCart({ cartId, body, b } = {}) {
|
|
731
1280
|
const { error } = CartValidator.updateCart().validate(
|
|
732
1281
|
{
|
|
733
1282
|
cartId,
|
|
@@ -740,16 +1289,50 @@ class Cart {
|
|
|
740
1289
|
return Promise.reject(new FDKClientValidationError(error));
|
|
741
1290
|
}
|
|
742
1291
|
|
|
1292
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1293
|
+
const { error: warrning } = CartValidator.updateCart().validate(
|
|
1294
|
+
{
|
|
1295
|
+
cartId,
|
|
1296
|
+
body,
|
|
1297
|
+
b,
|
|
1298
|
+
},
|
|
1299
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1300
|
+
);
|
|
1301
|
+
if (warrning) {
|
|
1302
|
+
Logger({
|
|
1303
|
+
level: "WARN",
|
|
1304
|
+
message: "Parameter Validation warrnings for updateCart",
|
|
1305
|
+
});
|
|
1306
|
+
Logger({ level: "WARN", message: warrning });
|
|
1307
|
+
}
|
|
1308
|
+
|
|
743
1309
|
const query_params = {};
|
|
744
1310
|
query_params["b"] = b;
|
|
745
1311
|
|
|
746
|
-
|
|
1312
|
+
const response = await PlatformAPIClient.execute(
|
|
747
1313
|
this.config,
|
|
748
1314
|
"put",
|
|
749
1315
|
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/abandoned/carts/${cartId}`,
|
|
750
1316
|
query_params,
|
|
751
1317
|
body
|
|
752
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;
|
|
753
1336
|
}
|
|
754
1337
|
}
|
|
755
1338
|
module.exports = Cart;
|