@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,9 @@ const Paginator = require("../../common/Paginator");
2
2
  const { FDKClientValidationError } = require("../../common/FDKError");
3
3
  const PlatformAPIClient = require("../PlatformAPIClient");
4
4
  const LeadValidator = require("./LeadPlatformValidator");
5
+ const LeadModel = require("./LeadPlatformModel");
6
+ const { Logger } = require("./../../common/Logger");
7
+
5
8
  class Lead {
6
9
  constructor(config) {
7
10
  this.config = config;
@@ -21,10 +24,11 @@ class Lead {
21
24
  * given set of results.
22
25
  * @param {number} [arg.pageSize] - Number of items to retrieve in each
23
26
  * page. Default is 12.
27
+ * @returns {Promise<TicketList>} - Success response
24
28
  * @summary: Gets the list of company level tickets and/or ticket filters depending on query params
25
29
  * @description: Gets the list of company level tickets and/or ticket filters
26
30
  */
27
- getTickets({
31
+ async getTickets({
28
32
  items,
29
33
  filters,
30
34
  q,
@@ -66,8 +70,11 @@ class Lead {
66
70
  { abortEarly: false, allowUnknown: false }
67
71
  );
68
72
  if (warrning) {
69
- console.log("Parameter Validation warrnings for getTickets");
70
- console.log(warrning);
73
+ Logger({
74
+ level: "WARN",
75
+ message: "Parameter Validation warrnings for getTickets",
76
+ });
77
+ Logger({ level: "WARN", message: warrning });
71
78
  }
72
79
 
73
80
  const query_params = {};
@@ -82,7 +89,7 @@ class Lead {
82
89
 
83
90
  const xHeaders = {};
84
91
 
85
- return PlatformAPIClient.execute(
92
+ const response = await PlatformAPIClient.execute(
86
93
  this.config,
87
94
  "get",
88
95
  `/service/platform/lead/v1.0/company/${this.config.companyId}/ticket`,
@@ -90,6 +97,21 @@ class Lead {
90
97
  undefined,
91
98
  xHeaders
92
99
  );
100
+
101
+ const { error: res_error } = LeadModel.TicketList().validate(response, {
102
+ abortEarly: false,
103
+ allowUnknown: false,
104
+ });
105
+
106
+ if (res_error) {
107
+ Logger({
108
+ level: "WARN",
109
+ message: "Response Validation Warnnings for getTickets",
110
+ });
111
+ Logger({ level: "WARN", message: res_error });
112
+ }
113
+
114
+ return response;
93
115
  }
94
116
 
95
117
  /**
@@ -144,10 +166,11 @@ class Lead {
144
166
  /**
145
167
  * @param {Object} arg - Arg object.
146
168
  * @param {AddTicketPayload} arg.body
169
+ * @returns {Promise<Ticket>} - Success response
147
170
  * @summary: Creates a company level ticket
148
171
  * @description: Creates a company level ticket
149
172
  */
150
- createTicket({ body } = {}) {
173
+ async createTicket({ body } = {}) {
151
174
  const { error } = LeadValidator.createTicket().validate(
152
175
  {
153
176
  body,
@@ -166,15 +189,18 @@ class Lead {
166
189
  { abortEarly: false, allowUnknown: false }
167
190
  );
168
191
  if (warrning) {
169
- console.log("Parameter Validation warrnings for createTicket");
170
- console.log(warrning);
192
+ Logger({
193
+ level: "WARN",
194
+ message: "Parameter Validation warrnings for createTicket",
195
+ });
196
+ Logger({ level: "WARN", message: warrning });
171
197
  }
172
198
 
173
199
  const query_params = {};
174
200
 
175
201
  const xHeaders = {};
176
202
 
177
- return PlatformAPIClient.execute(
203
+ const response = await PlatformAPIClient.execute(
178
204
  this.config,
179
205
  "post",
180
206
  `/service/platform/lead/v1.0/company/${this.config.companyId}/ticket`,
@@ -182,15 +208,31 @@ class Lead {
182
208
  body,
183
209
  xHeaders
184
210
  );
211
+
212
+ const { error: res_error } = LeadModel.Ticket().validate(response, {
213
+ abortEarly: false,
214
+ allowUnknown: false,
215
+ });
216
+
217
+ if (res_error) {
218
+ Logger({
219
+ level: "WARN",
220
+ message: "Response Validation Warnnings for createTicket",
221
+ });
222
+ Logger({ level: "WARN", message: res_error });
223
+ }
224
+
225
+ return response;
185
226
  }
186
227
 
187
228
  /**
188
229
  * @param {Object} arg - Arg object.
189
230
  * @param {string} arg.id - Tiket ID of the ticket to be fetched
231
+ * @returns {Promise<Ticket>} - Success response
190
232
  * @summary: Retreives ticket details of a company level ticket with ticket ID
191
233
  * @description: Retreives ticket details of a company level ticket
192
234
  */
193
- getTicket({ id } = {}) {
235
+ async getTicket({ id } = {}) {
194
236
  const { error } = LeadValidator.getTicket().validate(
195
237
  {
196
238
  id,
@@ -209,15 +251,18 @@ class Lead {
209
251
  { abortEarly: false, allowUnknown: false }
210
252
  );
211
253
  if (warrning) {
212
- console.log("Parameter Validation warrnings for getTicket");
213
- console.log(warrning);
254
+ Logger({
255
+ level: "WARN",
256
+ message: "Parameter Validation warrnings for getTicket",
257
+ });
258
+ Logger({ level: "WARN", message: warrning });
214
259
  }
215
260
 
216
261
  const query_params = {};
217
262
 
218
263
  const xHeaders = {};
219
264
 
220
- return PlatformAPIClient.execute(
265
+ const response = await PlatformAPIClient.execute(
221
266
  this.config,
222
267
  "get",
223
268
  `/service/platform/lead/v1.0/company/${this.config.companyId}/ticket/${id}`,
@@ -225,16 +270,32 @@ class Lead {
225
270
  undefined,
226
271
  xHeaders
227
272
  );
273
+
274
+ const { error: res_error } = LeadModel.Ticket().validate(response, {
275
+ abortEarly: false,
276
+ allowUnknown: false,
277
+ });
278
+
279
+ if (res_error) {
280
+ Logger({
281
+ level: "WARN",
282
+ message: "Response Validation Warnnings for getTicket",
283
+ });
284
+ Logger({ level: "WARN", message: res_error });
285
+ }
286
+
287
+ return response;
228
288
  }
229
289
 
230
290
  /**
231
291
  * @param {Object} arg - Arg object.
232
292
  * @param {string} arg.id - Ticket ID of ticket to be edited
233
293
  * @param {EditTicketPayload} arg.body
294
+ * @returns {Promise<Ticket>} - Success response
234
295
  * @summary: Edits ticket details of a company level ticket
235
296
  * @description: Edits ticket details of a company level ticket such as status, priority, category, tags, attachments, assigne & ticket content changes
236
297
  */
237
- editTicket({ id, body } = {}) {
298
+ async editTicket({ id, body } = {}) {
238
299
  const { error } = LeadValidator.editTicket().validate(
239
300
  {
240
301
  id,
@@ -255,15 +316,18 @@ class Lead {
255
316
  { abortEarly: false, allowUnknown: false }
256
317
  );
257
318
  if (warrning) {
258
- console.log("Parameter Validation warrnings for editTicket");
259
- console.log(warrning);
319
+ Logger({
320
+ level: "WARN",
321
+ message: "Parameter Validation warrnings for editTicket",
322
+ });
323
+ Logger({ level: "WARN", message: warrning });
260
324
  }
261
325
 
262
326
  const query_params = {};
263
327
 
264
328
  const xHeaders = {};
265
329
 
266
- return PlatformAPIClient.execute(
330
+ const response = await PlatformAPIClient.execute(
267
331
  this.config,
268
332
  "put",
269
333
  `/service/platform/lead/v1.0/company/${this.config.companyId}/ticket/${id}`,
@@ -271,16 +335,32 @@ class Lead {
271
335
  body,
272
336
  xHeaders
273
337
  );
338
+
339
+ const { error: res_error } = LeadModel.Ticket().validate(response, {
340
+ abortEarly: false,
341
+ allowUnknown: false,
342
+ });
343
+
344
+ if (res_error) {
345
+ Logger({
346
+ level: "WARN",
347
+ message: "Response Validation Warnnings for editTicket",
348
+ });
349
+ Logger({ level: "WARN", message: res_error });
350
+ }
351
+
352
+ return response;
274
353
  }
275
354
 
276
355
  /**
277
356
  * @param {Object} arg - Arg object.
278
357
  * @param {string} arg.id - Ticket ID for which history is created
279
358
  * @param {TicketHistoryPayload} arg.body
359
+ * @returns {Promise<TicketHistory>} - Success response
280
360
  * @summary: Create history for specific company level ticket
281
361
  * @description: Create history for specific company level ticket, this history is seen on ticket detail page, this can be comment, log or rating.
282
362
  */
283
- createHistory({ id, body } = {}) {
363
+ async createHistory({ id, body } = {}) {
284
364
  const { error } = LeadValidator.createHistory().validate(
285
365
  {
286
366
  id,
@@ -301,15 +381,18 @@ class Lead {
301
381
  { abortEarly: false, allowUnknown: false }
302
382
  );
303
383
  if (warrning) {
304
- console.log("Parameter Validation warrnings for createHistory");
305
- console.log(warrning);
384
+ Logger({
385
+ level: "WARN",
386
+ message: "Parameter Validation warrnings for createHistory",
387
+ });
388
+ Logger({ level: "WARN", message: warrning });
306
389
  }
307
390
 
308
391
  const query_params = {};
309
392
 
310
393
  const xHeaders = {};
311
394
 
312
- return PlatformAPIClient.execute(
395
+ const response = await PlatformAPIClient.execute(
313
396
  this.config,
314
397
  "post",
315
398
  `/service/platform/lead/v1.0/company/${this.config.companyId}/ticket/${id}/history`,
@@ -317,15 +400,31 @@ class Lead {
317
400
  body,
318
401
  xHeaders
319
402
  );
403
+
404
+ const { error: res_error } = LeadModel.TicketHistory().validate(response, {
405
+ abortEarly: false,
406
+ allowUnknown: false,
407
+ });
408
+
409
+ if (res_error) {
410
+ Logger({
411
+ level: "WARN",
412
+ message: "Response Validation Warnnings for createHistory",
413
+ });
414
+ Logger({ level: "WARN", message: res_error });
415
+ }
416
+
417
+ return response;
320
418
  }
321
419
 
322
420
  /**
323
421
  * @param {Object} arg - Arg object.
324
422
  * @param {string} arg.id - Ticket ID for which history is to be fetched
423
+ * @returns {Promise<TicketHistoryList>} - Success response
325
424
  * @summary: Gets history list for specific company level ticket
326
425
  * @description: Gets history list for specific company level ticket, this history is seen on ticket detail page, this can be comment, log or rating.
327
426
  */
328
- getTicketHistory({ id } = {}) {
427
+ async getTicketHistory({ id } = {}) {
329
428
  const { error } = LeadValidator.getTicketHistory().validate(
330
429
  {
331
430
  id,
@@ -344,15 +443,18 @@ class Lead {
344
443
  { abortEarly: false, allowUnknown: false }
345
444
  );
346
445
  if (warrning) {
347
- console.log("Parameter Validation warrnings for getTicketHistory");
348
- console.log(warrning);
446
+ Logger({
447
+ level: "WARN",
448
+ message: "Parameter Validation warrnings for getTicketHistory",
449
+ });
450
+ Logger({ level: "WARN", message: warrning });
349
451
  }
350
452
 
351
453
  const query_params = {};
352
454
 
353
455
  const xHeaders = {};
354
456
 
355
- return PlatformAPIClient.execute(
457
+ const response = await PlatformAPIClient.execute(
356
458
  this.config,
357
459
  "get",
358
460
  `/service/platform/lead/v1.0/company/${this.config.companyId}/ticket/${id}/history`,
@@ -360,15 +462,33 @@ class Lead {
360
462
  undefined,
361
463
  xHeaders
362
464
  );
465
+
466
+ const {
467
+ error: res_error,
468
+ } = LeadModel.TicketHistoryList().validate(response, {
469
+ abortEarly: false,
470
+ allowUnknown: false,
471
+ });
472
+
473
+ if (res_error) {
474
+ Logger({
475
+ level: "WARN",
476
+ message: "Response Validation Warnnings for getTicketHistory",
477
+ });
478
+ Logger({ level: "WARN", message: res_error });
479
+ }
480
+
481
+ return response;
363
482
  }
364
483
 
365
484
  /**
366
485
  * @param {Object} arg - Arg object.
367
486
  * @param {string} arg.id - Ticket ID for which feedbacks are to be fetched
487
+ * @returns {Promise<TicketFeedbackList>} - Success response
368
488
  * @summary: Gets a list of feedback submitted against that ticket
369
489
  * @description: Gets a list of feedback submitted against that ticket
370
490
  */
371
- getFeedbacks({ id } = {}) {
491
+ async getFeedbacks({ id } = {}) {
372
492
  const { error } = LeadValidator.getFeedbacks().validate(
373
493
  {
374
494
  id,
@@ -387,15 +507,18 @@ class Lead {
387
507
  { abortEarly: false, allowUnknown: false }
388
508
  );
389
509
  if (warrning) {
390
- console.log("Parameter Validation warrnings for getFeedbacks");
391
- console.log(warrning);
510
+ Logger({
511
+ level: "WARN",
512
+ message: "Parameter Validation warrnings for getFeedbacks",
513
+ });
514
+ Logger({ level: "WARN", message: warrning });
392
515
  }
393
516
 
394
517
  const query_params = {};
395
518
 
396
519
  const xHeaders = {};
397
520
 
398
- return PlatformAPIClient.execute(
521
+ const response = await PlatformAPIClient.execute(
399
522
  this.config,
400
523
  "get",
401
524
  `/service/platform/lead/v1.0/company/${this.config.companyId}/ticket/${id}/feedback`,
@@ -403,16 +526,34 @@ class Lead {
403
526
  undefined,
404
527
  xHeaders
405
528
  );
529
+
530
+ const {
531
+ error: res_error,
532
+ } = LeadModel.TicketFeedbackList().validate(response, {
533
+ abortEarly: false,
534
+ allowUnknown: false,
535
+ });
536
+
537
+ if (res_error) {
538
+ Logger({
539
+ level: "WARN",
540
+ message: "Response Validation Warnnings for getFeedbacks",
541
+ });
542
+ Logger({ level: "WARN", message: res_error });
543
+ }
544
+
545
+ return response;
406
546
  }
407
547
 
408
548
  /**
409
549
  * @param {Object} arg - Arg object.
410
550
  * @param {string} arg.id - Ticket ID for which feedback is to be submitted
411
551
  * @param {TicketFeedbackPayload} arg.body
552
+ * @returns {Promise<TicketFeedback>} - Success response
412
553
  * @summary: Submit a response for feeback form against that ticket
413
554
  * @description: Submit a response for feeback form against that ticket
414
555
  */
415
- submitFeedback({ id, body } = {}) {
556
+ async submitFeedback({ id, body } = {}) {
416
557
  const { error } = LeadValidator.submitFeedback().validate(
417
558
  {
418
559
  id,
@@ -433,15 +574,18 @@ class Lead {
433
574
  { abortEarly: false, allowUnknown: false }
434
575
  );
435
576
  if (warrning) {
436
- console.log("Parameter Validation warrnings for submitFeedback");
437
- console.log(warrning);
577
+ Logger({
578
+ level: "WARN",
579
+ message: "Parameter Validation warrnings for submitFeedback",
580
+ });
581
+ Logger({ level: "WARN", message: warrning });
438
582
  }
439
583
 
440
584
  const query_params = {};
441
585
 
442
586
  const xHeaders = {};
443
587
 
444
- return PlatformAPIClient.execute(
588
+ const response = await PlatformAPIClient.execute(
445
589
  this.config,
446
590
  "post",
447
591
  `/service/platform/lead/v1.0/company/${this.config.companyId}/ticket/${id}/feedback`,
@@ -449,15 +593,31 @@ class Lead {
449
593
  body,
450
594
  xHeaders
451
595
  );
596
+
597
+ const { error: res_error } = LeadModel.TicketFeedback().validate(response, {
598
+ abortEarly: false,
599
+ allowUnknown: false,
600
+ });
601
+
602
+ if (res_error) {
603
+ Logger({
604
+ level: "WARN",
605
+ message: "Response Validation Warnnings for submitFeedback",
606
+ });
607
+ Logger({ level: "WARN", message: res_error });
608
+ }
609
+
610
+ return response;
452
611
  }
453
612
 
454
613
  /**
455
614
  * @param {Object} arg - Arg object.
456
615
  * @param {string} arg.uniqueName - Unique name of video room
616
+ * @returns {Promise<GetTokenForVideoRoomResponse>} - Success response
457
617
  * @summary: Get Token to join a specific Video Room using it's unqiue name
458
618
  * @description: Get Token to join a specific Video Room using it's unqiue name, this Token is your ticket to Room and also creates your identity there.
459
619
  */
460
- getTokenForVideoRoom({ uniqueName } = {}) {
620
+ async getTokenForVideoRoom({ uniqueName } = {}) {
461
621
  const { error } = LeadValidator.getTokenForVideoRoom().validate(
462
622
  {
463
623
  uniqueName,
@@ -476,15 +636,18 @@ class Lead {
476
636
  { abortEarly: false, allowUnknown: false }
477
637
  );
478
638
  if (warrning) {
479
- console.log("Parameter Validation warrnings for getTokenForVideoRoom");
480
- console.log(warrning);
639
+ Logger({
640
+ level: "WARN",
641
+ message: "Parameter Validation warrnings for getTokenForVideoRoom",
642
+ });
643
+ Logger({ level: "WARN", message: warrning });
481
644
  }
482
645
 
483
646
  const query_params = {};
484
647
 
485
648
  const xHeaders = {};
486
649
 
487
- return PlatformAPIClient.execute(
650
+ const response = await PlatformAPIClient.execute(
488
651
  this.config,
489
652
  "get",
490
653
  `/service/platform/lead/v1.0/company/${this.config.companyId}/video/room/${uniqueName}/token`,
@@ -492,15 +655,33 @@ class Lead {
492
655
  undefined,
493
656
  xHeaders
494
657
  );
658
+
659
+ const {
660
+ error: res_error,
661
+ } = LeadModel.GetTokenForVideoRoomResponse().validate(response, {
662
+ abortEarly: false,
663
+ allowUnknown: false,
664
+ });
665
+
666
+ if (res_error) {
667
+ Logger({
668
+ level: "WARN",
669
+ message: "Response Validation Warnnings for getTokenForVideoRoom",
670
+ });
671
+ Logger({ level: "WARN", message: res_error });
672
+ }
673
+
674
+ return response;
495
675
  }
496
676
 
497
677
  /**
498
678
  * @param {Object} arg - Arg object.
499
679
  * @param {string} arg.uniqueName - Unique name of Video Room
680
+ * @returns {Promise<GetParticipantsInsideVideoRoomResponse>} - Success response
500
681
  * @summary: Get participants of a specific Video Room using it's unique name
501
682
  * @description: Get participants of a specific Video Room using it's unique name, this can be used to check if people are already there in the room and also to show their names.
502
683
  */
503
- getVideoParticipants({ uniqueName } = {}) {
684
+ async getVideoParticipants({ uniqueName } = {}) {
504
685
  const { error } = LeadValidator.getVideoParticipants().validate(
505
686
  {
506
687
  uniqueName,
@@ -519,15 +700,18 @@ class Lead {
519
700
  { abortEarly: false, allowUnknown: false }
520
701
  );
521
702
  if (warrning) {
522
- console.log("Parameter Validation warrnings for getVideoParticipants");
523
- console.log(warrning);
703
+ Logger({
704
+ level: "WARN",
705
+ message: "Parameter Validation warrnings for getVideoParticipants",
706
+ });
707
+ Logger({ level: "WARN", message: warrning });
524
708
  }
525
709
 
526
710
  const query_params = {};
527
711
 
528
712
  const xHeaders = {};
529
713
 
530
- return PlatformAPIClient.execute(
714
+ const response = await PlatformAPIClient.execute(
531
715
  this.config,
532
716
  "get",
533
717
  `/service/platform/lead/v1.0/company/${this.config.companyId}/video/room/${uniqueName}/participants`,
@@ -535,14 +719,32 @@ class Lead {
535
719
  undefined,
536
720
  xHeaders
537
721
  );
722
+
723
+ const {
724
+ error: res_error,
725
+ } = LeadModel.GetParticipantsInsideVideoRoomResponse().validate(response, {
726
+ abortEarly: false,
727
+ allowUnknown: false,
728
+ });
729
+
730
+ if (res_error) {
731
+ Logger({
732
+ level: "WARN",
733
+ message: "Response Validation Warnnings for getVideoParticipants",
734
+ });
735
+ Logger({ level: "WARN", message: res_error });
736
+ }
737
+
738
+ return response;
538
739
  }
539
740
 
540
741
  /**
541
742
  * @param {Object} arg - Arg object.
743
+ * @returns {Promise<CloseVideoRoomResponse>} - Success response
542
744
  * @summary: Get general support configuration.
543
745
  * @description: Get general support configuration.
544
746
  */
545
- getGeneralConfig({} = {}) {
747
+ async getGeneralConfig({} = {}) {
546
748
  const { error } = LeadValidator.getGeneralConfig().validate(
547
749
  {},
548
750
  { abortEarly: false, allowUnknown: true }
@@ -557,15 +759,18 @@ class Lead {
557
759
  { abortEarly: false, allowUnknown: false }
558
760
  );
559
761
  if (warrning) {
560
- console.log("Parameter Validation warrnings for getGeneralConfig");
561
- console.log(warrning);
762
+ Logger({
763
+ level: "WARN",
764
+ message: "Parameter Validation warrnings for getGeneralConfig",
765
+ });
766
+ Logger({ level: "WARN", message: warrning });
562
767
  }
563
768
 
564
769
  const query_params = {};
565
770
 
566
771
  const xHeaders = {};
567
772
 
568
- return PlatformAPIClient.execute(
773
+ const response = await PlatformAPIClient.execute(
569
774
  this.config,
570
775
  "get",
571
776
  `/service/platform/lead/v1.0/company/${this.config.companyId}/general-config`,
@@ -573,6 +778,23 @@ class Lead {
573
778
  undefined,
574
779
  xHeaders
575
780
  );
781
+
782
+ const {
783
+ error: res_error,
784
+ } = LeadModel.CloseVideoRoomResponse().validate(response, {
785
+ abortEarly: false,
786
+ allowUnknown: false,
787
+ });
788
+
789
+ if (res_error) {
790
+ Logger({
791
+ level: "WARN",
792
+ message: "Response Validation Warnnings for getGeneralConfig",
793
+ });
794
+ Logger({ level: "WARN", message: res_error });
795
+ }
796
+
797
+ return response;
576
798
  }
577
799
  }
578
800
 
@@ -49,11 +49,11 @@ class OAuthClient {
49
49
  if (this.refreshToken && this.useAutoRenewTimer) {
50
50
  this.retryOAuthToken(token.expires_in);
51
51
  }
52
- Logger({ type: "INFO", message: "Token set." });
52
+ Logger({ level: "INFO", message: "Token set." });
53
53
  }
54
54
 
55
55
  retryOAuthToken(expires_in) {
56
- Logger({ type: "INFO", message: "Retrying OAuth Token..." });
56
+ Logger({ level: "INFO", message: "Retrying OAuth Token..." });
57
57
  if (this.retryOAuthTokenTimer) {
58
58
  clearTimeout(this.retryOAuthTokenTimer);
59
59
  }
@@ -65,7 +65,7 @@ class OAuthClient {
65
65
  }
66
66
 
67
67
  startAuthorization(options) {
68
- Logger({ type: "INFO", message: "Starting Authorization..." });
68
+ Logger({ level: "INFO", message: "Starting Authorization..." });
69
69
  let query = {
70
70
  client_id: this.config.apiKey,
71
71
  scope: options.scope.join(","),
@@ -86,7 +86,7 @@ class OAuthClient {
86
86
  signQuery: true,
87
87
  };
88
88
  signingOptions = sign(signingOptions);
89
- Logger({ type: "INFO", message: "Authorization successful.!" });
89
+ Logger({ level: "INFO", message: "Authorization successful.!" });
90
90
 
91
91
  return `${this.config.domain}${signingOptions.path}`;
92
92
  }
@@ -116,7 +116,7 @@ class OAuthClient {
116
116
 
117
117
  async renewAccessToken(isOfflineToken = false) {
118
118
  try {
119
- Logger({ type: "INFO", message: "Renewing Access token..." });
119
+ Logger({ level: "INFO", message: "Renewing Access token..." });
120
120
  let res;
121
121
  if (isOfflineToken) {
122
122
  let requestCacheKey = `${this.config.apiKey}:${this.config.companyId}`;
@@ -138,7 +138,7 @@ class OAuthClient {
138
138
  this.setToken(res);
139
139
  this.token_expires_at =
140
140
  new Date().getTime() + this.token_expires_in * 1000;
141
- Logger({ type: "INFO", message: "Done." });
141
+ Logger({ level: "INFO", message: "Done." });
142
142
  return res;
143
143
  } catch (error) {
144
144
  if (error.isAxiosError) {
@@ -149,7 +149,7 @@ class OAuthClient {
149
149
  }
150
150
 
151
151
  async getAccesstokenObj({ grant_type, refresh_token, code }) {
152
- Logger({ type: "INFO", message: "Processing Access token object..." });
152
+ Logger({ level: "INFO", message: "Processing Access token object..." });
153
153
  let reqData = {
154
154
  grant_type: grant_type,
155
155
  };
@@ -173,7 +173,7 @@ class OAuthClient {
173
173
  "Content-Type": "application/x-www-form-urlencoded",
174
174
  },
175
175
  };
176
- Logger({ type: "INFO", message: "Done." });
176
+ Logger({ level: "INFO", message: "Done." });
177
177
  return fdkAxios.request(rawRequest);
178
178
  }
179
179