@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.
Files changed (156) hide show
  1. package/documentation/application/CART.md +251 -251
  2. package/documentation/application/CATALOG.md +393 -393
  3. package/documentation/application/CONTENT.md +15 -1
  4. package/documentation/application/ORDER.md +268 -268
  5. package/documentation/application/PAYMENT.md +249 -249
  6. package/documentation/application/POSCART.md +297 -297
  7. package/documentation/platform/CART.md +499 -499
  8. package/documentation/platform/CATALOG.md +3497 -3097
  9. package/documentation/platform/COMPANYPROFILE.md +207 -207
  10. package/documentation/platform/CONTENT.md +123 -1
  11. package/documentation/platform/ORDER.md +1518 -1324
  12. package/documentation/platform/PARTNER.md +7 -7
  13. package/documentation/platform/PAYMENT.md +96 -96
  14. package/index.js +7 -1
  15. package/package.json +1 -1
  16. package/sdk/application/ApplicationConfig.js +1 -1
  17. package/sdk/application/Cart/CartApplicationClient.js +865 -52
  18. package/sdk/application/Cart/CartApplicationModel.d.ts +7 -7
  19. package/sdk/application/Cart/CartApplicationModel.js +335 -335
  20. package/sdk/application/Cart/CartApplicationValidator.js +1 -0
  21. package/sdk/application/Catalog/CatalogApplicationClient.d.ts +1 -1
  22. package/sdk/application/Catalog/CatalogApplicationClient.js +1034 -60
  23. package/sdk/application/Catalog/CatalogApplicationModel.d.ts +19 -19
  24. package/sdk/application/Catalog/CatalogApplicationModel.js +532 -532
  25. package/sdk/application/Catalog/CatalogApplicationValidator.js +1 -0
  26. package/sdk/application/Common/CommonApplicationClient.js +66 -4
  27. package/sdk/application/Common/CommonApplicationValidator.js +1 -0
  28. package/sdk/application/Communication/CommunicationApplicationClient.js +108 -6
  29. package/sdk/application/Communication/CommunicationApplicationValidator.js +1 -0
  30. package/sdk/application/Configuration/ConfigurationApplicationClient.d.ts +1 -1
  31. package/sdk/application/Configuration/ConfigurationApplicationClient.js +558 -32
  32. package/sdk/application/Configuration/ConfigurationApplicationValidator.js +1 -0
  33. package/sdk/application/Content/ContentApplicationClient.js +621 -38
  34. package/sdk/application/Content/ContentApplicationModel.d.ts +1 -0
  35. package/sdk/application/Content/ContentApplicationModel.js +11 -1
  36. package/sdk/application/Content/ContentApplicationValidator.js +1 -0
  37. package/sdk/application/FileStorage/FileStorageApplicationClient.js +101 -6
  38. package/sdk/application/FileStorage/FileStorageApplicationValidator.js +1 -0
  39. package/sdk/application/Lead/LeadApplicationClient.js +229 -14
  40. package/sdk/application/Lead/LeadApplicationValidator.js +1 -0
  41. package/sdk/application/Logistic/LogisticApplicationClient.js +134 -8
  42. package/sdk/application/Logistic/LogisticApplicationValidator.js +1 -0
  43. package/sdk/application/Order/OrderApplicationClient.d.ts +1 -1
  44. package/sdk/application/Order/OrderApplicationClient.js +403 -24
  45. package/sdk/application/Order/OrderApplicationModel.d.ts +20 -20
  46. package/sdk/application/Order/OrderApplicationModel.js +334 -334
  47. package/sdk/application/Order/OrderApplicationValidator.js +1 -0
  48. package/sdk/application/Payment/PaymentApplicationClient.js +1381 -78
  49. package/sdk/application/Payment/PaymentApplicationModel.d.ts +2 -2
  50. package/sdk/application/Payment/PaymentApplicationModel.js +350 -350
  51. package/sdk/application/Payment/PaymentApplicationValidator.js +1 -0
  52. package/sdk/application/PosCart/PosCartApplicationClient.js +914 -54
  53. package/sdk/application/PosCart/PosCartApplicationModel.d.ts +15 -15
  54. package/sdk/application/PosCart/PosCartApplicationModel.js +389 -389
  55. package/sdk/application/PosCart/PosCartApplicationValidator.js +1 -0
  56. package/sdk/application/Rewards/RewardsApplicationClient.js +235 -14
  57. package/sdk/application/Rewards/RewardsApplicationValidator.js +1 -0
  58. package/sdk/application/Share/ShareApplicationClient.js +226 -14
  59. package/sdk/application/Share/ShareApplicationValidator.js +1 -0
  60. package/sdk/application/Theme/ThemeApplicationClient.js +130 -8
  61. package/sdk/application/Theme/ThemeApplicationValidator.js +1 -0
  62. package/sdk/application/User/UserApplicationClient.js +1133 -70
  63. package/sdk/application/User/UserApplicationValidator.js +1 -0
  64. package/sdk/common/AxiosHelper.js +1 -1
  65. package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.d.ts +16 -8
  66. package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.js +287 -16
  67. package/sdk/platform/Analytics/AnalyticsPlatformClient.d.ts +8 -4
  68. package/sdk/platform/Analytics/AnalyticsPlatformClient.js +153 -8
  69. package/sdk/platform/AuditTrail/AuditTrailPlatformClient.d.ts +8 -4
  70. package/sdk/platform/AuditTrail/AuditTrailPlatformClient.js +141 -8
  71. package/sdk/platform/Billing/BillingPlatformClient.d.ts +24 -12
  72. package/sdk/platform/Billing/BillingPlatformClient.js +429 -24
  73. package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +34 -17
  74. package/sdk/platform/Cart/CartPlatformApplicationClient.js +617 -34
  75. package/sdk/platform/Cart/CartPlatformModel.d.ts +35 -35
  76. package/sdk/platform/Cart/CartPlatformModel.js +617 -617
  77. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.d.ts +191 -138
  78. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.js +2202 -302
  79. package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.d.ts +11 -11
  80. package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.js +45 -45
  81. package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +344 -226
  82. package/sdk/platform/Catalog/CatalogPlatformClient.js +3282 -488
  83. package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +110 -100
  84. package/sdk/platform/Catalog/CatalogPlatformModel.js +2073 -1795
  85. package/sdk/platform/Catalog/CatalogPlatformValidator.d.ts +23 -21
  86. package/sdk/platform/Catalog/CatalogPlatformValidator.js +103 -84
  87. package/sdk/platform/Common/CommonPlatformClient.d.ts +4 -2
  88. package/sdk/platform/Common/CommonPlatformClient.js +73 -4
  89. package/sdk/platform/Communication/CommunicationPlatformApplicationClient.d.ts +80 -40
  90. package/sdk/platform/Communication/CommunicationPlatformApplicationClient.js +1499 -80
  91. package/sdk/platform/Communication/CommunicationPlatformClient.d.ts +2 -1
  92. package/sdk/platform/Communication/CommunicationPlatformClient.js +41 -2
  93. package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.d.ts +27 -14
  94. package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.js +486 -26
  95. package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.d.ts +9 -9
  96. package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.js +274 -274
  97. package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.d.ts +56 -28
  98. package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.js +1022 -56
  99. package/sdk/platform/Configuration/ConfigurationPlatformClient.d.ts +36 -18
  100. package/sdk/platform/Configuration/ConfigurationPlatformClient.js +693 -36
  101. package/sdk/platform/Content/ContentPlatformApplicationClient.d.ts +148 -67
  102. package/sdk/platform/Content/ContentPlatformApplicationClient.js +2446 -140
  103. package/sdk/platform/Content/ContentPlatformApplicationValidator.d.ts +1 -0
  104. package/sdk/platform/Content/ContentPlatformApplicationValidator.js +7 -0
  105. package/sdk/platform/Content/ContentPlatformModel.d.ts +4 -0
  106. package/sdk/platform/Content/ContentPlatformModel.js +43 -1
  107. package/sdk/platform/Discount/DiscountPlatformClient.d.ts +21 -10
  108. package/sdk/platform/Discount/DiscountPlatformClient.js +400 -22
  109. package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.d.ts +8 -4
  110. package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.js +148 -8
  111. package/sdk/platform/FileStorage/FileStoragePlatformClient.d.ts +12 -6
  112. package/sdk/platform/FileStorage/FileStoragePlatformClient.js +214 -12
  113. package/sdk/platform/Inventory/InventoryPlatformClient.d.ts +27 -14
  114. package/sdk/platform/Inventory/InventoryPlatformClient.js +449 -24
  115. package/sdk/platform/Lead/LeadPlatformApplicationClient.d.ts +26 -13
  116. package/sdk/platform/Lead/LeadPlatformApplicationClient.js +447 -26
  117. package/sdk/platform/Lead/LeadPlatformClient.d.ts +22 -11
  118. package/sdk/platform/Lead/LeadPlatformClient.js +384 -22
  119. package/sdk/platform/OAuthClient.js +8 -8
  120. package/sdk/platform/Order/OrderPlatformApplicationClient.d.ts +6 -3
  121. package/sdk/platform/Order/OrderPlatformApplicationClient.js +125 -6
  122. package/sdk/platform/Order/OrderPlatformClient.d.ts +108 -47
  123. package/sdk/platform/Order/OrderPlatformClient.js +1641 -100
  124. package/sdk/platform/Order/OrderPlatformModel.d.ts +69 -58
  125. package/sdk/platform/Order/OrderPlatformModel.js +1485 -1493
  126. package/sdk/platform/Order/OrderPlatformValidator.d.ts +2 -1
  127. package/sdk/platform/Order/OrderPlatformValidator.js +15 -4
  128. package/sdk/platform/Partner/PartnerPlatformApplicationClient.d.ts +4 -2
  129. package/sdk/platform/Partner/PartnerPlatformApplicationClient.js +74 -4
  130. package/sdk/platform/Partner/PartnerPlatformModel.d.ts +1 -1
  131. package/sdk/platform/Partner/PartnerPlatformModel.js +8 -8
  132. package/sdk/platform/Payment/PaymentPlatformApplicationClient.d.ts +22 -11
  133. package/sdk/platform/Payment/PaymentPlatformApplicationClient.js +418 -22
  134. package/sdk/platform/Payment/PaymentPlatformClient.d.ts +21 -11
  135. package/sdk/platform/Payment/PaymentPlatformClient.js +374 -20
  136. package/sdk/platform/Payment/PaymentPlatformModel.js +139 -139
  137. package/sdk/platform/PlatformApplicationClient.d.ts +2973 -2827
  138. package/sdk/platform/PlatformApplicationClient.js +3461 -3263
  139. package/sdk/platform/PlatformClient.d.ts +2973 -2827
  140. package/sdk/platform/PlatformClient.js +3461 -3263
  141. package/sdk/platform/Rewards/RewardsPlatformApplicationClient.d.ts +26 -13
  142. package/sdk/platform/Rewards/RewardsPlatformApplicationClient.js +449 -26
  143. package/sdk/platform/Share/SharePlatformApplicationClient.d.ts +8 -4
  144. package/sdk/platform/Share/SharePlatformApplicationClient.js +139 -8
  145. package/sdk/platform/Theme/ThemePlatformApplicationClient.d.ts +47 -23
  146. package/sdk/platform/Theme/ThemePlatformApplicationClient.js +816 -48
  147. package/sdk/platform/User/UserPlatformApplicationClient.d.ts +24 -12
  148. package/sdk/platform/User/UserPlatformApplicationClient.js +417 -24
  149. package/sdk/platform/Webhook/WebhookPlatformClient.d.ts +12 -6
  150. package/sdk/platform/Webhook/WebhookPlatformClient.js +229 -12
  151. package/sdk/public/Configuration/ConfigurationPublicClient.js +72 -4
  152. package/sdk/public/Configuration/ConfigurationPublicValidator.js +3 -1
  153. package/sdk/public/Inventory/InventoryPublicClient.js +210 -12
  154. package/sdk/public/Inventory/InventoryPublicValidator.js +3 -1
  155. package/sdk/public/Webhook/WebhookPublicClient.js +74 -4
  156. 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 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,
@@ -28,26 +31,60 @@ class Rewards {
28
31
  return Promise.reject(new FDKClientValidationError(error));
29
32
  }
30
33
 
34
+ // Showing warrnings if extra unknown parameters are found
35
+ const { error: warrning } = RewardsValidator.showGiveaways().validate(
36
+ {
37
+ pageId,
38
+ pageSize,
39
+ },
40
+ { abortEarly: false, allowUnknown: false }
41
+ );
42
+ if (warrning) {
43
+ Logger({
44
+ level: "WARN",
45
+ message: "Parameter Validation warrnings for showGiveaways",
46
+ });
47
+ Logger({ level: "WARN", message: warrning });
48
+ }
49
+
31
50
  const query_params = {};
32
51
  query_params["page_id"] = pageId;
33
52
  query_params["page_size"] = pageSize;
34
53
 
35
- return PlatformAPIClient.execute(
54
+ const response = await PlatformAPIClient.execute(
36
55
  this.config,
37
56
  "get",
38
57
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/giveaways`,
39
58
  query_params,
40
59
  undefined
41
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;
42
78
  }
43
79
 
44
80
  /**
45
81
  * @param {Object} arg - Arg object.
46
82
  * @param {Giveaway} arg.body
83
+ * @returns {Promise<Giveaway>} - Success response
47
84
  * @summary: List of giveaways of the current application.
48
85
  * @description: Adds a new giveaway.
49
86
  */
50
- saveGiveAway({ body } = {}) {
87
+ async saveGiveAway({ body } = {}) {
51
88
  const { error } = RewardsValidator.saveGiveAway().validate(
52
89
  {
53
90
  body,
@@ -58,24 +95,55 @@ class Rewards {
58
95
  return Promise.reject(new FDKClientValidationError(error));
59
96
  }
60
97
 
98
+ // Showing warrnings if extra unknown parameters are found
99
+ const { error: warrning } = RewardsValidator.saveGiveAway().validate(
100
+ {
101
+ body,
102
+ },
103
+ { abortEarly: false, allowUnknown: false }
104
+ );
105
+ if (warrning) {
106
+ Logger({
107
+ level: "WARN",
108
+ message: "Parameter Validation warrnings for saveGiveAway",
109
+ });
110
+ Logger({ level: "WARN", message: warrning });
111
+ }
112
+
61
113
  const query_params = {};
62
114
 
63
- return PlatformAPIClient.execute(
115
+ const response = await PlatformAPIClient.execute(
64
116
  this.config,
65
117
  "post",
66
118
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/giveaways`,
67
119
  query_params,
68
120
  body
69
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;
70
137
  }
71
138
 
72
139
  /**
73
140
  * @param {Object} arg - Arg object.
74
141
  * @param {string} arg.id - Giveaway ID
142
+ * @returns {Promise<Giveaway>} - Success response
75
143
  * @summary: Get giveaway by ID.
76
144
  * @description: Get giveaway by ID.
77
145
  */
78
- getGiveawayById({ id } = {}) {
146
+ async getGiveawayById({ id } = {}) {
79
147
  const { error } = RewardsValidator.getGiveawayById().validate(
80
148
  {
81
149
  id,
@@ -86,25 +154,56 @@ class Rewards {
86
154
  return Promise.reject(new FDKClientValidationError(error));
87
155
  }
88
156
 
157
+ // Showing warrnings if extra unknown parameters are found
158
+ const { error: warrning } = RewardsValidator.getGiveawayById().validate(
159
+ {
160
+ id,
161
+ },
162
+ { abortEarly: false, allowUnknown: false }
163
+ );
164
+ if (warrning) {
165
+ Logger({
166
+ level: "WARN",
167
+ message: "Parameter Validation warrnings for getGiveawayById",
168
+ });
169
+ Logger({ level: "WARN", message: warrning });
170
+ }
171
+
89
172
  const query_params = {};
90
173
 
91
- return PlatformAPIClient.execute(
174
+ const response = await PlatformAPIClient.execute(
92
175
  this.config,
93
176
  "get",
94
177
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/giveaways/${id}`,
95
178
  query_params,
96
179
  undefined
97
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;
98
196
  }
99
197
 
100
198
  /**
101
199
  * @param {Object} arg - Arg object.
102
200
  * @param {string} arg.id - Giveaway ID
103
201
  * @param {Giveaway} arg.body
202
+ * @returns {Promise<Giveaway>} - Success response
104
203
  * @summary: Updates the giveaway by it's ID.
105
204
  * @description: Updates the giveaway by it's ID.
106
205
  */
107
- updateGiveAway({ id, body } = {}) {
206
+ async updateGiveAway({ id, body } = {}) {
108
207
  const { error } = RewardsValidator.updateGiveAway().validate(
109
208
  {
110
209
  id,
@@ -116,24 +215,56 @@ class Rewards {
116
215
  return Promise.reject(new FDKClientValidationError(error));
117
216
  }
118
217
 
218
+ // Showing warrnings if extra unknown parameters are found
219
+ const { error: warrning } = RewardsValidator.updateGiveAway().validate(
220
+ {
221
+ id,
222
+ body,
223
+ },
224
+ { abortEarly: false, allowUnknown: false }
225
+ );
226
+ if (warrning) {
227
+ Logger({
228
+ level: "WARN",
229
+ message: "Parameter Validation warrnings for updateGiveAway",
230
+ });
231
+ Logger({ level: "WARN", message: warrning });
232
+ }
233
+
119
234
  const query_params = {};
120
235
 
121
- return PlatformAPIClient.execute(
236
+ const response = await PlatformAPIClient.execute(
122
237
  this.config,
123
238
  "put",
124
239
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/giveaways/${id}`,
125
240
  query_params,
126
241
  body
127
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;
128
258
  }
129
259
 
130
260
  /**
131
261
  * @param {Object} arg - Arg object.
132
262
  * @param {string} arg.audienceId - Audience id
263
+ * @returns {Promise<GiveawayAudience>} - Success response
133
264
  * @summary: Get the Giveaway audience status
134
265
  * @description: Get giveaway audience status
135
266
  */
136
- getGiveawayAudienceStatus({ audienceId } = {}) {
267
+ async getGiveawayAudienceStatus({ audienceId } = {}) {
137
268
  const { error } = RewardsValidator.getGiveawayAudienceStatus().validate(
138
269
  {
139
270
  audienceId,
@@ -144,23 +275,58 @@ class Rewards {
144
275
  return Promise.reject(new FDKClientValidationError(error));
145
276
  }
146
277
 
278
+ // Showing warrnings if extra unknown parameters are found
279
+ const {
280
+ error: warrning,
281
+ } = RewardsValidator.getGiveawayAudienceStatus().validate(
282
+ {
283
+ audienceId,
284
+ },
285
+ { abortEarly: false, allowUnknown: false }
286
+ );
287
+ if (warrning) {
288
+ Logger({
289
+ level: "WARN",
290
+ message: "Parameter Validation warrnings for getGiveawayAudienceStatus",
291
+ });
292
+ Logger({ level: "WARN", message: warrning });
293
+ }
294
+
147
295
  const query_params = {};
148
296
 
149
- return PlatformAPIClient.execute(
297
+ const response = await PlatformAPIClient.execute(
150
298
  this.config,
151
299
  "get",
152
300
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/giveaways/audience/${audienceId}/status`,
153
301
  query_params,
154
302
  undefined
155
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;
156
321
  }
157
322
 
158
323
  /**
159
324
  * @param {Object} arg - Arg object.
325
+ * @returns {Promise<Offer[]>} - Success response
160
326
  * @summary: List of offers of the current application.
161
327
  * @description: List of offers of the current application.
162
328
  */
163
- showOffers({} = {}) {
329
+ async showOffers({} = {}) {
164
330
  const { error } = RewardsValidator.showOffers().validate(
165
331
  {},
166
332
  { abortEarly: false, allowUnknown: true }
@@ -169,15 +335,42 @@ class Rewards {
169
335
  return Promise.reject(new FDKClientValidationError(error));
170
336
  }
171
337
 
338
+ // Showing warrnings if extra unknown parameters are found
339
+ const { error: warrning } = RewardsValidator.showOffers().validate(
340
+ {},
341
+ { abortEarly: false, allowUnknown: false }
342
+ );
343
+ if (warrning) {
344
+ Logger({
345
+ level: "WARN",
346
+ message: "Parameter Validation warrnings for showOffers",
347
+ });
348
+ Logger({ level: "WARN", message: warrning });
349
+ }
350
+
172
351
  const query_params = {};
173
352
 
174
- return PlatformAPIClient.execute(
353
+ const response = await PlatformAPIClient.execute(
175
354
  this.config,
176
355
  "get",
177
356
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers/`,
178
357
  query_params,
179
358
  undefined
180
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;
181
374
  }
182
375
 
183
376
  /**
@@ -186,10 +379,11 @@ class Rewards {
186
379
  * @param {string} arg.cookie - User's session cookie. This cookie is set in
187
380
  * browser cookie when logged-in to fynd's authentication system i.e.
188
381
  * `Grimlock` or by using grimlock-backend SDK for backend implementation.
382
+ * @returns {Promise<Offer>} - Success response
189
383
  * @summary: Get offer by name
190
384
  * @description: Use this API to get the offer details and configuration by entering the name of the offer.
191
385
  */
192
- getOfferByName({ name, cookie } = {}) {
386
+ async getOfferByName({ name, cookie } = {}) {
193
387
  const { error } = RewardsValidator.getOfferByName().validate(
194
388
  {
195
389
  name,
@@ -201,25 +395,57 @@ class Rewards {
201
395
  return Promise.reject(new FDKClientValidationError(error));
202
396
  }
203
397
 
398
+ // Showing warrnings if extra unknown parameters are found
399
+ const { error: warrning } = RewardsValidator.getOfferByName().validate(
400
+ {
401
+ name,
402
+ cookie,
403
+ },
404
+ { abortEarly: false, allowUnknown: false }
405
+ );
406
+ if (warrning) {
407
+ Logger({
408
+ level: "WARN",
409
+ message: "Parameter Validation warrnings for getOfferByName",
410
+ });
411
+ Logger({ level: "WARN", message: warrning });
412
+ }
413
+
204
414
  const query_params = {};
205
415
 
206
- return PlatformAPIClient.execute(
416
+ const response = await PlatformAPIClient.execute(
207
417
  this.config,
208
418
  "get",
209
419
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers/${name}/`,
210
420
  query_params,
211
421
  undefined
212
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;
213
438
  }
214
439
 
215
440
  /**
216
441
  * @param {Object} arg - Arg object.
217
442
  * @param {string} arg.name - The name given to the offer.
218
443
  * @param {Offer} arg.body
444
+ * @returns {Promise<Offer>} - Success response
219
445
  * @summary: Update offer by name
220
446
  * @description: Use this API to update the offer details
221
447
  */
222
- updateOfferByName({ name, body } = {}) {
448
+ async updateOfferByName({ name, body } = {}) {
223
449
  const { error } = RewardsValidator.updateOfferByName().validate(
224
450
  {
225
451
  name,
@@ -231,25 +457,57 @@ class Rewards {
231
457
  return Promise.reject(new FDKClientValidationError(error));
232
458
  }
233
459
 
460
+ // Showing warrnings if extra unknown parameters are found
461
+ const { error: warrning } = RewardsValidator.updateOfferByName().validate(
462
+ {
463
+ name,
464
+ body,
465
+ },
466
+ { abortEarly: false, allowUnknown: false }
467
+ );
468
+ if (warrning) {
469
+ Logger({
470
+ level: "WARN",
471
+ message: "Parameter Validation warrnings for updateOfferByName",
472
+ });
473
+ Logger({ level: "WARN", message: warrning });
474
+ }
475
+
234
476
  const query_params = {};
235
477
 
236
- return PlatformAPIClient.execute(
478
+ const response = await PlatformAPIClient.execute(
237
479
  this.config,
238
480
  "put",
239
481
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers/${name}/`,
240
482
  query_params,
241
483
  body
242
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;
243
500
  }
244
501
 
245
502
  /**
246
503
  * @param {Object} arg - Arg object.
247
504
  * @param {string} arg.userId - User id
248
505
  * @param {AppUser} arg.body
506
+ * @returns {Promise<AppUser>} - Success response
249
507
  * @summary: Update user status
250
508
  * @description: Use this API to update the user status active/archive
251
509
  */
252
- updateUserStatus({ userId, body } = {}) {
510
+ async updateUserStatus({ userId, body } = {}) {
253
511
  const { error } = RewardsValidator.updateUserStatus().validate(
254
512
  {
255
513
  userId,
@@ -261,24 +519,56 @@ class Rewards {
261
519
  return Promise.reject(new FDKClientValidationError(error));
262
520
  }
263
521
 
522
+ // Showing warrnings if extra unknown parameters are found
523
+ const { error: warrning } = RewardsValidator.updateUserStatus().validate(
524
+ {
525
+ userId,
526
+ body,
527
+ },
528
+ { abortEarly: false, allowUnknown: false }
529
+ );
530
+ if (warrning) {
531
+ Logger({
532
+ level: "WARN",
533
+ message: "Parameter Validation warrnings for updateUserStatus",
534
+ });
535
+ Logger({ level: "WARN", message: warrning });
536
+ }
537
+
264
538
  const query_params = {};
265
539
 
266
- return PlatformAPIClient.execute(
540
+ const response = await PlatformAPIClient.execute(
267
541
  this.config,
268
542
  "patch",
269
543
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/users/${userId}/`,
270
544
  query_params,
271
545
  body
272
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;
273
562
  }
274
563
 
275
564
  /**
276
565
  * @param {Object} arg - Arg object.
277
566
  * @param {string} arg.userId - User id
567
+ * @returns {Promise<UserRes>} - Success response
278
568
  * @summary: Get user reward details
279
569
  * @description: Use this API to get the user reward details
280
570
  */
281
- user({ userId } = {}) {
571
+ async user({ userId } = {}) {
282
572
  const { error } = RewardsValidator.user().validate(
283
573
  {
284
574
  userId,
@@ -289,15 +579,45 @@ class Rewards {
289
579
  return Promise.reject(new FDKClientValidationError(error));
290
580
  }
291
581
 
582
+ // Showing warrnings if extra unknown parameters are found
583
+ const { error: warrning } = RewardsValidator.user().validate(
584
+ {
585
+ userId,
586
+ },
587
+ { abortEarly: false, allowUnknown: false }
588
+ );
589
+ if (warrning) {
590
+ Logger({
591
+ level: "WARN",
592
+ message: "Parameter Validation warrnings for user",
593
+ });
594
+ Logger({ level: "WARN", message: warrning });
595
+ }
596
+
292
597
  const query_params = {};
293
598
 
294
- return PlatformAPIClient.execute(
599
+ const response = await PlatformAPIClient.execute(
295
600
  this.config,
296
601
  "get",
297
602
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/users/${userId}/`,
298
603
  query_params,
299
604
  undefined
300
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;
301
621
  }
302
622
 
303
623
  /**
@@ -306,10 +626,11 @@ class Rewards {
306
626
  * @param {string} [arg.pageId] - PageID is the ID of the requested page.
307
627
  * For first request it should be kept empty.
308
628
  * @param {number} [arg.pageSize] - The number of items to retrieve in each page.
629
+ * @returns {Promise<HistoryRes>} - Success response
309
630
  * @summary: Get all transactions of reward points
310
631
  * @description: Use this API to get a list of points transactions.
311
632
  */
312
- getUserPointsHistory({ userId, pageId, pageSize } = {}) {
633
+ async getUserPointsHistory({ userId, pageId, pageSize } = {}) {
313
634
  const { error } = RewardsValidator.getUserPointsHistory().validate(
314
635
  {
315
636
  userId,
@@ -322,17 +643,51 @@ class Rewards {
322
643
  return Promise.reject(new FDKClientValidationError(error));
323
644
  }
324
645
 
646
+ // Showing warrnings if extra unknown parameters are found
647
+ const {
648
+ error: warrning,
649
+ } = RewardsValidator.getUserPointsHistory().validate(
650
+ {
651
+ userId,
652
+ pageId,
653
+ pageSize,
654
+ },
655
+ { abortEarly: false, allowUnknown: false }
656
+ );
657
+ if (warrning) {
658
+ Logger({
659
+ level: "WARN",
660
+ message: "Parameter Validation warrnings for getUserPointsHistory",
661
+ });
662
+ Logger({ level: "WARN", message: warrning });
663
+ }
664
+
325
665
  const query_params = {};
326
666
  query_params["page_id"] = pageId;
327
667
  query_params["page_size"] = pageSize;
328
668
 
329
- return PlatformAPIClient.execute(
669
+ const response = await PlatformAPIClient.execute(
330
670
  this.config,
331
671
  "get",
332
672
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/users/${userId}/points/history/`,
333
673
  query_params,
334
674
  undefined
335
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;
336
691
  }
337
692
 
338
693
  /**
@@ -374,10 +729,11 @@ class Rewards {
374
729
 
375
730
  /**
376
731
  * @param {Object} arg - Arg object.
732
+ * @returns {Promise<ConfigurationRes>} - Success response
377
733
  * @summary: Get all valid android paths
378
734
  * @description: Use this API to get a list of valid android paths required by the Rewards INIT API to validate a fradualent device.
379
735
  */
380
- getRewardsConfiguration({} = {}) {
736
+ async getRewardsConfiguration({} = {}) {
381
737
  const { error } = RewardsValidator.getRewardsConfiguration().validate(
382
738
  {},
383
739
  { abortEarly: false, allowUnknown: true }
@@ -386,24 +742,57 @@ class Rewards {
386
742
  return Promise.reject(new FDKClientValidationError(error));
387
743
  }
388
744
 
745
+ // Showing warrnings if extra unknown parameters are found
746
+ const {
747
+ error: warrning,
748
+ } = RewardsValidator.getRewardsConfiguration().validate(
749
+ {},
750
+ { abortEarly: false, allowUnknown: false }
751
+ );
752
+ if (warrning) {
753
+ Logger({
754
+ level: "WARN",
755
+ message: "Parameter Validation warrnings for getRewardsConfiguration",
756
+ });
757
+ Logger({ level: "WARN", message: warrning });
758
+ }
759
+
389
760
  const query_params = {};
390
761
 
391
- return PlatformAPIClient.execute(
762
+ const response = await PlatformAPIClient.execute(
392
763
  this.config,
393
764
  "get",
394
765
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/configuration/`,
395
766
  query_params,
396
767
  undefined
397
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;
398
786
  }
399
787
 
400
788
  /**
401
789
  * @param {Object} arg - Arg object.
402
790
  * @param {ConfigurationRequest} arg.body
791
+ * @returns {Promise<SetConfigurationRes>} - Success response
403
792
  * @summary: Updates the collection with given android paths.
404
793
  * @description: Updates the configuration or inserts new records.
405
794
  */
406
- setRewardsConfiguration({ body } = {}) {
795
+ async setRewardsConfiguration({ body } = {}) {
407
796
  const { error } = RewardsValidator.setRewardsConfiguration().validate(
408
797
  {
409
798
  body,
@@ -414,15 +803,49 @@ class Rewards {
414
803
  return Promise.reject(new FDKClientValidationError(error));
415
804
  }
416
805
 
806
+ // Showing warrnings if extra unknown parameters are found
807
+ const {
808
+ error: warrning,
809
+ } = RewardsValidator.setRewardsConfiguration().validate(
810
+ {
811
+ body,
812
+ },
813
+ { abortEarly: false, allowUnknown: false }
814
+ );
815
+ if (warrning) {
816
+ Logger({
817
+ level: "WARN",
818
+ message: "Parameter Validation warrnings for setRewardsConfiguration",
819
+ });
820
+ Logger({ level: "WARN", message: warrning });
821
+ }
822
+
417
823
  const query_params = {};
418
824
 
419
- return PlatformAPIClient.execute(
825
+ const response = await PlatformAPIClient.execute(
420
826
  this.config,
421
827
  "post",
422
828
  `/service/platform/rewards/v1.0/company/${this.config.companyId}/application/${this.applicationId}/configuration/`,
423
829
  query_params,
424
830
  body
425
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;
426
849
  }
427
850
  }
428
851
  module.exports = Rewards;