@gofynd/fdk-client-javascript 3.16.3 → 3.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/sdk/application/ApplicationClient.d.ts +0 -2
  4. package/sdk/application/ApplicationClient.js +0 -2
  5. package/sdk/application/Cart/CartApplicationClient.d.ts +40 -0
  6. package/sdk/application/Cart/CartApplicationClient.js +176 -0
  7. package/sdk/application/Catalog/CatalogApplicationClient.d.ts +18 -4
  8. package/sdk/application/Catalog/CatalogApplicationClient.js +47 -4
  9. package/sdk/application/Content/ContentApplicationClient.d.ts +21 -1
  10. package/sdk/application/Content/ContentApplicationClient.js +93 -2
  11. package/sdk/application/Logistic/LogisticApplicationClient.d.ts +11 -21
  12. package/sdk/application/Logistic/LogisticApplicationClient.js +34 -83
  13. package/sdk/application/Order/OrderApplicationClient.d.ts +11 -0
  14. package/sdk/application/Order/OrderApplicationClient.js +50 -0
  15. package/sdk/application/Payment/PaymentApplicationClient.d.ts +5 -5
  16. package/sdk/application/Payment/PaymentApplicationClient.js +5 -4
  17. package/sdk/partner/Logistics/LogisticsPartnerClient.d.ts +84 -0
  18. package/sdk/partner/Logistics/LogisticsPartnerClient.js +712 -0
  19. package/sdk/partner/Logistics/LogisticsPartnerModel.d.ts +237 -1
  20. package/sdk/partner/Logistics/LogisticsPartnerModel.js +157 -0
  21. package/sdk/partner/Logistics/LogisticsPartnerValidator.d.ts +8 -0
  22. package/sdk/partner/Logistics/LogisticsPartnerValidator.js +70 -0
  23. package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +74 -12
  24. package/sdk/platform/Cart/CartPlatformApplicationClient.js +637 -36
  25. package/sdk/platform/Cart/CartPlatformApplicationValidator.d.ts +225 -1
  26. package/sdk/platform/Cart/CartPlatformApplicationValidator.js +147 -0
  27. package/sdk/platform/Cart/CartPlatformModel.d.ts +952 -5
  28. package/sdk/platform/Cart/CartPlatformModel.js +598 -2
  29. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.d.ts +125 -5
  30. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.js +831 -41
  31. package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.d.ts +205 -7
  32. package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.js +154 -3
  33. package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +5 -16
  34. package/sdk/platform/Catalog/CatalogPlatformClient.js +8 -85
  35. package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +1025 -159
  36. package/sdk/platform/Catalog/CatalogPlatformModel.js +840 -165
  37. package/sdk/platform/Catalog/CatalogPlatformValidator.d.ts +8 -10
  38. package/sdk/platform/Catalog/CatalogPlatformValidator.js +3 -12
  39. package/sdk/platform/Common/CommonPlatformModel.d.ts +18 -1
  40. package/sdk/platform/Common/CommonPlatformModel.js +14 -0
  41. package/sdk/platform/Communication/CommunicationPlatformApplicationClient.d.ts +1 -73
  42. package/sdk/platform/Communication/CommunicationPlatformApplicationClient.js +4 -462
  43. package/sdk/platform/Communication/CommunicationPlatformApplicationValidator.d.ts +7 -45
  44. package/sdk/platform/Communication/CommunicationPlatformApplicationValidator.js +4 -55
  45. package/sdk/platform/Communication/CommunicationPlatformModel.d.ts +10 -2
  46. package/sdk/platform/Communication/CommunicationPlatformModel.js +3 -2
  47. package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.d.ts +14 -0
  48. package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.js +6 -0
  49. package/sdk/platform/Configuration/ConfigurationPlatformModel.d.ts +92 -1
  50. package/sdk/platform/Configuration/ConfigurationPlatformModel.js +54 -0
  51. package/sdk/platform/Discount/DiscountPlatformModel.d.ts +21 -0
  52. package/sdk/platform/Discount/DiscountPlatformModel.js +9 -0
  53. package/sdk/platform/Order/OrderPlatformClient.d.ts +27 -19
  54. package/sdk/platform/Order/OrderPlatformClient.js +176 -108
  55. package/sdk/platform/Order/OrderPlatformModel.d.ts +359 -45
  56. package/sdk/platform/Order/OrderPlatformModel.js +218 -44
  57. package/sdk/platform/Order/OrderPlatformValidator.d.ts +40 -43
  58. package/sdk/platform/Order/OrderPlatformValidator.js +35 -30
  59. package/sdk/platform/Payment/PaymentPlatformApplicationClient.d.ts +14 -3
  60. package/sdk/platform/Payment/PaymentPlatformApplicationClient.js +88 -6
  61. package/sdk/platform/Payment/PaymentPlatformApplicationValidator.d.ts +28 -3
  62. package/sdk/platform/Payment/PaymentPlatformApplicationValidator.js +22 -2
  63. package/sdk/platform/Payment/PaymentPlatformModel.d.ts +376 -11
  64. package/sdk/platform/Payment/PaymentPlatformModel.js +243 -10
  65. package/sdk/platform/PlatformApplicationClient.d.ts +0 -2
  66. package/sdk/platform/PlatformApplicationClient.js +0 -4
  67. package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationClient.d.ts +0 -13
  68. package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationClient.js +0 -82
  69. package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationValidator.d.ts +1 -10
  70. package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationValidator.js +0 -12
  71. package/sdk/platform/Serviceability/ServiceabilityPlatformModel.d.ts +212 -28
  72. package/sdk/platform/Serviceability/ServiceabilityPlatformModel.js +133 -13
  73. package/sdk/platform/User/UserPlatformModel.d.ts +2 -2
  74. package/sdk/platform/User/UserPlatformModel.js +4 -4
  75. package/sdk/platform/Webhook/WebhookPlatformModel.d.ts +29 -0
  76. package/sdk/platform/Webhook/WebhookPlatformModel.js +13 -0
  77. package/sdk/platform/index.d.ts +0 -1
  78. package/sdk/platform/index.js +0 -2
  79. package/sdk/public/Configuration/ConfigurationPublicModel.d.ts +27 -1
  80. package/sdk/public/Configuration/ConfigurationPublicModel.js +19 -0
  81. package/sdk/public/Webhook/WebhookPublicModel.d.ts +29 -0
  82. package/sdk/public/Webhook/WebhookPublicModel.js +13 -0
  83. package/sdk/application/Rewards/RewardsApplicationClient.d.ts +0 -79
  84. package/sdk/application/Rewards/RewardsApplicationClient.js +0 -315
  85. package/sdk/platform/Rewards/RewardsPlatformApplicationClient.d.ts +0 -136
  86. package/sdk/platform/Rewards/RewardsPlatformApplicationClient.js +0 -976
  87. package/sdk/platform/Rewards/RewardsPlatformApplicationValidator.d.ts +0 -152
  88. package/sdk/platform/Rewards/RewardsPlatformApplicationValidator.js +0 -157
  89. package/sdk/platform/Rewards/RewardsPlatformModel.d.ts +0 -387
  90. package/sdk/platform/Rewards/RewardsPlatformModel.js +0 -410
@@ -1,976 +0,0 @@
1
- const PlatformAPIClient = require("../PlatformAPIClient");
2
- const {
3
- FDKClientValidationError,
4
- FDKResponseValidationError,
5
- } = require("../../common/FDKError");
6
- const Paginator = require("../../common/Paginator");
7
- const RewardsPlatformApplicationValidator = require("./RewardsPlatformApplicationValidator");
8
- const RewardsPlatformModel = require("./RewardsPlatformModel");
9
- const { Logger } = require("./../../common/Logger");
10
- const Joi = require("joi");
11
-
12
- class Rewards {
13
- constructor(config, applicationId) {
14
- this.config = config;
15
- this.applicationId = applicationId;
16
- }
17
-
18
- /**
19
- * @param {RewardsPlatformApplicationValidator.GetGiveawayByIdParam} arg - Arg object
20
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
21
- * @param {import("../PlatformAPIClient").Options} - Options
22
- * @returns {Promise<RewardsPlatformModel.Giveaway>} - Success response
23
- * @name getGiveawayById
24
- * @summary: Get a giveaway
25
- * @description: Retrieve specific giveaway details by its unique identifier. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/rewards/getGiveawayById/).
26
- */
27
- async getGiveawayById(
28
- { id, requestHeaders } = { requestHeaders: {} },
29
- { responseHeaders } = { responseHeaders: false }
30
- ) {
31
- const {
32
- error,
33
- } = RewardsPlatformApplicationValidator.getGiveawayById().validate(
34
- {
35
- id,
36
- },
37
- { abortEarly: false, allowUnknown: true }
38
- );
39
- if (error) {
40
- return Promise.reject(new FDKClientValidationError(error));
41
- }
42
-
43
- // Showing warrnings if extra unknown parameters are found
44
- const {
45
- error: warrning,
46
- } = RewardsPlatformApplicationValidator.getGiveawayById().validate(
47
- {
48
- id,
49
- },
50
- { abortEarly: false, allowUnknown: false }
51
- );
52
- if (warrning) {
53
- Logger({
54
- level: "WARN",
55
- message: `Parameter Validation warrnings for platform > Rewards > getGiveawayById \n ${warrning}`,
56
- });
57
- }
58
-
59
- const query_params = {};
60
-
61
- const response = await PlatformAPIClient.execute(
62
- this.config,
63
- "get",
64
- `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/giveaways/${id}`,
65
- query_params,
66
- undefined,
67
- requestHeaders,
68
- { responseHeaders }
69
- );
70
-
71
- let responseData = response;
72
- if (responseHeaders) {
73
- responseData = response[0];
74
- }
75
-
76
- const {
77
- error: res_error,
78
- } = RewardsPlatformModel.Giveaway().validate(responseData, {
79
- abortEarly: false,
80
- allowUnknown: true,
81
- });
82
-
83
- if (res_error) {
84
- if (this.config.options.strictResponseCheck === true) {
85
- return Promise.reject(new FDKResponseValidationError(res_error));
86
- } else {
87
- Logger({
88
- level: "WARN",
89
- message: `Response Validation Warnings for platform > Rewards > getGiveawayById \n ${res_error}`,
90
- });
91
- }
92
- }
93
-
94
- return response;
95
- }
96
-
97
- /**
98
- * @param {RewardsPlatformApplicationValidator.GetOfferByNameParam} arg - Arg object
99
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
100
- * @param {import("../PlatformAPIClient").Options} - Options
101
- * @returns {Promise<RewardsPlatformModel.Offer>} - Success response
102
- * @name getOfferByName
103
- * @summary: Get offer by name
104
- * @description: Retrieve an offer by its name. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/rewards/getOfferByName/).
105
- */
106
- async getOfferByName(
107
- { name, requestHeaders } = { requestHeaders: {} },
108
- { responseHeaders } = { responseHeaders: false }
109
- ) {
110
- const {
111
- error,
112
- } = RewardsPlatformApplicationValidator.getOfferByName().validate(
113
- { name },
114
- { abortEarly: false, allowUnknown: true }
115
- );
116
- if (error) {
117
- return Promise.reject(new FDKClientValidationError(error));
118
- }
119
-
120
- // Showing warrnings if extra unknown parameters are found
121
- const {
122
- error: warrning,
123
- } = RewardsPlatformApplicationValidator.getOfferByName().validate(
124
- { name },
125
- { abortEarly: false, allowUnknown: false }
126
- );
127
- if (warrning) {
128
- Logger({
129
- level: "WARN",
130
- message: `Parameter Validation warrnings for platform > Rewards > getOfferByName \n ${warrning}`,
131
- });
132
- }
133
-
134
- const query_params = {};
135
-
136
- const response = await PlatformAPIClient.execute(
137
- this.config,
138
- "get",
139
- `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers/${name}/`,
140
- query_params,
141
- undefined,
142
- requestHeaders,
143
- { responseHeaders }
144
- );
145
-
146
- let responseData = response;
147
- if (responseHeaders) {
148
- responseData = response[0];
149
- }
150
-
151
- const {
152
- error: res_error,
153
- } = RewardsPlatformModel.Offer().validate(responseData, {
154
- abortEarly: false,
155
- allowUnknown: true,
156
- });
157
-
158
- if (res_error) {
159
- if (this.config.options.strictResponseCheck === true) {
160
- return Promise.reject(new FDKResponseValidationError(res_error));
161
- } else {
162
- Logger({
163
- level: "WARN",
164
- message: `Response Validation Warnings for platform > Rewards > getOfferByName \n ${res_error}`,
165
- });
166
- }
167
- }
168
-
169
- return response;
170
- }
171
-
172
- /**
173
- * @param {RewardsPlatformApplicationValidator.GetRewardsConfigurationParam} arg
174
- * - Arg object
175
- *
176
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
177
- * @param {import("../PlatformAPIClient").Options} - Options
178
- * @returns {Promise<RewardsPlatformModel.ConfigurationRes>} - Success response
179
- * @name getRewardsConfiguration
180
- * @summary: Get rewards configuration
181
- * @description: Retrieve the configuration settings for the rewards program. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/rewards/getRewardsConfiguration/).
182
- */
183
- async getRewardsConfiguration(
184
- { requestHeaders } = { requestHeaders: {} },
185
- { responseHeaders } = { responseHeaders: false }
186
- ) {
187
- const {
188
- error,
189
- } = RewardsPlatformApplicationValidator.getRewardsConfiguration().validate(
190
- {},
191
- { abortEarly: false, allowUnknown: true }
192
- );
193
- if (error) {
194
- return Promise.reject(new FDKClientValidationError(error));
195
- }
196
-
197
- // Showing warrnings if extra unknown parameters are found
198
- const {
199
- error: warrning,
200
- } = RewardsPlatformApplicationValidator.getRewardsConfiguration().validate(
201
- {},
202
- { abortEarly: false, allowUnknown: false }
203
- );
204
- if (warrning) {
205
- Logger({
206
- level: "WARN",
207
- message: `Parameter Validation warrnings for platform > Rewards > getRewardsConfiguration \n ${warrning}`,
208
- });
209
- }
210
-
211
- const query_params = {};
212
-
213
- const response = await PlatformAPIClient.execute(
214
- this.config,
215
- "get",
216
- `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/configuration/`,
217
- query_params,
218
- undefined,
219
- requestHeaders,
220
- { responseHeaders }
221
- );
222
-
223
- let responseData = response;
224
- if (responseHeaders) {
225
- responseData = response[0];
226
- }
227
-
228
- const {
229
- error: res_error,
230
- } = RewardsPlatformModel.ConfigurationRes().validate(responseData, {
231
- abortEarly: false,
232
- allowUnknown: true,
233
- });
234
-
235
- if (res_error) {
236
- if (this.config.options.strictResponseCheck === true) {
237
- return Promise.reject(new FDKResponseValidationError(res_error));
238
- } else {
239
- Logger({
240
- level: "WARN",
241
- message: `Response Validation Warnings for platform > Rewards > getRewardsConfiguration \n ${res_error}`,
242
- });
243
- }
244
- }
245
-
246
- return response;
247
- }
248
-
249
- /**
250
- * @param {RewardsPlatformApplicationValidator.GetUserDetailsParam} arg - Arg object
251
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
252
- * @param {import("../PlatformAPIClient").Options} - Options
253
- * @returns {Promise<RewardsPlatformModel.UserRes>} - Success response
254
- * @name getUserDetails
255
- * @summary: Get a user
256
- * @description: Retrieve comprehensive details about a user in the rewards program. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/rewards/getUserDetails/).
257
- */
258
- async getUserDetails(
259
- { userId, requestHeaders } = { requestHeaders: {} },
260
- { responseHeaders } = { responseHeaders: false }
261
- ) {
262
- const {
263
- error,
264
- } = RewardsPlatformApplicationValidator.getUserDetails().validate(
265
- { userId },
266
- { abortEarly: false, allowUnknown: true }
267
- );
268
- if (error) {
269
- return Promise.reject(new FDKClientValidationError(error));
270
- }
271
-
272
- // Showing warrnings if extra unknown parameters are found
273
- const {
274
- error: warrning,
275
- } = RewardsPlatformApplicationValidator.getUserDetails().validate(
276
- { userId },
277
- { abortEarly: false, allowUnknown: false }
278
- );
279
- if (warrning) {
280
- Logger({
281
- level: "WARN",
282
- message: `Parameter Validation warrnings for platform > Rewards > getUserDetails \n ${warrning}`,
283
- });
284
- }
285
-
286
- const query_params = {};
287
-
288
- const response = await PlatformAPIClient.execute(
289
- this.config,
290
- "get",
291
- `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/users/${userId}/`,
292
- query_params,
293
- undefined,
294
- requestHeaders,
295
- { responseHeaders }
296
- );
297
-
298
- let responseData = response;
299
- if (responseHeaders) {
300
- responseData = response[0];
301
- }
302
-
303
- const {
304
- error: res_error,
305
- } = RewardsPlatformModel.UserRes().validate(responseData, {
306
- abortEarly: false,
307
- allowUnknown: true,
308
- });
309
-
310
- if (res_error) {
311
- if (this.config.options.strictResponseCheck === true) {
312
- return Promise.reject(new FDKResponseValidationError(res_error));
313
- } else {
314
- Logger({
315
- level: "WARN",
316
- message: `Response Validation Warnings for platform > Rewards > getUserDetails \n ${res_error}`,
317
- });
318
- }
319
- }
320
-
321
- return response;
322
- }
323
-
324
- /**
325
- * @param {RewardsPlatformApplicationValidator.GetUserPointsHistoryParam} arg
326
- * - Arg object
327
- *
328
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
329
- * @param {import("../PlatformAPIClient").Options} - Options
330
- * @returns {Promise<RewardsPlatformModel.HistoryRes>} - Success response
331
- * @name getUserPointsHistory
332
- * @summary: Get reward user points history
333
- * @description: Retrieve the history of points earned and redeemed by a user. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/rewards/getUserPointsHistory/).
334
- */
335
- async getUserPointsHistory(
336
- { userId, pageId, pageSize, requestHeaders } = { requestHeaders: {} },
337
- { responseHeaders } = { responseHeaders: false }
338
- ) {
339
- const {
340
- error,
341
- } = RewardsPlatformApplicationValidator.getUserPointsHistory().validate(
342
- {
343
- userId,
344
-
345
- pageId,
346
- pageSize,
347
- },
348
- { abortEarly: false, allowUnknown: true }
349
- );
350
- if (error) {
351
- return Promise.reject(new FDKClientValidationError(error));
352
- }
353
-
354
- // Showing warrnings if extra unknown parameters are found
355
- const {
356
- error: warrning,
357
- } = RewardsPlatformApplicationValidator.getUserPointsHistory().validate(
358
- {
359
- userId,
360
-
361
- pageId,
362
- pageSize,
363
- },
364
- { abortEarly: false, allowUnknown: false }
365
- );
366
- if (warrning) {
367
- Logger({
368
- level: "WARN",
369
- message: `Parameter Validation warrnings for platform > Rewards > getUserPointsHistory \n ${warrning}`,
370
- });
371
- }
372
-
373
- const query_params = {};
374
- query_params["page_id"] = pageId;
375
- query_params["page_size"] = pageSize;
376
-
377
- const response = await PlatformAPIClient.execute(
378
- this.config,
379
- "get",
380
- `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/users/${userId}/points/history/`,
381
- query_params,
382
- undefined,
383
- requestHeaders,
384
- { responseHeaders }
385
- );
386
-
387
- let responseData = response;
388
- if (responseHeaders) {
389
- responseData = response[0];
390
- }
391
-
392
- const {
393
- error: res_error,
394
- } = RewardsPlatformModel.HistoryRes().validate(responseData, {
395
- abortEarly: false,
396
- allowUnknown: true,
397
- });
398
-
399
- if (res_error) {
400
- if (this.config.options.strictResponseCheck === true) {
401
- return Promise.reject(new FDKResponseValidationError(res_error));
402
- } else {
403
- Logger({
404
- level: "WARN",
405
- message: `Response Validation Warnings for platform > Rewards > getUserPointsHistory \n ${res_error}`,
406
- });
407
- }
408
- }
409
-
410
- return response;
411
- }
412
-
413
- /**
414
- * @param {RewardsPlatformApplicationValidator.SaveGiveAwayParam} arg - Arg object
415
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
416
- * @param {import("../PlatformAPIClient").Options} - Options
417
- * @returns {Promise<RewardsPlatformModel.Giveaway>} - Success response
418
- * @name saveGiveAway
419
- * @summary: Create a giveaway
420
- * @description: Store and manage details of a giveaway. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/rewards/saveGiveAway/).
421
- */
422
- async saveGiveAway(
423
- { body, requestHeaders } = { requestHeaders: {} },
424
- { responseHeaders } = { responseHeaders: false }
425
- ) {
426
- const {
427
- error,
428
- } = RewardsPlatformApplicationValidator.saveGiveAway().validate(
429
- {
430
- body,
431
- },
432
- { abortEarly: false, allowUnknown: true }
433
- );
434
- if (error) {
435
- return Promise.reject(new FDKClientValidationError(error));
436
- }
437
-
438
- // Showing warrnings if extra unknown parameters are found
439
- const {
440
- error: warrning,
441
- } = RewardsPlatformApplicationValidator.saveGiveAway().validate(
442
- {
443
- body,
444
- },
445
- { abortEarly: false, allowUnknown: false }
446
- );
447
- if (warrning) {
448
- Logger({
449
- level: "WARN",
450
- message: `Parameter Validation warrnings for platform > Rewards > saveGiveAway \n ${warrning}`,
451
- });
452
- }
453
-
454
- const query_params = {};
455
-
456
- const response = await PlatformAPIClient.execute(
457
- this.config,
458
- "post",
459
- `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/giveaways`,
460
- query_params,
461
- body,
462
- requestHeaders,
463
- { responseHeaders }
464
- );
465
-
466
- let responseData = response;
467
- if (responseHeaders) {
468
- responseData = response[0];
469
- }
470
-
471
- const {
472
- error: res_error,
473
- } = RewardsPlatformModel.Giveaway().validate(responseData, {
474
- abortEarly: false,
475
- allowUnknown: true,
476
- });
477
-
478
- if (res_error) {
479
- if (this.config.options.strictResponseCheck === true) {
480
- return Promise.reject(new FDKResponseValidationError(res_error));
481
- } else {
482
- Logger({
483
- level: "WARN",
484
- message: `Response Validation Warnings for platform > Rewards > saveGiveAway \n ${res_error}`,
485
- });
486
- }
487
- }
488
-
489
- return response;
490
- }
491
-
492
- /**
493
- * @param {RewardsPlatformApplicationValidator.SetRewardsConfigurationParam} arg
494
- * - Arg object
495
- *
496
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
497
- * @param {import("../PlatformAPIClient").Options} - Options
498
- * @returns {Promise<RewardsPlatformModel.SetConfigurationRes>} - Success response
499
- * @name setRewardsConfiguration
500
- * @summary: Set rewards configuration
501
- * @description: Configure and modify the settings for the rewards program. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/rewards/setRewardsConfiguration/).
502
- */
503
- async setRewardsConfiguration(
504
- { body, requestHeaders } = { requestHeaders: {} },
505
- { responseHeaders } = { responseHeaders: false }
506
- ) {
507
- const {
508
- error,
509
- } = RewardsPlatformApplicationValidator.setRewardsConfiguration().validate(
510
- {
511
- body,
512
- },
513
- { abortEarly: false, allowUnknown: true }
514
- );
515
- if (error) {
516
- return Promise.reject(new FDKClientValidationError(error));
517
- }
518
-
519
- // Showing warrnings if extra unknown parameters are found
520
- const {
521
- error: warrning,
522
- } = RewardsPlatformApplicationValidator.setRewardsConfiguration().validate(
523
- {
524
- body,
525
- },
526
- { abortEarly: false, allowUnknown: false }
527
- );
528
- if (warrning) {
529
- Logger({
530
- level: "WARN",
531
- message: `Parameter Validation warrnings for platform > Rewards > setRewardsConfiguration \n ${warrning}`,
532
- });
533
- }
534
-
535
- const query_params = {};
536
-
537
- const response = await PlatformAPIClient.execute(
538
- this.config,
539
- "post",
540
- `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/configuration/`,
541
- query_params,
542
- body,
543
- requestHeaders,
544
- { responseHeaders }
545
- );
546
-
547
- let responseData = response;
548
- if (responseHeaders) {
549
- responseData = response[0];
550
- }
551
-
552
- const {
553
- error: res_error,
554
- } = RewardsPlatformModel.SetConfigurationRes().validate(responseData, {
555
- abortEarly: false,
556
- allowUnknown: true,
557
- });
558
-
559
- if (res_error) {
560
- if (this.config.options.strictResponseCheck === true) {
561
- return Promise.reject(new FDKResponseValidationError(res_error));
562
- } else {
563
- Logger({
564
- level: "WARN",
565
- message: `Response Validation Warnings for platform > Rewards > setRewardsConfiguration \n ${res_error}`,
566
- });
567
- }
568
- }
569
-
570
- return response;
571
- }
572
-
573
- /**
574
- * @param {RewardsPlatformApplicationValidator.ShowGiveawaysParam} arg - Arg object
575
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
576
- * @param {import("../PlatformAPIClient").Options} - Options
577
- * @returns {Promise<RewardsPlatformModel.ListGiveaway>} - Success response
578
- * @name showGiveaways
579
- * @summary: List giveaways
580
- * @description: Retrieve and display available giveaways. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/rewards/showGiveaways/).
581
- */
582
- async showGiveaways(
583
- { pageId, pageSize, requestHeaders } = { requestHeaders: {} },
584
- { responseHeaders } = { responseHeaders: false }
585
- ) {
586
- const {
587
- error,
588
- } = RewardsPlatformApplicationValidator.showGiveaways().validate(
589
- {
590
- pageId,
591
- pageSize,
592
- },
593
- { abortEarly: false, allowUnknown: true }
594
- );
595
- if (error) {
596
- return Promise.reject(new FDKClientValidationError(error));
597
- }
598
-
599
- // Showing warrnings if extra unknown parameters are found
600
- const {
601
- error: warrning,
602
- } = RewardsPlatformApplicationValidator.showGiveaways().validate(
603
- {
604
- pageId,
605
- pageSize,
606
- },
607
- { abortEarly: false, allowUnknown: false }
608
- );
609
- if (warrning) {
610
- Logger({
611
- level: "WARN",
612
- message: `Parameter Validation warrnings for platform > Rewards > showGiveaways \n ${warrning}`,
613
- });
614
- }
615
-
616
- const query_params = {};
617
- query_params["page_id"] = pageId;
618
- query_params["page_size"] = pageSize;
619
-
620
- const response = await PlatformAPIClient.execute(
621
- this.config,
622
- "get",
623
- `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/giveaways`,
624
- query_params,
625
- undefined,
626
- requestHeaders,
627
- { responseHeaders }
628
- );
629
-
630
- let responseData = response;
631
- if (responseHeaders) {
632
- responseData = response[0];
633
- }
634
-
635
- const {
636
- error: res_error,
637
- } = RewardsPlatformModel.ListGiveaway().validate(responseData, {
638
- abortEarly: false,
639
- allowUnknown: true,
640
- });
641
-
642
- if (res_error) {
643
- if (this.config.options.strictResponseCheck === true) {
644
- return Promise.reject(new FDKResponseValidationError(res_error));
645
- } else {
646
- Logger({
647
- level: "WARN",
648
- message: `Response Validation Warnings for platform > Rewards > showGiveaways \n ${res_error}`,
649
- });
650
- }
651
- }
652
-
653
- return response;
654
- }
655
-
656
- /**
657
- * @param {RewardsPlatformApplicationValidator.ShowOffersParam} arg - Arg object
658
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
659
- * @param {import("../PlatformAPIClient").Options} - Options
660
- * @returns {Promise<RewardsPlatformModel.Offer[]>} - Success response
661
- * @name showOffers
662
- * @summary: List offers
663
- * @description: Display available offers for users. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/rewards/showOffers/).
664
- */
665
- async showOffers(
666
- { requestHeaders } = { requestHeaders: {} },
667
- { responseHeaders } = { responseHeaders: false }
668
- ) {
669
- const { error } = RewardsPlatformApplicationValidator.showOffers().validate(
670
- {},
671
- { abortEarly: false, allowUnknown: true }
672
- );
673
- if (error) {
674
- return Promise.reject(new FDKClientValidationError(error));
675
- }
676
-
677
- // Showing warrnings if extra unknown parameters are found
678
- const {
679
- error: warrning,
680
- } = RewardsPlatformApplicationValidator.showOffers().validate(
681
- {},
682
- { abortEarly: false, allowUnknown: false }
683
- );
684
- if (warrning) {
685
- Logger({
686
- level: "WARN",
687
- message: `Parameter Validation warrnings for platform > Rewards > showOffers \n ${warrning}`,
688
- });
689
- }
690
-
691
- const query_params = {};
692
-
693
- const response = await PlatformAPIClient.execute(
694
- this.config,
695
- "get",
696
- `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers/`,
697
- query_params,
698
- undefined,
699
- requestHeaders,
700
- { responseHeaders }
701
- );
702
-
703
- let responseData = response;
704
- if (responseHeaders) {
705
- responseData = response[0];
706
- }
707
-
708
- const { error: res_error } = Joi.array()
709
- .items(RewardsPlatformModel.Offer())
710
- .validate(responseData, { abortEarly: false, allowUnknown: true });
711
-
712
- if (res_error) {
713
- if (this.config.options.strictResponseCheck === true) {
714
- return Promise.reject(new FDKResponseValidationError(res_error));
715
- } else {
716
- Logger({
717
- level: "WARN",
718
- message: `Response Validation Warnings for platform > Rewards > showOffers \n ${res_error}`,
719
- });
720
- }
721
- }
722
-
723
- return response;
724
- }
725
-
726
- /**
727
- * @param {RewardsPlatformApplicationValidator.UpdateGiveAwayParam} arg - Arg object
728
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
729
- * @param {import("../PlatformAPIClient").Options} - Options
730
- * @returns {Promise<RewardsPlatformModel.Giveaway>} - Success response
731
- * @name updateGiveAway
732
- * @summary: Update a giveaway
733
- * @description: Modify and update information about a giveaway. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/rewards/updateGiveAway/).
734
- */
735
- async updateGiveAway(
736
- { id, body, requestHeaders } = { requestHeaders: {} },
737
- { responseHeaders } = { responseHeaders: false }
738
- ) {
739
- const {
740
- error,
741
- } = RewardsPlatformApplicationValidator.updateGiveAway().validate(
742
- {
743
- id,
744
- body,
745
- },
746
- { abortEarly: false, allowUnknown: true }
747
- );
748
- if (error) {
749
- return Promise.reject(new FDKClientValidationError(error));
750
- }
751
-
752
- // Showing warrnings if extra unknown parameters are found
753
- const {
754
- error: warrning,
755
- } = RewardsPlatformApplicationValidator.updateGiveAway().validate(
756
- {
757
- id,
758
- body,
759
- },
760
- { abortEarly: false, allowUnknown: false }
761
- );
762
- if (warrning) {
763
- Logger({
764
- level: "WARN",
765
- message: `Parameter Validation warrnings for platform > Rewards > updateGiveAway \n ${warrning}`,
766
- });
767
- }
768
-
769
- const query_params = {};
770
-
771
- const response = await PlatformAPIClient.execute(
772
- this.config,
773
- "put",
774
- `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/giveaways/${id}`,
775
- query_params,
776
- body,
777
- requestHeaders,
778
- { responseHeaders }
779
- );
780
-
781
- let responseData = response;
782
- if (responseHeaders) {
783
- responseData = response[0];
784
- }
785
-
786
- const {
787
- error: res_error,
788
- } = RewardsPlatformModel.Giveaway().validate(responseData, {
789
- abortEarly: false,
790
- allowUnknown: true,
791
- });
792
-
793
- if (res_error) {
794
- if (this.config.options.strictResponseCheck === true) {
795
- return Promise.reject(new FDKResponseValidationError(res_error));
796
- } else {
797
- Logger({
798
- level: "WARN",
799
- message: `Response Validation Warnings for platform > Rewards > updateGiveAway \n ${res_error}`,
800
- });
801
- }
802
- }
803
-
804
- return response;
805
- }
806
-
807
- /**
808
- * @param {RewardsPlatformApplicationValidator.UpdateOfferByNameParam} arg
809
- * - Arg object
810
- *
811
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
812
- * @param {import("../PlatformAPIClient").Options} - Options
813
- * @returns {Promise<RewardsPlatformModel.Offer>} - Success response
814
- * @name updateOfferByName
815
- * @summary: Update offer by name
816
- * @description: Modify and manage an offer using its name. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/rewards/updateOfferByName/).
817
- */
818
- async updateOfferByName(
819
- { name, body, requestHeaders } = { requestHeaders: {} },
820
- { responseHeaders } = { responseHeaders: false }
821
- ) {
822
- const {
823
- error,
824
- } = RewardsPlatformApplicationValidator.updateOfferByName().validate(
825
- {
826
- name,
827
-
828
- body,
829
- },
830
- { abortEarly: false, allowUnknown: true }
831
- );
832
- if (error) {
833
- return Promise.reject(new FDKClientValidationError(error));
834
- }
835
-
836
- // Showing warrnings if extra unknown parameters are found
837
- const {
838
- error: warrning,
839
- } = RewardsPlatformApplicationValidator.updateOfferByName().validate(
840
- {
841
- name,
842
-
843
- body,
844
- },
845
- { abortEarly: false, allowUnknown: false }
846
- );
847
- if (warrning) {
848
- Logger({
849
- level: "WARN",
850
- message: `Parameter Validation warrnings for platform > Rewards > updateOfferByName \n ${warrning}`,
851
- });
852
- }
853
-
854
- const query_params = {};
855
-
856
- const response = await PlatformAPIClient.execute(
857
- this.config,
858
- "put",
859
- `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers/${name}/`,
860
- query_params,
861
- body,
862
- requestHeaders,
863
- { responseHeaders }
864
- );
865
-
866
- let responseData = response;
867
- if (responseHeaders) {
868
- responseData = response[0];
869
- }
870
-
871
- const {
872
- error: res_error,
873
- } = RewardsPlatformModel.Offer().validate(responseData, {
874
- abortEarly: false,
875
- allowUnknown: true,
876
- });
877
-
878
- if (res_error) {
879
- if (this.config.options.strictResponseCheck === true) {
880
- return Promise.reject(new FDKResponseValidationError(res_error));
881
- } else {
882
- Logger({
883
- level: "WARN",
884
- message: `Response Validation Warnings for platform > Rewards > updateOfferByName \n ${res_error}`,
885
- });
886
- }
887
- }
888
-
889
- return response;
890
- }
891
-
892
- /**
893
- * @param {RewardsPlatformApplicationValidator.UpdateUserStatusParam} arg - Arg object
894
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
895
- * @param {import("../PlatformAPIClient").Options} - Options
896
- * @returns {Promise<RewardsPlatformModel.AppUser>} - Success response
897
- * @name updateUserStatus
898
- * @summary: Update user status
899
- * @description: Change and update the status of a user in the rewards system. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/rewards/updateUserStatus/).
900
- */
901
- async updateUserStatus(
902
- { userId, body, requestHeaders } = { requestHeaders: {} },
903
- { responseHeaders } = { responseHeaders: false }
904
- ) {
905
- const {
906
- error,
907
- } = RewardsPlatformApplicationValidator.updateUserStatus().validate(
908
- {
909
- userId,
910
-
911
- body,
912
- },
913
- { abortEarly: false, allowUnknown: true }
914
- );
915
- if (error) {
916
- return Promise.reject(new FDKClientValidationError(error));
917
- }
918
-
919
- // Showing warrnings if extra unknown parameters are found
920
- const {
921
- error: warrning,
922
- } = RewardsPlatformApplicationValidator.updateUserStatus().validate(
923
- {
924
- userId,
925
-
926
- body,
927
- },
928
- { abortEarly: false, allowUnknown: false }
929
- );
930
- if (warrning) {
931
- Logger({
932
- level: "WARN",
933
- message: `Parameter Validation warrnings for platform > Rewards > updateUserStatus \n ${warrning}`,
934
- });
935
- }
936
-
937
- const query_params = {};
938
-
939
- const response = await PlatformAPIClient.execute(
940
- this.config,
941
- "patch",
942
- `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/users/${userId}/`,
943
- query_params,
944
- body,
945
- requestHeaders,
946
- { responseHeaders }
947
- );
948
-
949
- let responseData = response;
950
- if (responseHeaders) {
951
- responseData = response[0];
952
- }
953
-
954
- const {
955
- error: res_error,
956
- } = RewardsPlatformModel.AppUser().validate(responseData, {
957
- abortEarly: false,
958
- allowUnknown: true,
959
- });
960
-
961
- if (res_error) {
962
- if (this.config.options.strictResponseCheck === true) {
963
- return Promise.reject(new FDKResponseValidationError(res_error));
964
- } else {
965
- Logger({
966
- level: "WARN",
967
- message: `Response Validation Warnings for platform > Rewards > updateUserStatus \n ${res_error}`,
968
- });
969
- }
970
- }
971
-
972
- return response;
973
- }
974
- }
975
-
976
- module.exports = Rewards;