@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.
Files changed (134) hide show
  1. package/documentation/application/CART.md +251 -251
  2. package/documentation/application/CATALOG.md +414 -414
  3. package/documentation/application/CONTENT.md +15 -1
  4. package/documentation/application/ORDER.md +290 -290
  5. package/documentation/application/PAYMENT.md +255 -255
  6. package/documentation/application/POSCART.md +297 -297
  7. package/documentation/platform/CART.md +499 -499
  8. package/documentation/platform/CATALOG.md +3088 -2702
  9. package/documentation/platform/COMPANYPROFILE.md +201 -201
  10. package/documentation/platform/CONTENT.md +123 -1
  11. package/documentation/platform/ORDER.md +1233 -1158
  12. package/documentation/platform/PARTNER.md +7 -7
  13. package/documentation/platform/PAYMENT.md +83 -83
  14. package/package.json +1 -1
  15. package/sdk/application/ApplicationConfig.js +1 -1
  16. package/sdk/application/Cart/CartApplicationClient.js +619 -108
  17. package/sdk/application/Cart/CartApplicationModel.d.ts +7 -7
  18. package/sdk/application/Cart/CartApplicationModel.js +335 -335
  19. package/sdk/application/Catalog/CatalogApplicationClient.d.ts +1 -1
  20. package/sdk/application/Catalog/CatalogApplicationClient.js +730 -134
  21. package/sdk/application/Catalog/CatalogApplicationModel.d.ts +21 -21
  22. package/sdk/application/Catalog/CatalogApplicationModel.js +547 -547
  23. package/sdk/application/Common/CommonApplicationClient.js +48 -8
  24. package/sdk/application/Communication/CommunicationApplicationClient.js +75 -14
  25. package/sdk/application/Configuration/ConfigurationApplicationClient.d.ts +1 -1
  26. package/sdk/application/Configuration/ConfigurationApplicationClient.js +392 -66
  27. package/sdk/application/Content/ContentApplicationClient.js +444 -76
  28. package/sdk/application/Content/ContentApplicationModel.d.ts +1 -0
  29. package/sdk/application/Content/ContentApplicationModel.js +11 -1
  30. package/sdk/application/FileStorage/FileStorageApplicationClient.js +74 -12
  31. package/sdk/application/Lead/LeadApplicationClient.js +164 -30
  32. package/sdk/application/Logistic/LogisticApplicationClient.js +98 -16
  33. package/sdk/application/Order/OrderApplicationClient.d.ts +1 -1
  34. package/sdk/application/Order/OrderApplicationClient.js +287 -54
  35. package/sdk/application/Order/OrderApplicationModel.d.ts +19 -19
  36. package/sdk/application/Order/OrderApplicationModel.js +357 -357
  37. package/sdk/application/Payment/PaymentApplicationClient.js +961 -186
  38. package/sdk/application/Payment/PaymentApplicationModel.d.ts +3 -3
  39. package/sdk/application/Payment/PaymentApplicationModel.js +352 -352
  40. package/sdk/application/PosCart/PosCartApplicationClient.js +645 -114
  41. package/sdk/application/PosCart/PosCartApplicationModel.d.ts +15 -15
  42. package/sdk/application/PosCart/PosCartApplicationModel.js +389 -389
  43. package/sdk/application/Rewards/RewardsApplicationClient.js +168 -28
  44. package/sdk/application/Share/ShareApplicationClient.js +157 -32
  45. package/sdk/application/Theme/ThemeApplicationClient.js +94 -16
  46. package/sdk/application/User/UserApplicationClient.js +806 -148
  47. package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.d.ts +16 -8
  48. package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.js +191 -34
  49. package/sdk/platform/Analytics/AnalyticsPlatformClient.d.ts +8 -4
  50. package/sdk/platform/Analytics/AnalyticsPlatformClient.js +103 -16
  51. package/sdk/platform/AuditTrail/AuditTrailPlatformClient.d.ts +8 -4
  52. package/sdk/platform/AuditTrail/AuditTrailPlatformClient.js +103 -16
  53. package/sdk/platform/Billing/BillingPlatformClient.d.ts +24 -12
  54. package/sdk/platform/Billing/BillingPlatformClient.js +299 -54
  55. package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +34 -17
  56. package/sdk/platform/Cart/CartPlatformApplicationClient.js +409 -72
  57. package/sdk/platform/Cart/CartPlatformModel.d.ts +35 -35
  58. package/sdk/platform/Cart/CartPlatformModel.js +617 -617
  59. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.d.ts +167 -114
  60. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.js +1562 -453
  61. package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.d.ts +8 -8
  62. package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.js +39 -39
  63. package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +314 -196
  64. package/sdk/platform/Catalog/CatalogPlatformClient.js +2459 -718
  65. package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +103 -94
  66. package/sdk/platform/Catalog/CatalogPlatformModel.js +2063 -1797
  67. package/sdk/platform/Catalog/CatalogPlatformValidator.d.ts +17 -15
  68. package/sdk/platform/Catalog/CatalogPlatformValidator.js +95 -76
  69. package/sdk/platform/Common/CommonPlatformClient.d.ts +4 -2
  70. package/sdk/platform/Common/CommonPlatformClient.js +51 -8
  71. package/sdk/platform/Communication/CommunicationPlatformApplicationClient.d.ts +80 -40
  72. package/sdk/platform/Communication/CommunicationPlatformApplicationClient.js +1000 -168
  73. package/sdk/platform/Communication/CommunicationPlatformClient.d.ts +2 -1
  74. package/sdk/platform/Communication/CommunicationPlatformClient.js +28 -4
  75. package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.d.ts +27 -14
  76. package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.js +335 -54
  77. package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.d.ts +10 -10
  78. package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.js +278 -278
  79. package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.d.ts +56 -28
  80. package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.js +702 -118
  81. package/sdk/platform/Configuration/ConfigurationPlatformClient.d.ts +36 -18
  82. package/sdk/platform/Configuration/ConfigurationPlatformClient.js +457 -82
  83. package/sdk/platform/Content/ContentPlatformApplicationClient.d.ts +148 -67
  84. package/sdk/platform/Content/ContentPlatformApplicationClient.js +1724 -284
  85. package/sdk/platform/Content/ContentPlatformApplicationValidator.d.ts +1 -0
  86. package/sdk/platform/Content/ContentPlatformApplicationValidator.js +7 -0
  87. package/sdk/platform/Content/ContentPlatformModel.d.ts +4 -0
  88. package/sdk/platform/Content/ContentPlatformModel.js +43 -1
  89. package/sdk/platform/Discount/DiscountPlatformClient.d.ts +21 -10
  90. package/sdk/platform/Discount/DiscountPlatformClient.js +270 -44
  91. package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.d.ts +8 -4
  92. package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.js +102 -16
  93. package/sdk/platform/FileStorage/FileStoragePlatformClient.d.ts +12 -6
  94. package/sdk/platform/FileStorage/FileStoragePlatformClient.js +150 -24
  95. package/sdk/platform/Inventory/InventoryPlatformClient.d.ts +27 -14
  96. package/sdk/platform/Inventory/InventoryPlatformClient.js +316 -52
  97. package/sdk/platform/Lead/LeadPlatformApplicationClient.d.ts +26 -13
  98. package/sdk/platform/Lead/LeadPlatformApplicationClient.js +311 -52
  99. package/sdk/platform/Lead/LeadPlatformClient.d.ts +22 -11
  100. package/sdk/platform/Lead/LeadPlatformClient.js +266 -44
  101. package/sdk/platform/OAuthClient.js +8 -8
  102. package/sdk/platform/Order/OrderPlatformApplicationClient.d.ts +6 -3
  103. package/sdk/platform/Order/OrderPlatformApplicationClient.js +78 -14
  104. package/sdk/platform/Order/OrderPlatformClient.d.ts +95 -43
  105. package/sdk/platform/Order/OrderPlatformClient.js +1062 -180
  106. package/sdk/platform/Order/OrderPlatformModel.d.ts +64 -60
  107. package/sdk/platform/Order/OrderPlatformModel.js +1481 -1425
  108. package/sdk/platform/Order/OrderPlatformValidator.js +5 -0
  109. package/sdk/platform/Partner/PartnerPlatformApplicationClient.d.ts +4 -2
  110. package/sdk/platform/Partner/PartnerPlatformApplicationClient.js +52 -8
  111. package/sdk/platform/Partner/PartnerPlatformModel.d.ts +1 -1
  112. package/sdk/platform/Partner/PartnerPlatformModel.js +8 -8
  113. package/sdk/platform/Payment/PaymentPlatformApplicationClient.d.ts +22 -11
  114. package/sdk/platform/Payment/PaymentPlatformApplicationClient.js +287 -56
  115. package/sdk/platform/Payment/PaymentPlatformClient.d.ts +21 -11
  116. package/sdk/platform/Payment/PaymentPlatformClient.js +263 -48
  117. package/sdk/platform/Payment/PaymentPlatformModel.js +122 -122
  118. package/sdk/platform/PlatformApplicationClient.d.ts +2959 -2787
  119. package/sdk/platform/PlatformApplicationClient.js +3420 -3212
  120. package/sdk/platform/PlatformClient.d.ts +2959 -2787
  121. package/sdk/platform/PlatformClient.js +3420 -3212
  122. package/sdk/platform/Rewards/RewardsPlatformApplicationClient.d.ts +26 -13
  123. package/sdk/platform/Rewards/RewardsPlatformApplicationClient.js +308 -54
  124. package/sdk/platform/Share/SharePlatformApplicationClient.d.ts +8 -4
  125. package/sdk/platform/Share/SharePlatformApplicationClient.js +94 -16
  126. package/sdk/platform/Theme/ThemePlatformApplicationClient.d.ts +47 -23
  127. package/sdk/platform/Theme/ThemePlatformApplicationClient.js +571 -96
  128. package/sdk/platform/User/UserPlatformApplicationClient.d.ts +24 -12
  129. package/sdk/platform/User/UserPlatformApplicationClient.js +296 -48
  130. package/sdk/platform/Webhook/WebhookPlatformClient.d.ts +12 -6
  131. package/sdk/platform/Webhook/WebhookPlatformClient.js +157 -30
  132. package/sdk/public/Configuration/ConfigurationPublicClient.js +51 -8
  133. package/sdk/public/Inventory/InventoryPublicClient.js +149 -26
  134. 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 RewardsValidator = require("./RewardsPlatformApplicationValidator");
5
+ const RewardsModel = require("./RewardsPlatformModel");
6
+ const { Logger } = require("./../../common/Logger");
5
7
 
6
8
  class Rewards {
7
9
  constructor(config, applicationId) {
@@ -13,10 +15,11 @@ class Rewards {
13
15
  * @param {Object} arg - Arg object.
14
16
  * @param {string} arg.pageId - Pagination page id
15
17
  * @param {number} arg.pageSize - Pagination page size
18
+ * @returns {Promise<GiveawayResponse>} - Success response
16
19
  * @summary: List of giveaways of the current application.
17
20
  * @description: List of giveaways of the current application.
18
21
  */
19
- showGiveaways({ pageId, pageSize } = {}) {
22
+ async showGiveaways({ pageId, pageSize } = {}) {
20
23
  const { error } = RewardsValidator.showGiveaways().validate(
21
24
  {
22
25
  pageId,
@@ -37,30 +40,51 @@ class Rewards {
37
40
  { abortEarly: false, allowUnknown: false }
38
41
  );
39
42
  if (warrning) {
40
- console.log("Parameter Validation warrnings for showGiveaways");
41
- console.log(warrning);
43
+ Logger({
44
+ level: "WARN",
45
+ message: "Parameter Validation warrnings for showGiveaways",
46
+ });
47
+ Logger({ level: "WARN", message: warrning });
42
48
  }
43
49
 
44
50
  const query_params = {};
45
51
  query_params["page_id"] = pageId;
46
52
  query_params["page_size"] = pageSize;
47
53
 
48
- return PlatformAPIClient.execute(
54
+ const response = await PlatformAPIClient.execute(
49
55
  this.config,
50
56
  "get",
51
57
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/giveaways`,
52
58
  query_params,
53
59
  undefined
54
60
  );
61
+
62
+ const {
63
+ error: res_error,
64
+ } = RewardsModel.GiveawayResponse().validate(response, {
65
+ abortEarly: false,
66
+ allowUnknown: false,
67
+ });
68
+
69
+ if (res_error) {
70
+ Logger({
71
+ level: "WARN",
72
+ message: "Response Validation Warnnings for showGiveaways",
73
+ });
74
+ Logger({ level: "WARN", message: res_error });
75
+ }
76
+
77
+ return response;
55
78
  }
56
79
 
57
80
  /**
58
81
  * @param {Object} arg - Arg object.
59
82
  * @param {Giveaway} arg.body
83
+ * @returns {Promise<Giveaway>} - Success response
60
84
  * @summary: List of giveaways of the current application.
61
85
  * @description: Adds a new giveaway.
62
86
  */
63
- saveGiveAway({ body } = {}) {
87
+ async saveGiveAway({ body } = {}) {
64
88
  const { error } = RewardsValidator.saveGiveAway().validate(
65
89
  {
66
90
  body,
@@ -79,28 +103,47 @@ class Rewards {
79
103
  { abortEarly: false, allowUnknown: false }
80
104
  );
81
105
  if (warrning) {
82
- console.log("Parameter Validation warrnings for saveGiveAway");
83
- console.log(warrning);
106
+ Logger({
107
+ level: "WARN",
108
+ message: "Parameter Validation warrnings for saveGiveAway",
109
+ });
110
+ Logger({ level: "WARN", message: warrning });
84
111
  }
85
112
 
86
113
  const query_params = {};
87
114
 
88
- return PlatformAPIClient.execute(
115
+ const response = await PlatformAPIClient.execute(
89
116
  this.config,
90
117
  "post",
91
118
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/giveaways`,
92
119
  query_params,
93
120
  body
94
121
  );
122
+
123
+ const { error: res_error } = RewardsModel.Giveaway().validate(response, {
124
+ abortEarly: false,
125
+ allowUnknown: false,
126
+ });
127
+
128
+ if (res_error) {
129
+ Logger({
130
+ level: "WARN",
131
+ message: "Response Validation Warnnings for saveGiveAway",
132
+ });
133
+ Logger({ level: "WARN", message: res_error });
134
+ }
135
+
136
+ return response;
95
137
  }
96
138
 
97
139
  /**
98
140
  * @param {Object} arg - Arg object.
99
141
  * @param {string} arg.id - Giveaway ID
142
+ * @returns {Promise<Giveaway>} - Success response
100
143
  * @summary: Get giveaway by ID.
101
144
  * @description: Get giveaway by ID.
102
145
  */
103
- getGiveawayById({ id } = {}) {
146
+ async getGiveawayById({ id } = {}) {
104
147
  const { error } = RewardsValidator.getGiveawayById().validate(
105
148
  {
106
149
  id,
@@ -119,29 +162,48 @@ class Rewards {
119
162
  { abortEarly: false, allowUnknown: false }
120
163
  );
121
164
  if (warrning) {
122
- console.log("Parameter Validation warrnings for getGiveawayById");
123
- console.log(warrning);
165
+ Logger({
166
+ level: "WARN",
167
+ message: "Parameter Validation warrnings for getGiveawayById",
168
+ });
169
+ Logger({ level: "WARN", message: warrning });
124
170
  }
125
171
 
126
172
  const query_params = {};
127
173
 
128
- return PlatformAPIClient.execute(
174
+ const response = await PlatformAPIClient.execute(
129
175
  this.config,
130
176
  "get",
131
177
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/giveaways/${id}`,
132
178
  query_params,
133
179
  undefined
134
180
  );
181
+
182
+ const { error: res_error } = RewardsModel.Giveaway().validate(response, {
183
+ abortEarly: false,
184
+ allowUnknown: false,
185
+ });
186
+
187
+ if (res_error) {
188
+ Logger({
189
+ level: "WARN",
190
+ message: "Response Validation Warnnings for getGiveawayById",
191
+ });
192
+ Logger({ level: "WARN", message: res_error });
193
+ }
194
+
195
+ return response;
135
196
  }
136
197
 
137
198
  /**
138
199
  * @param {Object} arg - Arg object.
139
200
  * @param {string} arg.id - Giveaway ID
140
201
  * @param {Giveaway} arg.body
202
+ * @returns {Promise<Giveaway>} - Success response
141
203
  * @summary: Updates the giveaway by it's ID.
142
204
  * @description: Updates the giveaway by it's ID.
143
205
  */
144
- updateGiveAway({ id, body } = {}) {
206
+ async updateGiveAway({ id, body } = {}) {
145
207
  const { error } = RewardsValidator.updateGiveAway().validate(
146
208
  {
147
209
  id,
@@ -162,28 +224,47 @@ class Rewards {
162
224
  { abortEarly: false, allowUnknown: false }
163
225
  );
164
226
  if (warrning) {
165
- console.log("Parameter Validation warrnings for updateGiveAway");
166
- console.log(warrning);
227
+ Logger({
228
+ level: "WARN",
229
+ message: "Parameter Validation warrnings for updateGiveAway",
230
+ });
231
+ Logger({ level: "WARN", message: warrning });
167
232
  }
168
233
 
169
234
  const query_params = {};
170
235
 
171
- return PlatformAPIClient.execute(
236
+ const response = await PlatformAPIClient.execute(
172
237
  this.config,
173
238
  "put",
174
239
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/giveaways/${id}`,
175
240
  query_params,
176
241
  body
177
242
  );
243
+
244
+ const { error: res_error } = RewardsModel.Giveaway().validate(response, {
245
+ abortEarly: false,
246
+ allowUnknown: false,
247
+ });
248
+
249
+ if (res_error) {
250
+ Logger({
251
+ level: "WARN",
252
+ message: "Response Validation Warnnings for updateGiveAway",
253
+ });
254
+ Logger({ level: "WARN", message: res_error });
255
+ }
256
+
257
+ return response;
178
258
  }
179
259
 
180
260
  /**
181
261
  * @param {Object} arg - Arg object.
182
262
  * @param {string} arg.audienceId - Audience id
263
+ * @returns {Promise<GiveawayAudience>} - Success response
183
264
  * @summary: Get the Giveaway audience status
184
265
  * @description: Get giveaway audience status
185
266
  */
186
- getGiveawayAudienceStatus({ audienceId } = {}) {
267
+ async getGiveawayAudienceStatus({ audienceId } = {}) {
187
268
  const { error } = RewardsValidator.getGiveawayAudienceStatus().validate(
188
269
  {
189
270
  audienceId,
@@ -204,29 +285,48 @@ class Rewards {
204
285
  { abortEarly: false, allowUnknown: false }
205
286
  );
206
287
  if (warrning) {
207
- console.log(
208
- "Parameter Validation warrnings for getGiveawayAudienceStatus"
209
- );
210
- console.log(warrning);
288
+ Logger({
289
+ level: "WARN",
290
+ message: "Parameter Validation warrnings for getGiveawayAudienceStatus",
291
+ });
292
+ Logger({ level: "WARN", message: warrning });
211
293
  }
212
294
 
213
295
  const query_params = {};
214
296
 
215
- return PlatformAPIClient.execute(
297
+ const response = await PlatformAPIClient.execute(
216
298
  this.config,
217
299
  "get",
218
300
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/giveaways/audience/${audienceId}/status`,
219
301
  query_params,
220
302
  undefined
221
303
  );
304
+
305
+ const {
306
+ error: res_error,
307
+ } = RewardsModel.GiveawayAudience().validate(response, {
308
+ abortEarly: false,
309
+ allowUnknown: false,
310
+ });
311
+
312
+ if (res_error) {
313
+ Logger({
314
+ level: "WARN",
315
+ message: "Response Validation Warnnings for getGiveawayAudienceStatus",
316
+ });
317
+ Logger({ level: "WARN", message: res_error });
318
+ }
319
+
320
+ return response;
222
321
  }
223
322
 
224
323
  /**
225
324
  * @param {Object} arg - Arg object.
325
+ * @returns {Promise<Offer[]>} - Success response
226
326
  * @summary: List of offers of the current application.
227
327
  * @description: List of offers of the current application.
228
328
  */
229
- showOffers({} = {}) {
329
+ async showOffers({} = {}) {
230
330
  const { error } = RewardsValidator.showOffers().validate(
231
331
  {},
232
332
  { abortEarly: false, allowUnknown: true }
@@ -241,19 +341,36 @@ class Rewards {
241
341
  { abortEarly: false, allowUnknown: false }
242
342
  );
243
343
  if (warrning) {
244
- console.log("Parameter Validation warrnings for showOffers");
245
- console.log(warrning);
344
+ Logger({
345
+ level: "WARN",
346
+ message: "Parameter Validation warrnings for showOffers",
347
+ });
348
+ Logger({ level: "WARN", message: warrning });
246
349
  }
247
350
 
248
351
  const query_params = {};
249
352
 
250
- return PlatformAPIClient.execute(
353
+ const response = await PlatformAPIClient.execute(
251
354
  this.config,
252
355
  "get",
253
356
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers/`,
254
357
  query_params,
255
358
  undefined
256
359
  );
360
+
361
+ const { error: res_error } = Joi.array()
362
+ .items(RewardsModel.Offer())
363
+ .validate(response, { abortEarly: false, allowUnknown: false });
364
+
365
+ if (res_error) {
366
+ Logger({
367
+ level: "WARN",
368
+ message: "Response Validation Warnnings for showOffers",
369
+ });
370
+ Logger({ level: "WARN", message: res_error });
371
+ }
372
+
373
+ return response;
257
374
  }
258
375
 
259
376
  /**
@@ -262,10 +379,11 @@ class Rewards {
262
379
  * @param {string} arg.cookie - User's session cookie. This cookie is set in
263
380
  * browser cookie when logged-in to fynd's authentication system i.e.
264
381
  * `Grimlock` or by using grimlock-backend SDK for backend implementation.
382
+ * @returns {Promise<Offer>} - Success response
265
383
  * @summary: Get offer by name
266
384
  * @description: Use this API to get the offer details and configuration by entering the name of the offer.
267
385
  */
268
- getOfferByName({ name, cookie } = {}) {
386
+ async getOfferByName({ name, cookie } = {}) {
269
387
  const { error } = RewardsValidator.getOfferByName().validate(
270
388
  {
271
389
  name,
@@ -286,29 +404,48 @@ class Rewards {
286
404
  { abortEarly: false, allowUnknown: false }
287
405
  );
288
406
  if (warrning) {
289
- console.log("Parameter Validation warrnings for getOfferByName");
290
- console.log(warrning);
407
+ Logger({
408
+ level: "WARN",
409
+ message: "Parameter Validation warrnings for getOfferByName",
410
+ });
411
+ Logger({ level: "WARN", message: warrning });
291
412
  }
292
413
 
293
414
  const query_params = {};
294
415
 
295
- return PlatformAPIClient.execute(
416
+ const response = await PlatformAPIClient.execute(
296
417
  this.config,
297
418
  "get",
298
419
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers/${name}/`,
299
420
  query_params,
300
421
  undefined
301
422
  );
423
+
424
+ const { error: res_error } = RewardsModel.Offer().validate(response, {
425
+ abortEarly: false,
426
+ allowUnknown: false,
427
+ });
428
+
429
+ if (res_error) {
430
+ Logger({
431
+ level: "WARN",
432
+ message: "Response Validation Warnnings for getOfferByName",
433
+ });
434
+ Logger({ level: "WARN", message: res_error });
435
+ }
436
+
437
+ return response;
302
438
  }
303
439
 
304
440
  /**
305
441
  * @param {Object} arg - Arg object.
306
442
  * @param {string} arg.name - The name given to the offer.
307
443
  * @param {Offer} arg.body
444
+ * @returns {Promise<Offer>} - Success response
308
445
  * @summary: Update offer by name
309
446
  * @description: Use this API to update the offer details
310
447
  */
311
- updateOfferByName({ name, body } = {}) {
448
+ async updateOfferByName({ name, body } = {}) {
312
449
  const { error } = RewardsValidator.updateOfferByName().validate(
313
450
  {
314
451
  name,
@@ -329,29 +466,48 @@ class Rewards {
329
466
  { abortEarly: false, allowUnknown: false }
330
467
  );
331
468
  if (warrning) {
332
- console.log("Parameter Validation warrnings for updateOfferByName");
333
- console.log(warrning);
469
+ Logger({
470
+ level: "WARN",
471
+ message: "Parameter Validation warrnings for updateOfferByName",
472
+ });
473
+ Logger({ level: "WARN", message: warrning });
334
474
  }
335
475
 
336
476
  const query_params = {};
337
477
 
338
- return PlatformAPIClient.execute(
478
+ const response = await PlatformAPIClient.execute(
339
479
  this.config,
340
480
  "put",
341
481
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers/${name}/`,
342
482
  query_params,
343
483
  body
344
484
  );
485
+
486
+ const { error: res_error } = RewardsModel.Offer().validate(response, {
487
+ abortEarly: false,
488
+ allowUnknown: false,
489
+ });
490
+
491
+ if (res_error) {
492
+ Logger({
493
+ level: "WARN",
494
+ message: "Response Validation Warnnings for updateOfferByName",
495
+ });
496
+ Logger({ level: "WARN", message: res_error });
497
+ }
498
+
499
+ return response;
345
500
  }
346
501
 
347
502
  /**
348
503
  * @param {Object} arg - Arg object.
349
504
  * @param {string} arg.userId - User id
350
505
  * @param {AppUser} arg.body
506
+ * @returns {Promise<AppUser>} - Success response
351
507
  * @summary: Update user status
352
508
  * @description: Use this API to update the user status active/archive
353
509
  */
354
- updateUserStatus({ userId, body } = {}) {
510
+ async updateUserStatus({ userId, body } = {}) {
355
511
  const { error } = RewardsValidator.updateUserStatus().validate(
356
512
  {
357
513
  userId,
@@ -372,28 +528,47 @@ class Rewards {
372
528
  { abortEarly: false, allowUnknown: false }
373
529
  );
374
530
  if (warrning) {
375
- console.log("Parameter Validation warrnings for updateUserStatus");
376
- console.log(warrning);
531
+ Logger({
532
+ level: "WARN",
533
+ message: "Parameter Validation warrnings for updateUserStatus",
534
+ });
535
+ Logger({ level: "WARN", message: warrning });
377
536
  }
378
537
 
379
538
  const query_params = {};
380
539
 
381
- return PlatformAPIClient.execute(
540
+ const response = await PlatformAPIClient.execute(
382
541
  this.config,
383
542
  "patch",
384
543
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/users/${userId}/`,
385
544
  query_params,
386
545
  body
387
546
  );
547
+
548
+ const { error: res_error } = RewardsModel.AppUser().validate(response, {
549
+ abortEarly: false,
550
+ allowUnknown: false,
551
+ });
552
+
553
+ if (res_error) {
554
+ Logger({
555
+ level: "WARN",
556
+ message: "Response Validation Warnnings for updateUserStatus",
557
+ });
558
+ Logger({ level: "WARN", message: res_error });
559
+ }
560
+
561
+ return response;
388
562
  }
389
563
 
390
564
  /**
391
565
  * @param {Object} arg - Arg object.
392
566
  * @param {string} arg.userId - User id
567
+ * @returns {Promise<UserRes>} - Success response
393
568
  * @summary: Get user reward details
394
569
  * @description: Use this API to get the user reward details
395
570
  */
396
- user({ userId } = {}) {
571
+ async user({ userId } = {}) {
397
572
  const { error } = RewardsValidator.user().validate(
398
573
  {
399
574
  userId,
@@ -412,19 +587,37 @@ class Rewards {
412
587
  { abortEarly: false, allowUnknown: false }
413
588
  );
414
589
  if (warrning) {
415
- console.log("Parameter Validation warrnings for user");
416
- console.log(warrning);
590
+ Logger({
591
+ level: "WARN",
592
+ message: "Parameter Validation warrnings for user",
593
+ });
594
+ Logger({ level: "WARN", message: warrning });
417
595
  }
418
596
 
419
597
  const query_params = {};
420
598
 
421
- return PlatformAPIClient.execute(
599
+ const response = await PlatformAPIClient.execute(
422
600
  this.config,
423
601
  "get",
424
602
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/users/${userId}/`,
425
603
  query_params,
426
604
  undefined
427
605
  );
606
+
607
+ const { error: res_error } = RewardsModel.UserRes().validate(response, {
608
+ abortEarly: false,
609
+ allowUnknown: false,
610
+ });
611
+
612
+ if (res_error) {
613
+ Logger({
614
+ level: "WARN",
615
+ message: "Response Validation Warnnings for user",
616
+ });
617
+ Logger({ level: "WARN", message: res_error });
618
+ }
619
+
620
+ return response;
428
621
  }
429
622
 
430
623
  /**
@@ -433,10 +626,11 @@ class Rewards {
433
626
  * @param {string} [arg.pageId] - PageID is the ID of the requested page.
434
627
  * For first request it should be kept empty.
435
628
  * @param {number} [arg.pageSize] - The number of items to retrieve in each page.
629
+ * @returns {Promise<HistoryRes>} - Success response
436
630
  * @summary: Get all transactions of reward points
437
631
  * @description: Use this API to get a list of points transactions.
438
632
  */
439
- getUserPointsHistory({ userId, pageId, pageSize } = {}) {
633
+ async getUserPointsHistory({ userId, pageId, pageSize } = {}) {
440
634
  const { error } = RewardsValidator.getUserPointsHistory().validate(
441
635
  {
442
636
  userId,
@@ -461,21 +655,39 @@ class Rewards {
461
655
  { abortEarly: false, allowUnknown: false }
462
656
  );
463
657
  if (warrning) {
464
- console.log("Parameter Validation warrnings for getUserPointsHistory");
465
- console.log(warrning);
658
+ Logger({
659
+ level: "WARN",
660
+ message: "Parameter Validation warrnings for getUserPointsHistory",
661
+ });
662
+ Logger({ level: "WARN", message: warrning });
466
663
  }
467
664
 
468
665
  const query_params = {};
469
666
  query_params["page_id"] = pageId;
470
667
  query_params["page_size"] = pageSize;
471
668
 
472
- return PlatformAPIClient.execute(
669
+ const response = await PlatformAPIClient.execute(
473
670
  this.config,
474
671
  "get",
475
672
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/users/${userId}/points/history/`,
476
673
  query_params,
477
674
  undefined
478
675
  );
676
+
677
+ const { error: res_error } = RewardsModel.HistoryRes().validate(response, {
678
+ abortEarly: false,
679
+ allowUnknown: false,
680
+ });
681
+
682
+ if (res_error) {
683
+ Logger({
684
+ level: "WARN",
685
+ message: "Response Validation Warnnings for getUserPointsHistory",
686
+ });
687
+ Logger({ level: "WARN", message: res_error });
688
+ }
689
+
690
+ return response;
479
691
  }
480
692
 
481
693
  /**
@@ -517,10 +729,11 @@ class Rewards {
517
729
 
518
730
  /**
519
731
  * @param {Object} arg - Arg object.
732
+ * @returns {Promise<ConfigurationRes>} - Success response
520
733
  * @summary: Get all valid android paths
521
734
  * @description: Use this API to get a list of valid android paths required by the Rewards INIT API to validate a fradualent device.
522
735
  */
523
- getRewardsConfiguration({} = {}) {
736
+ async getRewardsConfiguration({} = {}) {
524
737
  const { error } = RewardsValidator.getRewardsConfiguration().validate(
525
738
  {},
526
739
  { abortEarly: false, allowUnknown: true }
@@ -537,28 +750,49 @@ class Rewards {
537
750
  { abortEarly: false, allowUnknown: false }
538
751
  );
539
752
  if (warrning) {
540
- console.log("Parameter Validation warrnings for getRewardsConfiguration");
541
- console.log(warrning);
753
+ Logger({
754
+ level: "WARN",
755
+ message: "Parameter Validation warrnings for getRewardsConfiguration",
756
+ });
757
+ Logger({ level: "WARN", message: warrning });
542
758
  }
543
759
 
544
760
  const query_params = {};
545
761
 
546
- return PlatformAPIClient.execute(
762
+ const response = await PlatformAPIClient.execute(
547
763
  this.config,
548
764
  "get",
549
765
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/configuration/`,
550
766
  query_params,
551
767
  undefined
552
768
  );
769
+
770
+ const {
771
+ error: res_error,
772
+ } = RewardsModel.ConfigurationRes().validate(response, {
773
+ abortEarly: false,
774
+ allowUnknown: false,
775
+ });
776
+
777
+ if (res_error) {
778
+ Logger({
779
+ level: "WARN",
780
+ message: "Response Validation Warnnings for getRewardsConfiguration",
781
+ });
782
+ Logger({ level: "WARN", message: res_error });
783
+ }
784
+
785
+ return response;
553
786
  }
554
787
 
555
788
  /**
556
789
  * @param {Object} arg - Arg object.
557
790
  * @param {ConfigurationRequest} arg.body
791
+ * @returns {Promise<SetConfigurationRes>} - Success response
558
792
  * @summary: Updates the collection with given android paths.
559
793
  * @description: Updates the configuration or inserts new records.
560
794
  */
561
- setRewardsConfiguration({ body } = {}) {
795
+ async setRewardsConfiguration({ body } = {}) {
562
796
  const { error } = RewardsValidator.setRewardsConfiguration().validate(
563
797
  {
564
798
  body,
@@ -579,19 +813,39 @@ class Rewards {
579
813
  { abortEarly: false, allowUnknown: false }
580
814
  );
581
815
  if (warrning) {
582
- console.log("Parameter Validation warrnings for setRewardsConfiguration");
583
- console.log(warrning);
816
+ Logger({
817
+ level: "WARN",
818
+ message: "Parameter Validation warrnings for setRewardsConfiguration",
819
+ });
820
+ Logger({ level: "WARN", message: warrning });
584
821
  }
585
822
 
586
823
  const query_params = {};
587
824
 
588
- return PlatformAPIClient.execute(
825
+ const response = await PlatformAPIClient.execute(
589
826
  this.config,
590
827
  "post",
591
828
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/configuration/`,
592
829
  query_params,
593
830
  body
594
831
  );
832
+
833
+ const {
834
+ error: res_error,
835
+ } = RewardsModel.SetConfigurationRes().validate(response, {
836
+ abortEarly: false,
837
+ allowUnknown: false,
838
+ });
839
+
840
+ if (res_error) {
841
+ Logger({
842
+ level: "WARN",
843
+ message: "Response Validation Warnnings for setRewardsConfiguration",
844
+ });
845
+ Logger({ level: "WARN", message: res_error });
846
+ }
847
+
848
+ return response;
595
849
  }
596
850
  }
597
851
  module.exports = Rewards;