@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 PaymentValidator = require("./PaymentPlatformApplicationValidator");
5
+ const PaymentModel = require("./PaymentPlatformModel");
6
+ const { Logger } = require("./../../common/Logger");
5
7
 
6
8
  class Payment {
7
9
  constructor(config, applicationId) {
@@ -11,10 +13,11 @@ class Payment {
11
13
 
12
14
  /**
13
15
  * @param {Object} arg - Arg object.
16
+ * @returns {Promise<PaymentGatewayConfigResponse>} - Success response
14
17
  * @summary: Get All Brand Payment Gateway Config Secret
15
18
  * @description: Get All Brand Payment Gateway Config Secret
16
19
  */
17
- getBrandPaymentGatewayConfig({} = {}) {
20
+ async getBrandPaymentGatewayConfig({} = {}) {
18
21
  const { error } = PaymentValidator.getBrandPaymentGatewayConfig().validate(
19
22
  {},
20
23
  { abortEarly: false, allowUnknown: true }
@@ -31,30 +34,51 @@ class Payment {
31
34
  { abortEarly: false, allowUnknown: false }
32
35
  );
33
36
  if (warrning) {
34
- console.log(
35
- "Parameter Validation warrnings for getBrandPaymentGatewayConfig"
36
- );
37
- console.log(warrning);
37
+ Logger({
38
+ level: "WARN",
39
+ message:
40
+ "Parameter Validation warrnings for getBrandPaymentGatewayConfig",
41
+ });
42
+ Logger({ level: "WARN", message: warrning });
38
43
  }
39
44
 
40
45
  const query_params = {};
41
46
 
42
- return PlatformAPIClient.execute(
47
+ const response = await PlatformAPIClient.execute(
43
48
  this.config,
44
49
  "get",
45
50
  `/service/platform/payment/v1.0/company/${this.config.companyId}/application/${this.applicationId}/aggregator/request`,
46
51
  query_params,
47
52
  undefined
48
53
  );
54
+
55
+ const {
56
+ error: res_error,
57
+ } = PaymentModel.PaymentGatewayConfigResponse().validate(response, {
58
+ abortEarly: false,
59
+ allowUnknown: false,
60
+ });
61
+
62
+ if (res_error) {
63
+ Logger({
64
+ level: "WARN",
65
+ message:
66
+ "Response Validation Warnnings for getBrandPaymentGatewayConfig",
67
+ });
68
+ Logger({ level: "WARN", message: res_error });
69
+ }
70
+
71
+ return response;
49
72
  }
50
73
 
51
74
  /**
52
75
  * @param {Object} arg - Arg object.
53
76
  * @param {PaymentGatewayConfigRequest} arg.body
77
+ * @returns {Promise<PaymentGatewayToBeReviewed>} - Success response
54
78
  * @summary: Save Config Secret For Brand Payment Gateway
55
79
  * @description: Save Config Secret For Brand Payment Gateway
56
80
  */
57
- saveBrandPaymentGatewayConfig({ body } = {}) {
81
+ async saveBrandPaymentGatewayConfig({ body } = {}) {
58
82
  const { error } = PaymentValidator.saveBrandPaymentGatewayConfig().validate(
59
83
  {
60
84
  body,
@@ -75,30 +99,51 @@ class Payment {
75
99
  { abortEarly: false, allowUnknown: false }
76
100
  );
77
101
  if (warrning) {
78
- console.log(
79
- "Parameter Validation warrnings for saveBrandPaymentGatewayConfig"
80
- );
81
- console.log(warrning);
102
+ Logger({
103
+ level: "WARN",
104
+ message:
105
+ "Parameter Validation warrnings for saveBrandPaymentGatewayConfig",
106
+ });
107
+ Logger({ level: "WARN", message: warrning });
82
108
  }
83
109
 
84
110
  const query_params = {};
85
111
 
86
- return PlatformAPIClient.execute(
112
+ const response = await PlatformAPIClient.execute(
87
113
  this.config,
88
114
  "post",
89
115
  `/service/platform/payment/v1.0/company/${this.config.companyId}/application/${this.applicationId}/aggregator/request`,
90
116
  query_params,
91
117
  body
92
118
  );
119
+
120
+ const {
121
+ error: res_error,
122
+ } = PaymentModel.PaymentGatewayToBeReviewed().validate(response, {
123
+ abortEarly: false,
124
+ allowUnknown: false,
125
+ });
126
+
127
+ if (res_error) {
128
+ Logger({
129
+ level: "WARN",
130
+ message:
131
+ "Response Validation Warnnings for saveBrandPaymentGatewayConfig",
132
+ });
133
+ Logger({ level: "WARN", message: res_error });
134
+ }
135
+
136
+ return response;
93
137
  }
94
138
 
95
139
  /**
96
140
  * @param {Object} arg - Arg object.
97
141
  * @param {PaymentGatewayConfigRequest} arg.body
142
+ * @returns {Promise<PaymentGatewayToBeReviewed>} - Success response
98
143
  * @summary: Save Config Secret For Brand Payment Gateway
99
144
  * @description: Save Config Secret For Brand Payment Gateway
100
145
  */
101
- updateBrandPaymentGatewayConfig({ body } = {}) {
146
+ async updateBrandPaymentGatewayConfig({ body } = {}) {
102
147
  const {
103
148
  error,
104
149
  } = PaymentValidator.updateBrandPaymentGatewayConfig().validate(
@@ -121,31 +166,52 @@ class Payment {
121
166
  { abortEarly: false, allowUnknown: false }
122
167
  );
123
168
  if (warrning) {
124
- console.log(
125
- "Parameter Validation warrnings for updateBrandPaymentGatewayConfig"
126
- );
127
- console.log(warrning);
169
+ Logger({
170
+ level: "WARN",
171
+ message:
172
+ "Parameter Validation warrnings for updateBrandPaymentGatewayConfig",
173
+ });
174
+ Logger({ level: "WARN", message: warrning });
128
175
  }
129
176
 
130
177
  const query_params = {};
131
178
 
132
- return PlatformAPIClient.execute(
179
+ const response = await PlatformAPIClient.execute(
133
180
  this.config,
134
181
  "put",
135
182
  `/service/platform/payment/v1.0/company/${this.config.companyId}/application/${this.applicationId}/aggregator/request`,
136
183
  query_params,
137
184
  body
138
185
  );
186
+
187
+ const {
188
+ error: res_error,
189
+ } = PaymentModel.PaymentGatewayToBeReviewed().validate(response, {
190
+ abortEarly: false,
191
+ allowUnknown: false,
192
+ });
193
+
194
+ if (res_error) {
195
+ Logger({
196
+ level: "WARN",
197
+ message:
198
+ "Response Validation Warnnings for updateBrandPaymentGatewayConfig",
199
+ });
200
+ Logger({ level: "WARN", message: res_error });
201
+ }
202
+
203
+ return response;
139
204
  }
140
205
 
141
206
  /**
142
207
  * @param {Object} arg - Arg object.
143
208
  * @param {boolean} arg.refresh -
144
209
  * @param {string} arg.requestType -
210
+ * @returns {Promise<PaymentOptionsResponse>} - Success response
145
211
  * @summary: Get All Valid Payment Options
146
212
  * @description: Use this API to get Get All Valid Payment Options for making payment
147
213
  */
148
- getPaymentModeRoutes({ refresh, requestType } = {}) {
214
+ async getPaymentModeRoutes({ refresh, requestType } = {}) {
149
215
  const { error } = PaymentValidator.getPaymentModeRoutes().validate(
150
216
  {
151
217
  refresh,
@@ -168,31 +234,52 @@ class Payment {
168
234
  { abortEarly: false, allowUnknown: false }
169
235
  );
170
236
  if (warrning) {
171
- console.log("Parameter Validation warrnings for getPaymentModeRoutes");
172
- console.log(warrning);
237
+ Logger({
238
+ level: "WARN",
239
+ message: "Parameter Validation warrnings for getPaymentModeRoutes",
240
+ });
241
+ Logger({ level: "WARN", message: warrning });
173
242
  }
174
243
 
175
244
  const query_params = {};
176
245
  query_params["refresh"] = refresh;
177
246
  query_params["request_type"] = requestType;
178
247
 
179
- return PlatformAPIClient.execute(
248
+ const response = await PlatformAPIClient.execute(
180
249
  this.config,
181
250
  "get",
182
251
  `/service/platform/payment/v1.0/company/${this.config.companyId}/application/${this.applicationId}/payment/options`,
183
252
  query_params,
184
253
  undefined
185
254
  );
255
+
256
+ const {
257
+ error: res_error,
258
+ } = PaymentModel.PaymentOptionsResponse().validate(response, {
259
+ abortEarly: false,
260
+ allowUnknown: false,
261
+ });
262
+
263
+ if (res_error) {
264
+ Logger({
265
+ level: "WARN",
266
+ message: "Response Validation Warnnings for getPaymentModeRoutes",
267
+ });
268
+ Logger({ level: "WARN", message: res_error });
269
+ }
270
+
271
+ return response;
186
272
  }
187
273
 
188
274
  /**
189
275
  * @param {Object} arg - Arg object.
190
276
  * @param {string} arg.orderId -
191
277
  * @param {string} [arg.requestHash] -
278
+ * @returns {Promise<RefundAccountResponse>} - Success response
192
279
  * @summary: Get bank details
193
280
  * @description: Use this API to get saved bank details for returned/cancelled order using order id.
194
281
  */
195
- getBankAccountDetailsOpenAPI({ orderId, requestHash } = {}) {
282
+ async getBankAccountDetailsOpenAPI({ orderId, requestHash } = {}) {
196
283
  const { error } = PaymentValidator.getBankAccountDetailsOpenAPI().validate(
197
284
  {
198
285
  orderId,
@@ -215,32 +302,53 @@ class Payment {
215
302
  { abortEarly: false, allowUnknown: false }
216
303
  );
217
304
  if (warrning) {
218
- console.log(
219
- "Parameter Validation warrnings for getBankAccountDetailsOpenAPI"
220
- );
221
- console.log(warrning);
305
+ Logger({
306
+ level: "WARN",
307
+ message:
308
+ "Parameter Validation warrnings for getBankAccountDetailsOpenAPI",
309
+ });
310
+ Logger({ level: "WARN", message: warrning });
222
311
  }
223
312
 
224
313
  const query_params = {};
225
314
  query_params["order_id"] = orderId;
226
315
  query_params["request_hash"] = requestHash;
227
316
 
228
- return PlatformAPIClient.execute(
317
+ const response = await PlatformAPIClient.execute(
229
318
  this.config,
230
319
  "get",
231
320
  `/service/platform/payment/v1.0/company/${this.config.companyId}/application/${this.applicationId}/refund/account`,
232
321
  query_params,
233
322
  undefined
234
323
  );
324
+
325
+ const {
326
+ error: res_error,
327
+ } = PaymentModel.RefundAccountResponse().validate(response, {
328
+ abortEarly: false,
329
+ allowUnknown: false,
330
+ });
331
+
332
+ if (res_error) {
333
+ Logger({
334
+ level: "WARN",
335
+ message:
336
+ "Response Validation Warnnings for getBankAccountDetailsOpenAPI",
337
+ });
338
+ Logger({ level: "WARN", message: res_error });
339
+ }
340
+
341
+ return response;
235
342
  }
236
343
 
237
344
  /**
238
345
  * @param {Object} arg - Arg object.
239
346
  * @param {AddBeneficiaryDetailsOTPRequest} arg.body
347
+ * @returns {Promise<RefundAccountResponse>} - Success response
240
348
  * @summary: Save bank details for cancelled/returned order
241
349
  * @description: Use this API to save bank details for returned/cancelled order to refund amount in his account.
242
350
  */
243
- addRefundBankAccountUsingOTP({ body } = {}) {
351
+ async addRefundBankAccountUsingOTP({ body } = {}) {
244
352
  const { error } = PaymentValidator.addRefundBankAccountUsingOTP().validate(
245
353
  {
246
354
  body,
@@ -261,30 +369,51 @@ class Payment {
261
369
  { abortEarly: false, allowUnknown: false }
262
370
  );
263
371
  if (warrning) {
264
- console.log(
265
- "Parameter Validation warrnings for addRefundBankAccountUsingOTP"
266
- );
267
- console.log(warrning);
372
+ Logger({
373
+ level: "WARN",
374
+ message:
375
+ "Parameter Validation warrnings for addRefundBankAccountUsingOTP",
376
+ });
377
+ Logger({ level: "WARN", message: warrning });
268
378
  }
269
379
 
270
380
  const query_params = {};
271
381
 
272
- return PlatformAPIClient.execute(
382
+ const response = await PlatformAPIClient.execute(
273
383
  this.config,
274
384
  "post",
275
385
  `/service/platform/payment/v1.0/company/${this.config.companyId}/application/${this.applicationId}/refund/account`,
276
386
  query_params,
277
387
  body
278
388
  );
389
+
390
+ const {
391
+ error: res_error,
392
+ } = PaymentModel.RefundAccountResponse().validate(response, {
393
+ abortEarly: false,
394
+ allowUnknown: false,
395
+ });
396
+
397
+ if (res_error) {
398
+ Logger({
399
+ level: "WARN",
400
+ message:
401
+ "Response Validation Warnnings for addRefundBankAccountUsingOTP",
402
+ });
403
+ Logger({ level: "WARN", message: res_error });
404
+ }
405
+
406
+ return response;
279
407
  }
280
408
 
281
409
  /**
282
410
  * @param {Object} arg - Arg object.
283
411
  * @param {string} arg.orderId -
412
+ * @returns {Promise<OrderBeneficiaryResponse>} - Success response
284
413
  * @summary: List Order Beneficiary
285
414
  * @description: Get all active beneficiary details added by the user for refund
286
415
  */
287
- getUserOrderBeneficiaries({ orderId } = {}) {
416
+ async getUserOrderBeneficiaries({ orderId } = {}) {
288
417
  const { error } = PaymentValidator.getUserOrderBeneficiaries().validate(
289
418
  {
290
419
  orderId,
@@ -305,31 +434,50 @@ class Payment {
305
434
  { abortEarly: false, allowUnknown: false }
306
435
  );
307
436
  if (warrning) {
308
- console.log(
309
- "Parameter Validation warrnings for getUserOrderBeneficiaries"
310
- );
311
- console.log(warrning);
437
+ Logger({
438
+ level: "WARN",
439
+ message: "Parameter Validation warrnings for getUserOrderBeneficiaries",
440
+ });
441
+ Logger({ level: "WARN", message: warrning });
312
442
  }
313
443
 
314
444
  const query_params = {};
315
445
  query_params["order_id"] = orderId;
316
446
 
317
- return PlatformAPIClient.execute(
447
+ const response = await PlatformAPIClient.execute(
318
448
  this.config,
319
449
  "get",
320
450
  `/service/platform/payment/v1.0/company/${this.config.companyId}/application/${this.applicationId}/refund/accounts/order`,
321
451
  query_params,
322
452
  undefined
323
453
  );
454
+
455
+ const {
456
+ error: res_error,
457
+ } = PaymentModel.OrderBeneficiaryResponse().validate(response, {
458
+ abortEarly: false,
459
+ allowUnknown: false,
460
+ });
461
+
462
+ if (res_error) {
463
+ Logger({
464
+ level: "WARN",
465
+ message: "Response Validation Warnnings for getUserOrderBeneficiaries",
466
+ });
467
+ Logger({ level: "WARN", message: res_error });
468
+ }
469
+
470
+ return response;
324
471
  }
325
472
 
326
473
  /**
327
474
  * @param {Object} arg - Arg object.
328
475
  * @param {string} arg.orderId -
476
+ * @returns {Promise<OrderBeneficiaryResponse>} - Success response
329
477
  * @summary: List User Beneficiary
330
478
  * @description: Get all active beneficiary details added by the user for refund
331
479
  */
332
- getUserBeneficiaries({ orderId } = {}) {
480
+ async getUserBeneficiaries({ orderId } = {}) {
333
481
  const { error } = PaymentValidator.getUserBeneficiaries().validate(
334
482
  {
335
483
  orderId,
@@ -350,29 +498,50 @@ class Payment {
350
498
  { abortEarly: false, allowUnknown: false }
351
499
  );
352
500
  if (warrning) {
353
- console.log("Parameter Validation warrnings for getUserBeneficiaries");
354
- console.log(warrning);
501
+ Logger({
502
+ level: "WARN",
503
+ message: "Parameter Validation warrnings for getUserBeneficiaries",
504
+ });
505
+ Logger({ level: "WARN", message: warrning });
355
506
  }
356
507
 
357
508
  const query_params = {};
358
509
  query_params["order_id"] = orderId;
359
510
 
360
- return PlatformAPIClient.execute(
511
+ const response = await PlatformAPIClient.execute(
361
512
  this.config,
362
513
  "get",
363
514
  `/service/platform/payment/v1.0/company/${this.config.companyId}/application/${this.applicationId}/refund/accounts/user`,
364
515
  query_params,
365
516
  undefined
366
517
  );
518
+
519
+ const {
520
+ error: res_error,
521
+ } = PaymentModel.OrderBeneficiaryResponse().validate(response, {
522
+ abortEarly: false,
523
+ allowUnknown: false,
524
+ });
525
+
526
+ if (res_error) {
527
+ Logger({
528
+ level: "WARN",
529
+ message: "Response Validation Warnnings for getUserBeneficiaries",
530
+ });
531
+ Logger({ level: "WARN", message: res_error });
532
+ }
533
+
534
+ return response;
367
535
  }
368
536
 
369
537
  /**
370
538
  * @param {Object} arg - Arg object.
371
539
  * @param {PaymentConfirmationRequest} arg.body
540
+ * @returns {Promise<PaymentConfirmationResponse>} - Success response
372
541
  * @summary: Confirm payment after successful payment from payment gateway
373
542
  * @description: Use this API to confirm payment after payment gateway accepted payment.
374
543
  */
375
- confirmPayment({ body } = {}) {
544
+ async confirmPayment({ body } = {}) {
376
545
  const { error } = PaymentValidator.confirmPayment().validate(
377
546
  {
378
547
  body,
@@ -391,29 +560,50 @@ class Payment {
391
560
  { abortEarly: false, allowUnknown: false }
392
561
  );
393
562
  if (warrning) {
394
- console.log("Parameter Validation warrnings for confirmPayment");
395
- console.log(warrning);
563
+ Logger({
564
+ level: "WARN",
565
+ message: "Parameter Validation warrnings for confirmPayment",
566
+ });
567
+ Logger({ level: "WARN", message: warrning });
396
568
  }
397
569
 
398
570
  const query_params = {};
399
571
 
400
- return PlatformAPIClient.execute(
572
+ const response = await PlatformAPIClient.execute(
401
573
  this.config,
402
574
  "post",
403
575
  `/service/platform/payment/v1.0/company/${this.config.companyId}/application/${this.applicationId}/payment/confirm`,
404
576
  query_params,
405
577
  body
406
578
  );
579
+
580
+ const {
581
+ error: res_error,
582
+ } = PaymentModel.PaymentConfirmationResponse().validate(response, {
583
+ abortEarly: false,
584
+ allowUnknown: false,
585
+ });
586
+
587
+ if (res_error) {
588
+ Logger({
589
+ level: "WARN",
590
+ message: "Response Validation Warnnings for confirmPayment",
591
+ });
592
+ Logger({ level: "WARN", message: res_error });
593
+ }
594
+
595
+ return response;
407
596
  }
408
597
 
409
598
  /**
410
599
  * @param {Object} arg - Arg object.
411
600
  * @param {string} arg.merchantUserId -
412
601
  * @param {string} arg.mobileNo -
602
+ * @returns {Promise<GetUserCODLimitResponse>} - Success response
413
603
  * @summary: Get COD limit for user
414
604
  * @description: Use this API to get user cod limit and reamining limit for the payment
415
605
  */
416
- getUserCODlimitRoutes({ merchantUserId, mobileNo } = {}) {
606
+ async getUserCODlimitRoutes({ merchantUserId, mobileNo } = {}) {
417
607
  const { error } = PaymentValidator.getUserCODlimitRoutes().validate(
418
608
  {
419
609
  merchantUserId,
@@ -436,30 +626,51 @@ class Payment {
436
626
  { abortEarly: false, allowUnknown: false }
437
627
  );
438
628
  if (warrning) {
439
- console.log("Parameter Validation warrnings for getUserCODlimitRoutes");
440
- console.log(warrning);
629
+ Logger({
630
+ level: "WARN",
631
+ message: "Parameter Validation warrnings for getUserCODlimitRoutes",
632
+ });
633
+ Logger({ level: "WARN", message: warrning });
441
634
  }
442
635
 
443
636
  const query_params = {};
444
637
  query_params["merchant_user_id"] = merchantUserId;
445
638
  query_params["mobile_no"] = mobileNo;
446
639
 
447
- return PlatformAPIClient.execute(
640
+ const response = await PlatformAPIClient.execute(
448
641
  this.config,
449
642
  "get",
450
643
  `/service/platform/payment/v1.0/company/${this.config.companyId}/application/${this.applicationId}/payment/user-cod`,
451
644
  query_params,
452
645
  undefined
453
646
  );
647
+
648
+ const {
649
+ error: res_error,
650
+ } = PaymentModel.GetUserCODLimitResponse().validate(response, {
651
+ abortEarly: false,
652
+ allowUnknown: false,
653
+ });
654
+
655
+ if (res_error) {
656
+ Logger({
657
+ level: "WARN",
658
+ message: "Response Validation Warnnings for getUserCODlimitRoutes",
659
+ });
660
+ Logger({ level: "WARN", message: res_error });
661
+ }
662
+
663
+ return response;
454
664
  }
455
665
 
456
666
  /**
457
667
  * @param {Object} arg - Arg object.
458
668
  * @param {SetCODForUserRequest} arg.body
669
+ * @returns {Promise<SetCODOptionResponse>} - Success response
459
670
  * @summary: Set COD option for user for payment
460
671
  * @description: Use this API to set cod option as true or false for the payment
461
672
  */
462
- setUserCODlimitRoutes({ body } = {}) {
673
+ async setUserCODlimitRoutes({ body } = {}) {
463
674
  const { error } = PaymentValidator.setUserCODlimitRoutes().validate(
464
675
  {
465
676
  body,
@@ -480,19 +691,39 @@ class Payment {
480
691
  { abortEarly: false, allowUnknown: false }
481
692
  );
482
693
  if (warrning) {
483
- console.log("Parameter Validation warrnings for setUserCODlimitRoutes");
484
- console.log(warrning);
694
+ Logger({
695
+ level: "WARN",
696
+ message: "Parameter Validation warrnings for setUserCODlimitRoutes",
697
+ });
698
+ Logger({ level: "WARN", message: warrning });
485
699
  }
486
700
 
487
701
  const query_params = {};
488
702
 
489
- return PlatformAPIClient.execute(
703
+ const response = await PlatformAPIClient.execute(
490
704
  this.config,
491
705
  "put",
492
706
  `/service/platform/payment/v1.0/company/${this.config.companyId}/application/${this.applicationId}/payment/user-cod`,
493
707
  query_params,
494
708
  body
495
709
  );
710
+
711
+ const {
712
+ error: res_error,
713
+ } = PaymentModel.SetCODOptionResponse().validate(response, {
714
+ abortEarly: false,
715
+ allowUnknown: false,
716
+ });
717
+
718
+ if (res_error) {
719
+ Logger({
720
+ level: "WARN",
721
+ message: "Response Validation Warnnings for setUserCODlimitRoutes",
722
+ });
723
+ Logger({ level: "WARN", message: res_error });
724
+ }
725
+
726
+ return response;
496
727
  }
497
728
  }
498
729
  module.exports = Payment;