@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 LeadValidator = require("./LeadPlatformApplicationValidator");
5
+ const LeadModel = require("./LeadPlatformModel");
6
+ const { Logger } = require("./../../common/Logger");
5
7
 
6
8
  class Lead {
7
9
  constructor(config, applicationId) {
@@ -19,10 +21,11 @@ class Lead {
19
21
  * @param {string} [arg.status] - Filter tickets on status
20
22
  * @param {PriorityEnum} [arg.priority] - Filter tickets on priority
21
23
  * @param {string} [arg.category] - Filter tickets on category
24
+ * @returns {Promise<TicketList>} - Success response
22
25
  * @summary: Gets the list of Application level Tickets and/or ticket filters depending on query params
23
26
  * @description: Gets the list of Application level Tickets and/or ticket filters
24
27
  */
25
- getTickets({ items, filters, q, status, priority, category } = {}) {
28
+ async getTickets({ items, filters, q, status, priority, category } = {}) {
26
29
  const { error } = LeadValidator.getTickets().validate(
27
30
  {
28
31
  items,
@@ -51,8 +54,11 @@ class Lead {
51
54
  { abortEarly: false, allowUnknown: false }
52
55
  );
53
56
  if (warrning) {
54
- console.log("Parameter Validation warrnings for getTickets");
55
- console.log(warrning);
57
+ Logger({
58
+ level: "WARN",
59
+ message: "Parameter Validation warrnings for getTickets",
60
+ });
61
+ Logger({ level: "WARN", message: warrning });
56
62
  }
57
63
 
58
64
  const query_params = {};
@@ -63,22 +69,38 @@ class Lead {
63
69
  query_params["priority"] = priority;
64
70
  query_params["category"] = category;
65
71
 
66
- return PlatformAPIClient.execute(
72
+ const response = await PlatformAPIClient.execute(
67
73
  this.config,
68
74
  "get",
69
75
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/ticket`,
70
76
  query_params,
71
77
  undefined
72
78
  );
79
+
80
+ const { error: res_error } = LeadModel.TicketList().validate(response, {
81
+ abortEarly: false,
82
+ allowUnknown: false,
83
+ });
84
+
85
+ if (res_error) {
86
+ Logger({
87
+ level: "WARN",
88
+ message: "Response Validation Warnnings for getTickets",
89
+ });
90
+ Logger({ level: "WARN", message: res_error });
91
+ }
92
+
93
+ return response;
73
94
  }
74
95
 
75
96
  /**
76
97
  * @param {Object} arg - Arg object.
77
98
  * @param {string} arg.id - Tiket ID of the ticket to be fetched
99
+ * @returns {Promise<Ticket>} - Success response
78
100
  * @summary: Retreives ticket details of a application level ticket
79
101
  * @description: Retreives ticket details of a application level ticket with ticket ID
80
102
  */
81
- getTicket({ id } = {}) {
103
+ async getTicket({ id } = {}) {
82
104
  const { error } = LeadValidator.getTicket().validate(
83
105
  {
84
106
  id,
@@ -97,29 +119,48 @@ class Lead {
97
119
  { abortEarly: false, allowUnknown: false }
98
120
  );
99
121
  if (warrning) {
100
- console.log("Parameter Validation warrnings for getTicket");
101
- console.log(warrning);
122
+ Logger({
123
+ level: "WARN",
124
+ message: "Parameter Validation warrnings for getTicket",
125
+ });
126
+ Logger({ level: "WARN", message: warrning });
102
127
  }
103
128
 
104
129
  const query_params = {};
105
130
 
106
- return PlatformAPIClient.execute(
131
+ const response = await PlatformAPIClient.execute(
107
132
  this.config,
108
133
  "get",
109
134
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/ticket/${id}`,
110
135
  query_params,
111
136
  undefined
112
137
  );
138
+
139
+ const { error: res_error } = LeadModel.Ticket().validate(response, {
140
+ abortEarly: false,
141
+ allowUnknown: false,
142
+ });
143
+
144
+ if (res_error) {
145
+ Logger({
146
+ level: "WARN",
147
+ message: "Response Validation Warnnings for getTicket",
148
+ });
149
+ Logger({ level: "WARN", message: res_error });
150
+ }
151
+
152
+ return response;
113
153
  }
114
154
 
115
155
  /**
116
156
  * @param {Object} arg - Arg object.
117
157
  * @param {string} arg.id - Ticket ID of ticket to be edited
118
158
  * @param {EditTicketPayload} arg.body
159
+ * @returns {Promise<Ticket>} - Success response
119
160
  * @summary: Edits ticket details of a application level ticket
120
161
  * @description: Edits ticket details of a application level ticket such as status, priority, category, tags, attachments, assigne & ticket content changes
121
162
  */
122
- editTicket({ id, body } = {}) {
163
+ async editTicket({ id, body } = {}) {
123
164
  const { error } = LeadValidator.editTicket().validate(
124
165
  {
125
166
  id,
@@ -140,29 +181,48 @@ class Lead {
140
181
  { abortEarly: false, allowUnknown: false }
141
182
  );
142
183
  if (warrning) {
143
- console.log("Parameter Validation warrnings for editTicket");
144
- console.log(warrning);
184
+ Logger({
185
+ level: "WARN",
186
+ message: "Parameter Validation warrnings for editTicket",
187
+ });
188
+ Logger({ level: "WARN", message: warrning });
145
189
  }
146
190
 
147
191
  const query_params = {};
148
192
 
149
- return PlatformAPIClient.execute(
193
+ const response = await PlatformAPIClient.execute(
150
194
  this.config,
151
195
  "put",
152
196
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/ticket/${id}`,
153
197
  query_params,
154
198
  body
155
199
  );
200
+
201
+ const { error: res_error } = LeadModel.Ticket().validate(response, {
202
+ abortEarly: false,
203
+ allowUnknown: false,
204
+ });
205
+
206
+ if (res_error) {
207
+ Logger({
208
+ level: "WARN",
209
+ message: "Response Validation Warnnings for editTicket",
210
+ });
211
+ Logger({ level: "WARN", message: res_error });
212
+ }
213
+
214
+ return response;
156
215
  }
157
216
 
158
217
  /**
159
218
  * @param {Object} arg - Arg object.
160
219
  * @param {string} arg.id - Ticket ID for which history is created
161
220
  * @param {TicketHistoryPayload} arg.body
221
+ * @returns {Promise<TicketHistory>} - Success response
162
222
  * @summary: Create history for specific application level ticket
163
223
  * @description: Create history for specific application level ticket, this history is seen on ticket detail page, this can be comment, log or rating.
164
224
  */
165
- createHistory({ id, body } = {}) {
225
+ async createHistory({ id, body } = {}) {
166
226
  const { error } = LeadValidator.createHistory().validate(
167
227
  {
168
228
  id,
@@ -183,28 +243,47 @@ class Lead {
183
243
  { abortEarly: false, allowUnknown: false }
184
244
  );
185
245
  if (warrning) {
186
- console.log("Parameter Validation warrnings for createHistory");
187
- console.log(warrning);
246
+ Logger({
247
+ level: "WARN",
248
+ message: "Parameter Validation warrnings for createHistory",
249
+ });
250
+ Logger({ level: "WARN", message: warrning });
188
251
  }
189
252
 
190
253
  const query_params = {};
191
254
 
192
- return PlatformAPIClient.execute(
255
+ const response = await PlatformAPIClient.execute(
193
256
  this.config,
194
257
  "post",
195
258
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/ticket/${id}/history`,
196
259
  query_params,
197
260
  body
198
261
  );
262
+
263
+ const { error: res_error } = LeadModel.TicketHistory().validate(response, {
264
+ abortEarly: false,
265
+ allowUnknown: false,
266
+ });
267
+
268
+ if (res_error) {
269
+ Logger({
270
+ level: "WARN",
271
+ message: "Response Validation Warnnings for createHistory",
272
+ });
273
+ Logger({ level: "WARN", message: res_error });
274
+ }
275
+
276
+ return response;
199
277
  }
200
278
 
201
279
  /**
202
280
  * @param {Object} arg - Arg object.
203
281
  * @param {string} arg.id - Ticket ID for which history is to be fetched
282
+ * @returns {Promise<TicketHistoryList>} - Success response
204
283
  * @summary: Gets history list for specific application level ticket
205
284
  * @description: Gets history list for specific application level ticket, this history is seen on ticket detail page, this can be comment, log or rating.
206
285
  */
207
- getTicketHistory({ id } = {}) {
286
+ async getTicketHistory({ id } = {}) {
208
287
  const { error } = LeadValidator.getTicketHistory().validate(
209
288
  {
210
289
  id,
@@ -223,28 +302,49 @@ class Lead {
223
302
  { abortEarly: false, allowUnknown: false }
224
303
  );
225
304
  if (warrning) {
226
- console.log("Parameter Validation warrnings for getTicketHistory");
227
- console.log(warrning);
305
+ Logger({
306
+ level: "WARN",
307
+ message: "Parameter Validation warrnings for getTicketHistory",
308
+ });
309
+ Logger({ level: "WARN", message: warrning });
228
310
  }
229
311
 
230
312
  const query_params = {};
231
313
 
232
- return PlatformAPIClient.execute(
314
+ const response = await PlatformAPIClient.execute(
233
315
  this.config,
234
316
  "get",
235
317
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/ticket/${id}/history`,
236
318
  query_params,
237
319
  undefined
238
320
  );
321
+
322
+ const {
323
+ error: res_error,
324
+ } = LeadModel.TicketHistoryList().validate(response, {
325
+ abortEarly: false,
326
+ allowUnknown: false,
327
+ });
328
+
329
+ if (res_error) {
330
+ Logger({
331
+ level: "WARN",
332
+ message: "Response Validation Warnnings for getTicketHistory",
333
+ });
334
+ Logger({ level: "WARN", message: res_error });
335
+ }
336
+
337
+ return response;
239
338
  }
240
339
 
241
340
  /**
242
341
  * @param {Object} arg - Arg object.
243
342
  * @param {string} arg.slug - Slug of form whose response is getting submitted
343
+ * @returns {Promise<CustomForm>} - Success response
244
344
  * @summary: Get specific custom form using it's slug
245
345
  * @description: Get specific custom form using it's slug, this is used to view the form.
246
346
  */
247
- getCustomForm({ slug } = {}) {
347
+ async getCustomForm({ slug } = {}) {
248
348
  const { error } = LeadValidator.getCustomForm().validate(
249
349
  {
250
350
  slug,
@@ -263,29 +363,48 @@ class Lead {
263
363
  { abortEarly: false, allowUnknown: false }
264
364
  );
265
365
  if (warrning) {
266
- console.log("Parameter Validation warrnings for getCustomForm");
267
- console.log(warrning);
366
+ Logger({
367
+ level: "WARN",
368
+ message: "Parameter Validation warrnings for getCustomForm",
369
+ });
370
+ Logger({ level: "WARN", message: warrning });
268
371
  }
269
372
 
270
373
  const query_params = {};
271
374
 
272
- return PlatformAPIClient.execute(
375
+ const response = await PlatformAPIClient.execute(
273
376
  this.config,
274
377
  "get",
275
378
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/form/${slug}`,
276
379
  query_params,
277
380
  undefined
278
381
  );
382
+
383
+ const { error: res_error } = LeadModel.CustomForm().validate(response, {
384
+ abortEarly: false,
385
+ allowUnknown: false,
386
+ });
387
+
388
+ if (res_error) {
389
+ Logger({
390
+ level: "WARN",
391
+ message: "Response Validation Warnnings for getCustomForm",
392
+ });
393
+ Logger({ level: "WARN", message: res_error });
394
+ }
395
+
396
+ return response;
279
397
  }
280
398
 
281
399
  /**
282
400
  * @param {Object} arg - Arg object.
283
401
  * @param {string} arg.slug - Slug of form whose response is getting submitted
284
402
  * @param {EditCustomFormPayload} arg.body
403
+ * @returns {Promise<CustomForm>} - Success response
285
404
  * @summary: Edit the given custom form
286
405
  * @description: Edit the given custom form field such as adding or deleting input, assignee, title, decription, notification and polling information.
287
406
  */
288
- editCustomForm({ slug, body } = {}) {
407
+ async editCustomForm({ slug, body } = {}) {
289
408
  const { error } = LeadValidator.editCustomForm().validate(
290
409
  {
291
410
  slug,
@@ -306,27 +425,46 @@ class Lead {
306
425
  { abortEarly: false, allowUnknown: false }
307
426
  );
308
427
  if (warrning) {
309
- console.log("Parameter Validation warrnings for editCustomForm");
310
- console.log(warrning);
428
+ Logger({
429
+ level: "WARN",
430
+ message: "Parameter Validation warrnings for editCustomForm",
431
+ });
432
+ Logger({ level: "WARN", message: warrning });
311
433
  }
312
434
 
313
435
  const query_params = {};
314
436
 
315
- return PlatformAPIClient.execute(
437
+ const response = await PlatformAPIClient.execute(
316
438
  this.config,
317
439
  "put",
318
440
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/form/${slug}`,
319
441
  query_params,
320
442
  body
321
443
  );
444
+
445
+ const { error: res_error } = LeadModel.CustomForm().validate(response, {
446
+ abortEarly: false,
447
+ allowUnknown: false,
448
+ });
449
+
450
+ if (res_error) {
451
+ Logger({
452
+ level: "WARN",
453
+ message: "Response Validation Warnnings for editCustomForm",
454
+ });
455
+ Logger({ level: "WARN", message: res_error });
456
+ }
457
+
458
+ return response;
322
459
  }
323
460
 
324
461
  /**
325
462
  * @param {Object} arg - Arg object.
463
+ * @returns {Promise<CustomFormList>} - Success response
326
464
  * @summary: Get list of custom form
327
465
  * @description: Get list of custom form for given application
328
466
  */
329
- getCustomForms({} = {}) {
467
+ async getCustomForms({} = {}) {
330
468
  const { error } = LeadValidator.getCustomForms().validate(
331
469
  {},
332
470
  { abortEarly: false, allowUnknown: true }
@@ -341,28 +479,47 @@ class Lead {
341
479
  { abortEarly: false, allowUnknown: false }
342
480
  );
343
481
  if (warrning) {
344
- console.log("Parameter Validation warrnings for getCustomForms");
345
- console.log(warrning);
482
+ Logger({
483
+ level: "WARN",
484
+ message: "Parameter Validation warrnings for getCustomForms",
485
+ });
486
+ Logger({ level: "WARN", message: warrning });
346
487
  }
347
488
 
348
489
  const query_params = {};
349
490
 
350
- return PlatformAPIClient.execute(
491
+ const response = await PlatformAPIClient.execute(
351
492
  this.config,
352
493
  "get",
353
494
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/form`,
354
495
  query_params,
355
496
  undefined
356
497
  );
498
+
499
+ const { error: res_error } = LeadModel.CustomFormList().validate(response, {
500
+ abortEarly: false,
501
+ allowUnknown: false,
502
+ });
503
+
504
+ if (res_error) {
505
+ Logger({
506
+ level: "WARN",
507
+ message: "Response Validation Warnnings for getCustomForms",
508
+ });
509
+ Logger({ level: "WARN", message: res_error });
510
+ }
511
+
512
+ return response;
357
513
  }
358
514
 
359
515
  /**
360
516
  * @param {Object} arg - Arg object.
361
517
  * @param {CreateCustomFormPayload} arg.body
518
+ * @returns {Promise<CustomForm>} - Success response
362
519
  * @summary: Creates a new custom form
363
520
  * @description: Creates a new custom form for given application
364
521
  */
365
- createCustomForm({ body } = {}) {
522
+ async createCustomForm({ body } = {}) {
366
523
  const { error } = LeadValidator.createCustomForm().validate(
367
524
  {
368
525
  body,
@@ -381,28 +538,47 @@ class Lead {
381
538
  { abortEarly: false, allowUnknown: false }
382
539
  );
383
540
  if (warrning) {
384
- console.log("Parameter Validation warrnings for createCustomForm");
385
- console.log(warrning);
541
+ Logger({
542
+ level: "WARN",
543
+ message: "Parameter Validation warrnings for createCustomForm",
544
+ });
545
+ Logger({ level: "WARN", message: warrning });
386
546
  }
387
547
 
388
548
  const query_params = {};
389
549
 
390
- return PlatformAPIClient.execute(
550
+ const response = await PlatformAPIClient.execute(
391
551
  this.config,
392
552
  "post",
393
553
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/form`,
394
554
  query_params,
395
555
  body
396
556
  );
557
+
558
+ const { error: res_error } = LeadModel.CustomForm().validate(response, {
559
+ abortEarly: false,
560
+ allowUnknown: false,
561
+ });
562
+
563
+ if (res_error) {
564
+ Logger({
565
+ level: "WARN",
566
+ message: "Response Validation Warnnings for createCustomForm",
567
+ });
568
+ Logger({ level: "WARN", message: res_error });
569
+ }
570
+
571
+ return response;
397
572
  }
398
573
 
399
574
  /**
400
575
  * @param {Object} arg - Arg object.
401
576
  * @param {string} arg.uniqueName - Unique name of video room
577
+ * @returns {Promise<GetTokenForVideoRoomResponse>} - Success response
402
578
  * @summary: Get Token to join a specific Video Room using it's unqiue name
403
579
  * @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.
404
580
  */
405
- getTokenForVideoRoom({ uniqueName } = {}) {
581
+ async getTokenForVideoRoom({ uniqueName } = {}) {
406
582
  const { error } = LeadValidator.getTokenForVideoRoom().validate(
407
583
  {
408
584
  uniqueName,
@@ -421,28 +597,49 @@ class Lead {
421
597
  { abortEarly: false, allowUnknown: false }
422
598
  );
423
599
  if (warrning) {
424
- console.log("Parameter Validation warrnings for getTokenForVideoRoom");
425
- console.log(warrning);
600
+ Logger({
601
+ level: "WARN",
602
+ message: "Parameter Validation warrnings for getTokenForVideoRoom",
603
+ });
604
+ Logger({ level: "WARN", message: warrning });
426
605
  }
427
606
 
428
607
  const query_params = {};
429
608
 
430
- return PlatformAPIClient.execute(
609
+ const response = await PlatformAPIClient.execute(
431
610
  this.config,
432
611
  "get",
433
612
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/video/room/${uniqueName}/token`,
434
613
  query_params,
435
614
  undefined
436
615
  );
616
+
617
+ const {
618
+ error: res_error,
619
+ } = LeadModel.GetTokenForVideoRoomResponse().validate(response, {
620
+ abortEarly: false,
621
+ allowUnknown: false,
622
+ });
623
+
624
+ if (res_error) {
625
+ Logger({
626
+ level: "WARN",
627
+ message: "Response Validation Warnnings for getTokenForVideoRoom",
628
+ });
629
+ Logger({ level: "WARN", message: res_error });
630
+ }
631
+
632
+ return response;
437
633
  }
438
634
 
439
635
  /**
440
636
  * @param {Object} arg - Arg object.
441
637
  * @param {string} arg.uniqueName - Unique name of Video Room
638
+ * @returns {Promise<GetParticipantsInsideVideoRoomResponse>} - Success response
442
639
  * @summary: Get participants of a specific Video Room using it's unique name
443
640
  * @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.
444
641
  */
445
- getVideoParticipants({ uniqueName } = {}) {
642
+ async getVideoParticipants({ uniqueName } = {}) {
446
643
  const { error } = LeadValidator.getVideoParticipants().validate(
447
644
  {
448
645
  uniqueName,
@@ -461,28 +658,49 @@ class Lead {
461
658
  { abortEarly: false, allowUnknown: false }
462
659
  );
463
660
  if (warrning) {
464
- console.log("Parameter Validation warrnings for getVideoParticipants");
465
- console.log(warrning);
661
+ Logger({
662
+ level: "WARN",
663
+ message: "Parameter Validation warrnings for getVideoParticipants",
664
+ });
665
+ Logger({ level: "WARN", message: warrning });
466
666
  }
467
667
 
468
668
  const query_params = {};
469
669
 
470
- return PlatformAPIClient.execute(
670
+ const response = await PlatformAPIClient.execute(
471
671
  this.config,
472
672
  "get",
473
673
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/video/room/${uniqueName}/participants`,
474
674
  query_params,
475
675
  undefined
476
676
  );
677
+
678
+ const {
679
+ error: res_error,
680
+ } = LeadModel.GetParticipantsInsideVideoRoomResponse().validate(response, {
681
+ abortEarly: false,
682
+ allowUnknown: false,
683
+ });
684
+
685
+ if (res_error) {
686
+ Logger({
687
+ level: "WARN",
688
+ message: "Response Validation Warnnings for getVideoParticipants",
689
+ });
690
+ Logger({ level: "WARN", message: res_error });
691
+ }
692
+
693
+ return response;
477
694
  }
478
695
 
479
696
  /**
480
697
  * @param {Object} arg - Arg object.
481
698
  * @param {CreateVideoRoomPayload} arg.body
699
+ * @returns {Promise<CreateVideoRoomResponse>} - Success response
482
700
  * @summary: Open a video room.
483
701
  * @description: Open a video room.
484
702
  */
485
- openVideoRoom({ body } = {}) {
703
+ async openVideoRoom({ body } = {}) {
486
704
  const { error } = LeadValidator.openVideoRoom().validate(
487
705
  {
488
706
  body,
@@ -501,28 +719,49 @@ class Lead {
501
719
  { abortEarly: false, allowUnknown: false }
502
720
  );
503
721
  if (warrning) {
504
- console.log("Parameter Validation warrnings for openVideoRoom");
505
- console.log(warrning);
722
+ Logger({
723
+ level: "WARN",
724
+ message: "Parameter Validation warrnings for openVideoRoom",
725
+ });
726
+ Logger({ level: "WARN", message: warrning });
506
727
  }
507
728
 
508
729
  const query_params = {};
509
730
 
510
- return PlatformAPIClient.execute(
731
+ const response = await PlatformAPIClient.execute(
511
732
  this.config,
512
733
  "post",
513
734
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/video/room`,
514
735
  query_params,
515
736
  body
516
737
  );
738
+
739
+ const {
740
+ error: res_error,
741
+ } = LeadModel.CreateVideoRoomResponse().validate(response, {
742
+ abortEarly: false,
743
+ allowUnknown: false,
744
+ });
745
+
746
+ if (res_error) {
747
+ Logger({
748
+ level: "WARN",
749
+ message: "Response Validation Warnnings for openVideoRoom",
750
+ });
751
+ Logger({ level: "WARN", message: res_error });
752
+ }
753
+
754
+ return response;
517
755
  }
518
756
 
519
757
  /**
520
758
  * @param {Object} arg - Arg object.
521
759
  * @param {string} arg.uniqueName - Unique name of Video Room
760
+ * @returns {Promise<CloseVideoRoomResponse>} - Success response
522
761
  * @summary: Close the video room and force all participants to leave.
523
762
  * @description: Close the video room and force all participants to leave.
524
763
  */
525
- closeVideoRoom({ uniqueName } = {}) {
764
+ async closeVideoRoom({ uniqueName } = {}) {
526
765
  const { error } = LeadValidator.closeVideoRoom().validate(
527
766
  {
528
767
  uniqueName,
@@ -541,19 +780,39 @@ class Lead {
541
780
  { abortEarly: false, allowUnknown: false }
542
781
  );
543
782
  if (warrning) {
544
- console.log("Parameter Validation warrnings for closeVideoRoom");
545
- console.log(warrning);
783
+ Logger({
784
+ level: "WARN",
785
+ message: "Parameter Validation warrnings for closeVideoRoom",
786
+ });
787
+ Logger({ level: "WARN", message: warrning });
546
788
  }
547
789
 
548
790
  const query_params = {};
549
791
 
550
- return PlatformAPIClient.execute(
792
+ const response = await PlatformAPIClient.execute(
551
793
  this.config,
552
794
  "delete",
553
795
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/video/room/${uniqueName}`,
554
796
  query_params,
555
797
  undefined
556
798
  );
799
+
800
+ const {
801
+ error: res_error,
802
+ } = LeadModel.CloseVideoRoomResponse().validate(response, {
803
+ abortEarly: false,
804
+ allowUnknown: false,
805
+ });
806
+
807
+ if (res_error) {
808
+ Logger({
809
+ level: "WARN",
810
+ message: "Response Validation Warnnings for closeVideoRoom",
811
+ });
812
+ Logger({ level: "WARN", message: res_error });
813
+ }
814
+
815
+ return response;
557
816
  }
558
817
  }
559
818
  module.exports = Lead;