@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,9 @@ const Paginator = require("../../common/Paginator");
2
2
  const { FDKClientValidationError } = require("../../common/FDKError");
3
3
  const PlatformAPIClient = require("../PlatformAPIClient");
4
4
  const DiscountValidator = require("./DiscountPlatformValidator");
5
+ const DiscountModel = require("./DiscountPlatformModel");
6
+ const { Logger } = require("./../../common/Logger");
7
+
5
8
  class Discount {
6
9
  constructor(config) {
7
10
  this.config = config;
@@ -19,10 +22,11 @@ class Discount {
19
22
  * @param {number} [arg.year] - Year. Default is current year.
20
23
  * @param {string} [arg.type] - Basic or custom.
21
24
  * @param {string[]} [arg.appIds] - Application ids.
25
+ * @returns {Promise<ListOrCalender>} - Success response
22
26
  * @summary: Fetch discount list.
23
27
  * @description: Fetch discount list.
24
28
  */
25
- getDiscounts({
29
+ async getDiscounts({
26
30
  view,
27
31
  q,
28
32
  pageNo,
@@ -51,6 +55,29 @@ class Discount {
51
55
  return Promise.reject(new FDKClientValidationError(error));
52
56
  }
53
57
 
58
+ // Showing warrnings if extra unknown parameters are found
59
+ const { error: warrning } = DiscountValidator.getDiscounts().validate(
60
+ {
61
+ view,
62
+ q,
63
+ pageNo,
64
+ pageSize,
65
+ archived,
66
+ month,
67
+ year,
68
+ type,
69
+ appIds,
70
+ },
71
+ { abortEarly: false, allowUnknown: false }
72
+ );
73
+ if (warrning) {
74
+ Logger({
75
+ level: "WARN",
76
+ message: "Parameter Validation warrnings for getDiscounts",
77
+ });
78
+ Logger({ level: "WARN", message: warrning });
79
+ }
80
+
54
81
  const query_params = {};
55
82
  query_params["view"] = view;
56
83
  query_params["q"] = q;
@@ -64,7 +91,7 @@ class Discount {
64
91
 
65
92
  const xHeaders = {};
66
93
 
67
- return PlatformAPIClient.execute(
94
+ const response = await PlatformAPIClient.execute(
68
95
  this.config,
69
96
  "get",
70
97
  `/service/platform/discount/v1.0/company/${this.config.companyId}/job/`,
@@ -72,15 +99,33 @@ class Discount {
72
99
  undefined,
73
100
  xHeaders
74
101
  );
102
+
103
+ const {
104
+ error: res_error,
105
+ } = DiscountModel.ListOrCalender().validate(response, {
106
+ abortEarly: false,
107
+ allowUnknown: false,
108
+ });
109
+
110
+ if (res_error) {
111
+ Logger({
112
+ level: "WARN",
113
+ message: "Response Validation Warnnings for getDiscounts",
114
+ });
115
+ Logger({ level: "WARN", message: res_error });
116
+ }
117
+
118
+ return response;
75
119
  }
76
120
 
77
121
  /**
78
122
  * @param {Object} arg - Arg object.
79
123
  * @param {CreateUpdateDiscount} arg.body
124
+ * @returns {Promise<DiscountJob>} - Success response
80
125
  * @summary: Create Discount.
81
126
  * @description: Create Discount.
82
127
  */
83
- createDiscount({ body } = {}) {
128
+ async createDiscount({ body } = {}) {
84
129
  const { error } = DiscountValidator.createDiscount().validate(
85
130
  {
86
131
  body,
@@ -91,11 +136,26 @@ class Discount {
91
136
  return Promise.reject(new FDKClientValidationError(error));
92
137
  }
93
138
 
139
+ // Showing warrnings if extra unknown parameters are found
140
+ const { error: warrning } = DiscountValidator.createDiscount().validate(
141
+ {
142
+ body,
143
+ },
144
+ { abortEarly: false, allowUnknown: false }
145
+ );
146
+ if (warrning) {
147
+ Logger({
148
+ level: "WARN",
149
+ message: "Parameter Validation warrnings for createDiscount",
150
+ });
151
+ Logger({ level: "WARN", message: warrning });
152
+ }
153
+
94
154
  const query_params = {};
95
155
 
96
156
  const xHeaders = {};
97
157
 
98
- return PlatformAPIClient.execute(
158
+ const response = await PlatformAPIClient.execute(
99
159
  this.config,
100
160
  "post",
101
161
  `/service/platform/discount/v1.0/company/${this.config.companyId}/job/`,
@@ -103,15 +163,31 @@ class Discount {
103
163
  body,
104
164
  xHeaders
105
165
  );
166
+
167
+ const { error: res_error } = DiscountModel.DiscountJob().validate(
168
+ response,
169
+ { abortEarly: false, allowUnknown: false }
170
+ );
171
+
172
+ if (res_error) {
173
+ Logger({
174
+ level: "WARN",
175
+ message: "Response Validation Warnnings for createDiscount",
176
+ });
177
+ Logger({ level: "WARN", message: res_error });
178
+ }
179
+
180
+ return response;
106
181
  }
107
182
 
108
183
  /**
109
184
  * @param {Object} arg - Arg object.
110
185
  * @param {string} arg.id - Unique id.
186
+ * @returns {Promise<DiscountJob>} - Success response
111
187
  * @summary: Fetch discount.
112
188
  * @description: Fetch discount.
113
189
  */
114
- getDiscount({ id } = {}) {
190
+ async getDiscount({ id } = {}) {
115
191
  const { error } = DiscountValidator.getDiscount().validate(
116
192
  {
117
193
  id,
@@ -122,11 +198,26 @@ class Discount {
122
198
  return Promise.reject(new FDKClientValidationError(error));
123
199
  }
124
200
 
201
+ // Showing warrnings if extra unknown parameters are found
202
+ const { error: warrning } = DiscountValidator.getDiscount().validate(
203
+ {
204
+ id,
205
+ },
206
+ { abortEarly: false, allowUnknown: false }
207
+ );
208
+ if (warrning) {
209
+ Logger({
210
+ level: "WARN",
211
+ message: "Parameter Validation warrnings for getDiscount",
212
+ });
213
+ Logger({ level: "WARN", message: warrning });
214
+ }
215
+
125
216
  const query_params = {};
126
217
 
127
218
  const xHeaders = {};
128
219
 
129
- return PlatformAPIClient.execute(
220
+ const response = await PlatformAPIClient.execute(
130
221
  this.config,
131
222
  "get",
132
223
  `/service/platform/discount/v1.0/company/${this.config.companyId}/job/${id}/`,
@@ -134,16 +225,32 @@ class Discount {
134
225
  undefined,
135
226
  xHeaders
136
227
  );
228
+
229
+ const { error: res_error } = DiscountModel.DiscountJob().validate(
230
+ response,
231
+ { abortEarly: false, allowUnknown: false }
232
+ );
233
+
234
+ if (res_error) {
235
+ Logger({
236
+ level: "WARN",
237
+ message: "Response Validation Warnnings for getDiscount",
238
+ });
239
+ Logger({ level: "WARN", message: res_error });
240
+ }
241
+
242
+ return response;
137
243
  }
138
244
 
139
245
  /**
140
246
  * @param {Object} arg - Arg object.
141
247
  * @param {string} arg.id - Id
142
248
  * @param {CreateUpdateDiscount} arg.body
249
+ * @returns {Promise<DiscountJob>} - Success response
143
250
  * @summary: Create Discount.
144
251
  * @description: Create Discount.
145
252
  */
146
- updateDiscount({ id, body } = {}) {
253
+ async updateDiscount({ id, body } = {}) {
147
254
  const { error } = DiscountValidator.updateDiscount().validate(
148
255
  {
149
256
  id,
@@ -155,11 +262,27 @@ class Discount {
155
262
  return Promise.reject(new FDKClientValidationError(error));
156
263
  }
157
264
 
265
+ // Showing warrnings if extra unknown parameters are found
266
+ const { error: warrning } = DiscountValidator.updateDiscount().validate(
267
+ {
268
+ id,
269
+ body,
270
+ },
271
+ { abortEarly: false, allowUnknown: false }
272
+ );
273
+ if (warrning) {
274
+ Logger({
275
+ level: "WARN",
276
+ message: "Parameter Validation warrnings for updateDiscount",
277
+ });
278
+ Logger({ level: "WARN", message: warrning });
279
+ }
280
+
158
281
  const query_params = {};
159
282
 
160
283
  const xHeaders = {};
161
284
 
162
- return PlatformAPIClient.execute(
285
+ const response = await PlatformAPIClient.execute(
163
286
  this.config,
164
287
  "put",
165
288
  `/service/platform/discount/v1.0/company/${this.config.companyId}/job/${id}/`,
@@ -167,16 +290,32 @@ class Discount {
167
290
  body,
168
291
  xHeaders
169
292
  );
293
+
294
+ const { error: res_error } = DiscountModel.DiscountJob().validate(
295
+ response,
296
+ { abortEarly: false, allowUnknown: false }
297
+ );
298
+
299
+ if (res_error) {
300
+ Logger({
301
+ level: "WARN",
302
+ message: "Response Validation Warnnings for updateDiscount",
303
+ });
304
+ Logger({ level: "WARN", message: res_error });
305
+ }
306
+
307
+ return response;
170
308
  }
171
309
 
172
310
  /**
173
311
  * @param {Object} arg - Arg object.
174
312
  * @param {string} arg.id - Job ID of the discount.
175
313
  * @param {BulkDiscount} arg.body
314
+ * @returns {Promise<Object>} - Success response
176
315
  * @summary: Create custom discount from bulk.
177
316
  * @description: Create custom discounts through API.
178
317
  */
179
- upsertDiscountItems({ id, body } = {}) {
318
+ async upsertDiscountItems({ id, body } = {}) {
180
319
  const { error } = DiscountValidator.upsertDiscountItems().validate(
181
320
  {
182
321
  id,
@@ -188,11 +327,29 @@ class Discount {
188
327
  return Promise.reject(new FDKClientValidationError(error));
189
328
  }
190
329
 
330
+ // Showing warrnings if extra unknown parameters are found
331
+ const {
332
+ error: warrning,
333
+ } = DiscountValidator.upsertDiscountItems().validate(
334
+ {
335
+ id,
336
+ body,
337
+ },
338
+ { abortEarly: false, allowUnknown: false }
339
+ );
340
+ if (warrning) {
341
+ Logger({
342
+ level: "WARN",
343
+ message: "Parameter Validation warrnings for upsertDiscountItems",
344
+ });
345
+ Logger({ level: "WARN", message: warrning });
346
+ }
347
+
191
348
  const query_params = {};
192
349
 
193
350
  const xHeaders = {};
194
351
 
195
- return PlatformAPIClient.execute(
352
+ const response = await PlatformAPIClient.execute(
196
353
  this.config,
197
354
  "post",
198
355
  `/service/platform/discount/v1.0/company/${this.config.companyId}/job/${id}/items/`,
@@ -200,16 +357,32 @@ class Discount {
200
357
  body,
201
358
  xHeaders
202
359
  );
360
+
361
+ const { error: res_error } = Joi.any().validate(response, {
362
+ abortEarly: false,
363
+ allowUnknown: false,
364
+ });
365
+
366
+ if (res_error) {
367
+ Logger({
368
+ level: "WARN",
369
+ message: "Response Validation Warnnings for upsertDiscountItems",
370
+ });
371
+ Logger({ level: "WARN", message: res_error });
372
+ }
373
+
374
+ return response;
203
375
  }
204
376
 
205
377
  /**
206
378
  * @param {Object} arg - Arg object.
207
379
  * @param {string} [arg.discount] - Discount
208
380
  * @param {DiscountJob} arg.body
381
+ * @returns {Promise<FileJobResponse>} - Success response
209
382
  * @summary: Validate File.
210
383
  * @description: Validate File.
211
384
  */
212
- validateDiscountFile({ body, discount } = {}) {
385
+ async validateDiscountFile({ body, discount } = {}) {
213
386
  const { error } = DiscountValidator.validateDiscountFile().validate(
214
387
  {
215
388
  body,
@@ -221,12 +394,30 @@ class Discount {
221
394
  return Promise.reject(new FDKClientValidationError(error));
222
395
  }
223
396
 
397
+ // Showing warrnings if extra unknown parameters are found
398
+ const {
399
+ error: warrning,
400
+ } = DiscountValidator.validateDiscountFile().validate(
401
+ {
402
+ body,
403
+ discount,
404
+ },
405
+ { abortEarly: false, allowUnknown: false }
406
+ );
407
+ if (warrning) {
408
+ Logger({
409
+ level: "WARN",
410
+ message: "Parameter Validation warrnings for validateDiscountFile",
411
+ });
412
+ Logger({ level: "WARN", message: warrning });
413
+ }
414
+
224
415
  const query_params = {};
225
416
  query_params["discount"] = discount;
226
417
 
227
418
  const xHeaders = {};
228
419
 
229
- return PlatformAPIClient.execute(
420
+ const response = await PlatformAPIClient.execute(
230
421
  this.config,
231
422
  "post",
232
423
  `/service/platform/discount/v1.0/company/${this.config.companyId}/file/validation/`,
@@ -234,16 +425,34 @@ class Discount {
234
425
  body,
235
426
  xHeaders
236
427
  );
428
+
429
+ const {
430
+ error: res_error,
431
+ } = DiscountModel.FileJobResponse().validate(response, {
432
+ abortEarly: false,
433
+ allowUnknown: false,
434
+ });
435
+
436
+ if (res_error) {
437
+ Logger({
438
+ level: "WARN",
439
+ message: "Response Validation Warnnings for validateDiscountFile",
440
+ });
441
+ Logger({ level: "WARN", message: res_error });
442
+ }
443
+
444
+ return response;
237
445
  }
238
446
 
239
447
  /**
240
448
  * @param {Object} arg - Arg object.
241
449
  * @param {string} arg.type - Type
242
450
  * @param {DownloadFileJob} arg.body
451
+ * @returns {Promise<FileJobResponse>} - Success response
243
452
  * @summary: Validate File.
244
453
  * @description: Validate File.
245
454
  */
246
- downloadDiscountFile({ type, body } = {}) {
455
+ async downloadDiscountFile({ type, body } = {}) {
247
456
  const { error } = DiscountValidator.downloadDiscountFile().validate(
248
457
  {
249
458
  type,
@@ -255,11 +464,29 @@ class Discount {
255
464
  return Promise.reject(new FDKClientValidationError(error));
256
465
  }
257
466
 
467
+ // Showing warrnings if extra unknown parameters are found
468
+ const {
469
+ error: warrning,
470
+ } = DiscountValidator.downloadDiscountFile().validate(
471
+ {
472
+ type,
473
+ body,
474
+ },
475
+ { abortEarly: false, allowUnknown: false }
476
+ );
477
+ if (warrning) {
478
+ Logger({
479
+ level: "WARN",
480
+ message: "Parameter Validation warrnings for downloadDiscountFile",
481
+ });
482
+ Logger({ level: "WARN", message: warrning });
483
+ }
484
+
258
485
  const query_params = {};
259
486
 
260
487
  const xHeaders = {};
261
488
 
262
- return PlatformAPIClient.execute(
489
+ const response = await PlatformAPIClient.execute(
263
490
  this.config,
264
491
  "post",
265
492
  `/service/platform/discount/v1.0/company/${this.config.companyId}/file/${type}/download/`,
@@ -267,15 +494,33 @@ class Discount {
267
494
  body,
268
495
  xHeaders
269
496
  );
497
+
498
+ const {
499
+ error: res_error,
500
+ } = DiscountModel.FileJobResponse().validate(response, {
501
+ abortEarly: false,
502
+ allowUnknown: false,
503
+ });
504
+
505
+ if (res_error) {
506
+ Logger({
507
+ level: "WARN",
508
+ message: "Response Validation Warnnings for downloadDiscountFile",
509
+ });
510
+ Logger({ level: "WARN", message: res_error });
511
+ }
512
+
513
+ return response;
270
514
  }
271
515
 
272
516
  /**
273
517
  * @param {Object} arg - Arg object.
274
518
  * @param {string} arg.id - Id
519
+ * @returns {Promise<FileJobResponse>} - Success response
275
520
  * @summary: Validate File Job.
276
521
  * @description: Validate File Job.
277
522
  */
278
- getValidationJob({ id } = {}) {
523
+ async getValidationJob({ id } = {}) {
279
524
  const { error } = DiscountValidator.getValidationJob().validate(
280
525
  {
281
526
  id,
@@ -286,11 +531,26 @@ class Discount {
286
531
  return Promise.reject(new FDKClientValidationError(error));
287
532
  }
288
533
 
534
+ // Showing warrnings if extra unknown parameters are found
535
+ const { error: warrning } = DiscountValidator.getValidationJob().validate(
536
+ {
537
+ id,
538
+ },
539
+ { abortEarly: false, allowUnknown: false }
540
+ );
541
+ if (warrning) {
542
+ Logger({
543
+ level: "WARN",
544
+ message: "Parameter Validation warrnings for getValidationJob",
545
+ });
546
+ Logger({ level: "WARN", message: warrning });
547
+ }
548
+
289
549
  const query_params = {};
290
550
 
291
551
  const xHeaders = {};
292
552
 
293
- return PlatformAPIClient.execute(
553
+ const response = await PlatformAPIClient.execute(
294
554
  this.config,
295
555
  "get",
296
556
  `/service/platform/discount/v1.0/company/${this.config.companyId}/file/validation/${id}/`,
@@ -298,15 +558,33 @@ class Discount {
298
558
  undefined,
299
559
  xHeaders
300
560
  );
561
+
562
+ const {
563
+ error: res_error,
564
+ } = DiscountModel.FileJobResponse().validate(response, {
565
+ abortEarly: false,
566
+ allowUnknown: false,
567
+ });
568
+
569
+ if (res_error) {
570
+ Logger({
571
+ level: "WARN",
572
+ message: "Response Validation Warnnings for getValidationJob",
573
+ });
574
+ Logger({ level: "WARN", message: res_error });
575
+ }
576
+
577
+ return response;
301
578
  }
302
579
 
303
580
  /**
304
581
  * @param {Object} arg - Arg object.
305
582
  * @param {string} arg.id - Id
583
+ * @returns {Promise<CancelJobResponse>} - Success response
306
584
  * @summary: Cancel Validation Job.
307
585
  * @description: Cancel Validation Job.
308
586
  */
309
- cancelValidationJob({ id } = {}) {
587
+ async cancelValidationJob({ id } = {}) {
310
588
  const { error } = DiscountValidator.cancelValidationJob().validate(
311
589
  {
312
590
  id,
@@ -317,11 +595,28 @@ class Discount {
317
595
  return Promise.reject(new FDKClientValidationError(error));
318
596
  }
319
597
 
598
+ // Showing warrnings if extra unknown parameters are found
599
+ const {
600
+ error: warrning,
601
+ } = DiscountValidator.cancelValidationJob().validate(
602
+ {
603
+ id,
604
+ },
605
+ { abortEarly: false, allowUnknown: false }
606
+ );
607
+ if (warrning) {
608
+ Logger({
609
+ level: "WARN",
610
+ message: "Parameter Validation warrnings for cancelValidationJob",
611
+ });
612
+ Logger({ level: "WARN", message: warrning });
613
+ }
614
+
320
615
  const query_params = {};
321
616
 
322
617
  const xHeaders = {};
323
618
 
324
- return PlatformAPIClient.execute(
619
+ const response = await PlatformAPIClient.execute(
325
620
  this.config,
326
621
  "delete",
327
622
  `/service/platform/discount/v1.0/company/${this.config.companyId}/file/validation/${id}/`,
@@ -329,15 +624,33 @@ class Discount {
329
624
  undefined,
330
625
  xHeaders
331
626
  );
627
+
628
+ const {
629
+ error: res_error,
630
+ } = DiscountModel.CancelJobResponse().validate(response, {
631
+ abortEarly: false,
632
+ allowUnknown: false,
633
+ });
634
+
635
+ if (res_error) {
636
+ Logger({
637
+ level: "WARN",
638
+ message: "Response Validation Warnnings for cancelValidationJob",
639
+ });
640
+ Logger({ level: "WARN", message: res_error });
641
+ }
642
+
643
+ return response;
332
644
  }
333
645
 
334
646
  /**
335
647
  * @param {Object} arg - Arg object.
336
648
  * @param {string} arg.id - Id
649
+ * @returns {Promise<FileJobResponse>} - Success response
337
650
  * @summary: Download File Job.
338
651
  * @description: Download File Job.
339
652
  */
340
- getDownloadJob({ id } = {}) {
653
+ async getDownloadJob({ id } = {}) {
341
654
  const { error } = DiscountValidator.getDownloadJob().validate(
342
655
  {
343
656
  id,
@@ -348,11 +661,26 @@ class Discount {
348
661
  return Promise.reject(new FDKClientValidationError(error));
349
662
  }
350
663
 
664
+ // Showing warrnings if extra unknown parameters are found
665
+ const { error: warrning } = DiscountValidator.getDownloadJob().validate(
666
+ {
667
+ id,
668
+ },
669
+ { abortEarly: false, allowUnknown: false }
670
+ );
671
+ if (warrning) {
672
+ Logger({
673
+ level: "WARN",
674
+ message: "Parameter Validation warrnings for getDownloadJob",
675
+ });
676
+ Logger({ level: "WARN", message: warrning });
677
+ }
678
+
351
679
  const query_params = {};
352
680
 
353
681
  const xHeaders = {};
354
682
 
355
- return PlatformAPIClient.execute(
683
+ const response = await PlatformAPIClient.execute(
356
684
  this.config,
357
685
  "get",
358
686
  `/service/platform/discount/v1.0/company/${this.config.companyId}/file/download/${id}/`,
@@ -360,15 +688,33 @@ class Discount {
360
688
  undefined,
361
689
  xHeaders
362
690
  );
691
+
692
+ const {
693
+ error: res_error,
694
+ } = DiscountModel.FileJobResponse().validate(response, {
695
+ abortEarly: false,
696
+ allowUnknown: false,
697
+ });
698
+
699
+ if (res_error) {
700
+ Logger({
701
+ level: "WARN",
702
+ message: "Response Validation Warnnings for getDownloadJob",
703
+ });
704
+ Logger({ level: "WARN", message: res_error });
705
+ }
706
+
707
+ return response;
363
708
  }
364
709
 
365
710
  /**
366
711
  * @param {Object} arg - Arg object.
367
712
  * @param {string} arg.id - Id
713
+ * @returns {Promise<CancelJobResponse>} - Success response
368
714
  * @summary: Cancel Download Job.
369
715
  * @description: Cancel Download Job.
370
716
  */
371
- cancelDownloadJob({ id } = {}) {
717
+ async cancelDownloadJob({ id } = {}) {
372
718
  const { error } = DiscountValidator.cancelDownloadJob().validate(
373
719
  {
374
720
  id,
@@ -379,11 +725,26 @@ class Discount {
379
725
  return Promise.reject(new FDKClientValidationError(error));
380
726
  }
381
727
 
728
+ // Showing warrnings if extra unknown parameters are found
729
+ const { error: warrning } = DiscountValidator.cancelDownloadJob().validate(
730
+ {
731
+ id,
732
+ },
733
+ { abortEarly: false, allowUnknown: false }
734
+ );
735
+ if (warrning) {
736
+ Logger({
737
+ level: "WARN",
738
+ message: "Parameter Validation warrnings for cancelDownloadJob",
739
+ });
740
+ Logger({ level: "WARN", message: warrning });
741
+ }
742
+
382
743
  const query_params = {};
383
744
 
384
745
  const xHeaders = {};
385
746
 
386
- return PlatformAPIClient.execute(
747
+ const response = await PlatformAPIClient.execute(
387
748
  this.config,
388
749
  "delete",
389
750
  `/service/platform/discount/v1.0/company/${this.config.companyId}/file/download/${id}/`,
@@ -391,6 +752,23 @@ class Discount {
391
752
  undefined,
392
753
  xHeaders
393
754
  );
755
+
756
+ const {
757
+ error: res_error,
758
+ } = DiscountModel.CancelJobResponse().validate(response, {
759
+ abortEarly: false,
760
+ allowUnknown: false,
761
+ });
762
+
763
+ if (res_error) {
764
+ Logger({
765
+ level: "WARN",
766
+ message: "Response Validation Warnnings for cancelDownloadJob",
767
+ });
768
+ Logger({ level: "WARN", message: res_error });
769
+ }
770
+
771
+ return response;
394
772
  }
395
773
  }
396
774