@gofynd/fdk-client-javascript 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/documentation/application/CART.md +251 -251
  2. package/documentation/application/CATALOG.md +393 -393
  3. package/documentation/application/CONTENT.md +15 -1
  4. package/documentation/application/ORDER.md +268 -268
  5. package/documentation/application/PAYMENT.md +249 -249
  6. package/documentation/application/POSCART.md +297 -297
  7. package/documentation/platform/CART.md +499 -499
  8. package/documentation/platform/CATALOG.md +3497 -3097
  9. package/documentation/platform/COMPANYPROFILE.md +207 -207
  10. package/documentation/platform/CONTENT.md +123 -1
  11. package/documentation/platform/ORDER.md +1518 -1324
  12. package/documentation/platform/PARTNER.md +7 -7
  13. package/documentation/platform/PAYMENT.md +96 -96
  14. package/index.js +7 -1
  15. package/package.json +1 -1
  16. package/sdk/application/ApplicationConfig.js +1 -1
  17. package/sdk/application/Cart/CartApplicationClient.js +865 -52
  18. package/sdk/application/Cart/CartApplicationModel.d.ts +7 -7
  19. package/sdk/application/Cart/CartApplicationModel.js +335 -335
  20. package/sdk/application/Cart/CartApplicationValidator.js +1 -0
  21. package/sdk/application/Catalog/CatalogApplicationClient.d.ts +1 -1
  22. package/sdk/application/Catalog/CatalogApplicationClient.js +1034 -60
  23. package/sdk/application/Catalog/CatalogApplicationModel.d.ts +19 -19
  24. package/sdk/application/Catalog/CatalogApplicationModel.js +532 -532
  25. package/sdk/application/Catalog/CatalogApplicationValidator.js +1 -0
  26. package/sdk/application/Common/CommonApplicationClient.js +66 -4
  27. package/sdk/application/Common/CommonApplicationValidator.js +1 -0
  28. package/sdk/application/Communication/CommunicationApplicationClient.js +108 -6
  29. package/sdk/application/Communication/CommunicationApplicationValidator.js +1 -0
  30. package/sdk/application/Configuration/ConfigurationApplicationClient.d.ts +1 -1
  31. package/sdk/application/Configuration/ConfigurationApplicationClient.js +558 -32
  32. package/sdk/application/Configuration/ConfigurationApplicationValidator.js +1 -0
  33. package/sdk/application/Content/ContentApplicationClient.js +621 -38
  34. package/sdk/application/Content/ContentApplicationModel.d.ts +1 -0
  35. package/sdk/application/Content/ContentApplicationModel.js +11 -1
  36. package/sdk/application/Content/ContentApplicationValidator.js +1 -0
  37. package/sdk/application/FileStorage/FileStorageApplicationClient.js +101 -6
  38. package/sdk/application/FileStorage/FileStorageApplicationValidator.js +1 -0
  39. package/sdk/application/Lead/LeadApplicationClient.js +229 -14
  40. package/sdk/application/Lead/LeadApplicationValidator.js +1 -0
  41. package/sdk/application/Logistic/LogisticApplicationClient.js +134 -8
  42. package/sdk/application/Logistic/LogisticApplicationValidator.js +1 -0
  43. package/sdk/application/Order/OrderApplicationClient.d.ts +1 -1
  44. package/sdk/application/Order/OrderApplicationClient.js +403 -24
  45. package/sdk/application/Order/OrderApplicationModel.d.ts +20 -20
  46. package/sdk/application/Order/OrderApplicationModel.js +334 -334
  47. package/sdk/application/Order/OrderApplicationValidator.js +1 -0
  48. package/sdk/application/Payment/PaymentApplicationClient.js +1381 -78
  49. package/sdk/application/Payment/PaymentApplicationModel.d.ts +2 -2
  50. package/sdk/application/Payment/PaymentApplicationModel.js +350 -350
  51. package/sdk/application/Payment/PaymentApplicationValidator.js +1 -0
  52. package/sdk/application/PosCart/PosCartApplicationClient.js +914 -54
  53. package/sdk/application/PosCart/PosCartApplicationModel.d.ts +15 -15
  54. package/sdk/application/PosCart/PosCartApplicationModel.js +389 -389
  55. package/sdk/application/PosCart/PosCartApplicationValidator.js +1 -0
  56. package/sdk/application/Rewards/RewardsApplicationClient.js +235 -14
  57. package/sdk/application/Rewards/RewardsApplicationValidator.js +1 -0
  58. package/sdk/application/Share/ShareApplicationClient.js +226 -14
  59. package/sdk/application/Share/ShareApplicationValidator.js +1 -0
  60. package/sdk/application/Theme/ThemeApplicationClient.js +130 -8
  61. package/sdk/application/Theme/ThemeApplicationValidator.js +1 -0
  62. package/sdk/application/User/UserApplicationClient.js +1133 -70
  63. package/sdk/application/User/UserApplicationValidator.js +1 -0
  64. package/sdk/common/AxiosHelper.js +1 -1
  65. package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.d.ts +16 -8
  66. package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.js +287 -16
  67. package/sdk/platform/Analytics/AnalyticsPlatformClient.d.ts +8 -4
  68. package/sdk/platform/Analytics/AnalyticsPlatformClient.js +153 -8
  69. package/sdk/platform/AuditTrail/AuditTrailPlatformClient.d.ts +8 -4
  70. package/sdk/platform/AuditTrail/AuditTrailPlatformClient.js +141 -8
  71. package/sdk/platform/Billing/BillingPlatformClient.d.ts +24 -12
  72. package/sdk/platform/Billing/BillingPlatformClient.js +429 -24
  73. package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +34 -17
  74. package/sdk/platform/Cart/CartPlatformApplicationClient.js +617 -34
  75. package/sdk/platform/Cart/CartPlatformModel.d.ts +35 -35
  76. package/sdk/platform/Cart/CartPlatformModel.js +617 -617
  77. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.d.ts +191 -138
  78. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.js +2202 -302
  79. package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.d.ts +11 -11
  80. package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.js +45 -45
  81. package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +344 -226
  82. package/sdk/platform/Catalog/CatalogPlatformClient.js +3282 -488
  83. package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +110 -100
  84. package/sdk/platform/Catalog/CatalogPlatformModel.js +2073 -1795
  85. package/sdk/platform/Catalog/CatalogPlatformValidator.d.ts +23 -21
  86. package/sdk/platform/Catalog/CatalogPlatformValidator.js +103 -84
  87. package/sdk/platform/Common/CommonPlatformClient.d.ts +4 -2
  88. package/sdk/platform/Common/CommonPlatformClient.js +73 -4
  89. package/sdk/platform/Communication/CommunicationPlatformApplicationClient.d.ts +80 -40
  90. package/sdk/platform/Communication/CommunicationPlatformApplicationClient.js +1499 -80
  91. package/sdk/platform/Communication/CommunicationPlatformClient.d.ts +2 -1
  92. package/sdk/platform/Communication/CommunicationPlatformClient.js +41 -2
  93. package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.d.ts +27 -14
  94. package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.js +486 -26
  95. package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.d.ts +9 -9
  96. package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.js +274 -274
  97. package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.d.ts +56 -28
  98. package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.js +1022 -56
  99. package/sdk/platform/Configuration/ConfigurationPlatformClient.d.ts +36 -18
  100. package/sdk/platform/Configuration/ConfigurationPlatformClient.js +693 -36
  101. package/sdk/platform/Content/ContentPlatformApplicationClient.d.ts +148 -67
  102. package/sdk/platform/Content/ContentPlatformApplicationClient.js +2446 -140
  103. package/sdk/platform/Content/ContentPlatformApplicationValidator.d.ts +1 -0
  104. package/sdk/platform/Content/ContentPlatformApplicationValidator.js +7 -0
  105. package/sdk/platform/Content/ContentPlatformModel.d.ts +4 -0
  106. package/sdk/platform/Content/ContentPlatformModel.js +43 -1
  107. package/sdk/platform/Discount/DiscountPlatformClient.d.ts +21 -10
  108. package/sdk/platform/Discount/DiscountPlatformClient.js +400 -22
  109. package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.d.ts +8 -4
  110. package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.js +148 -8
  111. package/sdk/platform/FileStorage/FileStoragePlatformClient.d.ts +12 -6
  112. package/sdk/platform/FileStorage/FileStoragePlatformClient.js +214 -12
  113. package/sdk/platform/Inventory/InventoryPlatformClient.d.ts +27 -14
  114. package/sdk/platform/Inventory/InventoryPlatformClient.js +449 -24
  115. package/sdk/platform/Lead/LeadPlatformApplicationClient.d.ts +26 -13
  116. package/sdk/platform/Lead/LeadPlatformApplicationClient.js +447 -26
  117. package/sdk/platform/Lead/LeadPlatformClient.d.ts +22 -11
  118. package/sdk/platform/Lead/LeadPlatformClient.js +384 -22
  119. package/sdk/platform/OAuthClient.js +8 -8
  120. package/sdk/platform/Order/OrderPlatformApplicationClient.d.ts +6 -3
  121. package/sdk/platform/Order/OrderPlatformApplicationClient.js +125 -6
  122. package/sdk/platform/Order/OrderPlatformClient.d.ts +108 -47
  123. package/sdk/platform/Order/OrderPlatformClient.js +1641 -100
  124. package/sdk/platform/Order/OrderPlatformModel.d.ts +69 -58
  125. package/sdk/platform/Order/OrderPlatformModel.js +1485 -1493
  126. package/sdk/platform/Order/OrderPlatformValidator.d.ts +2 -1
  127. package/sdk/platform/Order/OrderPlatformValidator.js +15 -4
  128. package/sdk/platform/Partner/PartnerPlatformApplicationClient.d.ts +4 -2
  129. package/sdk/platform/Partner/PartnerPlatformApplicationClient.js +74 -4
  130. package/sdk/platform/Partner/PartnerPlatformModel.d.ts +1 -1
  131. package/sdk/platform/Partner/PartnerPlatformModel.js +8 -8
  132. package/sdk/platform/Payment/PaymentPlatformApplicationClient.d.ts +22 -11
  133. package/sdk/platform/Payment/PaymentPlatformApplicationClient.js +418 -22
  134. package/sdk/platform/Payment/PaymentPlatformClient.d.ts +21 -11
  135. package/sdk/platform/Payment/PaymentPlatformClient.js +374 -20
  136. package/sdk/platform/Payment/PaymentPlatformModel.js +139 -139
  137. package/sdk/platform/PlatformApplicationClient.d.ts +2973 -2827
  138. package/sdk/platform/PlatformApplicationClient.js +3461 -3263
  139. package/sdk/platform/PlatformClient.d.ts +2973 -2827
  140. package/sdk/platform/PlatformClient.js +3461 -3263
  141. package/sdk/platform/Rewards/RewardsPlatformApplicationClient.d.ts +26 -13
  142. package/sdk/platform/Rewards/RewardsPlatformApplicationClient.js +449 -26
  143. package/sdk/platform/Share/SharePlatformApplicationClient.d.ts +8 -4
  144. package/sdk/platform/Share/SharePlatformApplicationClient.js +139 -8
  145. package/sdk/platform/Theme/ThemePlatformApplicationClient.d.ts +47 -23
  146. package/sdk/platform/Theme/ThemePlatformApplicationClient.js +816 -48
  147. package/sdk/platform/User/UserPlatformApplicationClient.d.ts +24 -12
  148. package/sdk/platform/User/UserPlatformApplicationClient.js +417 -24
  149. package/sdk/platform/Webhook/WebhookPlatformClient.d.ts +12 -6
  150. package/sdk/platform/Webhook/WebhookPlatformClient.js +229 -12
  151. package/sdk/public/Configuration/ConfigurationPublicClient.js +72 -4
  152. package/sdk/public/Configuration/ConfigurationPublicValidator.js +3 -1
  153. package/sdk/public/Inventory/InventoryPublicClient.js +210 -12
  154. package/sdk/public/Inventory/InventoryPublicValidator.js +3 -1
  155. package/sdk/public/Webhook/WebhookPublicClient.js +74 -4
  156. package/sdk/public/Webhook/WebhookPublicValidator.js +3 -1
@@ -2,6 +2,8 @@ const Paginator = require("../../common/Paginator");
2
2
  const PlatformAPIClient = require("../PlatformAPIClient");
3
3
  const { FDKClientValidationError } = require("../../common/FDKError");
4
4
  const 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,
@@ -38,6 +41,26 @@ class Lead {
38
41
  return Promise.reject(new FDKClientValidationError(error));
39
42
  }
40
43
 
44
+ // Showing warrnings if extra unknown parameters are found
45
+ const { error: warrning } = LeadValidator.getTickets().validate(
46
+ {
47
+ items,
48
+ filters,
49
+ q,
50
+ status,
51
+ priority,
52
+ category,
53
+ },
54
+ { abortEarly: false, allowUnknown: false }
55
+ );
56
+ if (warrning) {
57
+ Logger({
58
+ level: "WARN",
59
+ message: "Parameter Validation warrnings for getTickets",
60
+ });
61
+ Logger({ level: "WARN", message: warrning });
62
+ }
63
+
41
64
  const query_params = {};
42
65
  query_params["items"] = items;
43
66
  query_params["filters"] = filters;
@@ -46,22 +69,38 @@ class Lead {
46
69
  query_params["priority"] = priority;
47
70
  query_params["category"] = category;
48
71
 
49
- return PlatformAPIClient.execute(
72
+ const response = await PlatformAPIClient.execute(
50
73
  this.config,
51
74
  "get",
52
75
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/ticket`,
53
76
  query_params,
54
77
  undefined
55
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;
56
94
  }
57
95
 
58
96
  /**
59
97
  * @param {Object} arg - Arg object.
60
98
  * @param {string} arg.id - Tiket ID of the ticket to be fetched
99
+ * @returns {Promise<Ticket>} - Success response
61
100
  * @summary: Retreives ticket details of a application level ticket
62
101
  * @description: Retreives ticket details of a application level ticket with ticket ID
63
102
  */
64
- getTicket({ id } = {}) {
103
+ async getTicket({ id } = {}) {
65
104
  const { error } = LeadValidator.getTicket().validate(
66
105
  {
67
106
  id,
@@ -72,25 +111,56 @@ class Lead {
72
111
  return Promise.reject(new FDKClientValidationError(error));
73
112
  }
74
113
 
114
+ // Showing warrnings if extra unknown parameters are found
115
+ const { error: warrning } = LeadValidator.getTicket().validate(
116
+ {
117
+ id,
118
+ },
119
+ { abortEarly: false, allowUnknown: false }
120
+ );
121
+ if (warrning) {
122
+ Logger({
123
+ level: "WARN",
124
+ message: "Parameter Validation warrnings for getTicket",
125
+ });
126
+ Logger({ level: "WARN", message: warrning });
127
+ }
128
+
75
129
  const query_params = {};
76
130
 
77
- return PlatformAPIClient.execute(
131
+ const response = await PlatformAPIClient.execute(
78
132
  this.config,
79
133
  "get",
80
134
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/ticket/${id}`,
81
135
  query_params,
82
136
  undefined
83
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;
84
153
  }
85
154
 
86
155
  /**
87
156
  * @param {Object} arg - Arg object.
88
157
  * @param {string} arg.id - Ticket ID of ticket to be edited
89
158
  * @param {EditTicketPayload} arg.body
159
+ * @returns {Promise<Ticket>} - Success response
90
160
  * @summary: Edits ticket details of a application level ticket
91
161
  * @description: Edits ticket details of a application level ticket such as status, priority, category, tags, attachments, assigne & ticket content changes
92
162
  */
93
- editTicket({ id, body } = {}) {
163
+ async editTicket({ id, body } = {}) {
94
164
  const { error } = LeadValidator.editTicket().validate(
95
165
  {
96
166
  id,
@@ -102,25 +172,57 @@ class Lead {
102
172
  return Promise.reject(new FDKClientValidationError(error));
103
173
  }
104
174
 
175
+ // Showing warrnings if extra unknown parameters are found
176
+ const { error: warrning } = LeadValidator.editTicket().validate(
177
+ {
178
+ id,
179
+ body,
180
+ },
181
+ { abortEarly: false, allowUnknown: false }
182
+ );
183
+ if (warrning) {
184
+ Logger({
185
+ level: "WARN",
186
+ message: "Parameter Validation warrnings for editTicket",
187
+ });
188
+ Logger({ level: "WARN", message: warrning });
189
+ }
190
+
105
191
  const query_params = {};
106
192
 
107
- return PlatformAPIClient.execute(
193
+ const response = await PlatformAPIClient.execute(
108
194
  this.config,
109
195
  "put",
110
196
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/ticket/${id}`,
111
197
  query_params,
112
198
  body
113
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;
114
215
  }
115
216
 
116
217
  /**
117
218
  * @param {Object} arg - Arg object.
118
219
  * @param {string} arg.id - Ticket ID for which history is created
119
220
  * @param {TicketHistoryPayload} arg.body
221
+ * @returns {Promise<TicketHistory>} - Success response
120
222
  * @summary: Create history for specific application level ticket
121
223
  * @description: Create history for specific application level ticket, this history is seen on ticket detail page, this can be comment, log or rating.
122
224
  */
123
- createHistory({ id, body } = {}) {
225
+ async createHistory({ id, body } = {}) {
124
226
  const { error } = LeadValidator.createHistory().validate(
125
227
  {
126
228
  id,
@@ -132,24 +234,56 @@ class Lead {
132
234
  return Promise.reject(new FDKClientValidationError(error));
133
235
  }
134
236
 
237
+ // Showing warrnings if extra unknown parameters are found
238
+ const { error: warrning } = LeadValidator.createHistory().validate(
239
+ {
240
+ id,
241
+ body,
242
+ },
243
+ { abortEarly: false, allowUnknown: false }
244
+ );
245
+ if (warrning) {
246
+ Logger({
247
+ level: "WARN",
248
+ message: "Parameter Validation warrnings for createHistory",
249
+ });
250
+ Logger({ level: "WARN", message: warrning });
251
+ }
252
+
135
253
  const query_params = {};
136
254
 
137
- return PlatformAPIClient.execute(
255
+ const response = await PlatformAPIClient.execute(
138
256
  this.config,
139
257
  "post",
140
258
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/ticket/${id}/history`,
141
259
  query_params,
142
260
  body
143
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;
144
277
  }
145
278
 
146
279
  /**
147
280
  * @param {Object} arg - Arg object.
148
281
  * @param {string} arg.id - Ticket ID for which history is to be fetched
282
+ * @returns {Promise<TicketHistoryList>} - Success response
149
283
  * @summary: Gets history list for specific application level ticket
150
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.
151
285
  */
152
- getTicketHistory({ id } = {}) {
286
+ async getTicketHistory({ id } = {}) {
153
287
  const { error } = LeadValidator.getTicketHistory().validate(
154
288
  {
155
289
  id,
@@ -160,24 +294,57 @@ class Lead {
160
294
  return Promise.reject(new FDKClientValidationError(error));
161
295
  }
162
296
 
297
+ // Showing warrnings if extra unknown parameters are found
298
+ const { error: warrning } = LeadValidator.getTicketHistory().validate(
299
+ {
300
+ id,
301
+ },
302
+ { abortEarly: false, allowUnknown: false }
303
+ );
304
+ if (warrning) {
305
+ Logger({
306
+ level: "WARN",
307
+ message: "Parameter Validation warrnings for getTicketHistory",
308
+ });
309
+ Logger({ level: "WARN", message: warrning });
310
+ }
311
+
163
312
  const query_params = {};
164
313
 
165
- return PlatformAPIClient.execute(
314
+ const response = await PlatformAPIClient.execute(
166
315
  this.config,
167
316
  "get",
168
317
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/ticket/${id}/history`,
169
318
  query_params,
170
319
  undefined
171
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;
172
338
  }
173
339
 
174
340
  /**
175
341
  * @param {Object} arg - Arg object.
176
342
  * @param {string} arg.slug - Slug of form whose response is getting submitted
343
+ * @returns {Promise<CustomForm>} - Success response
177
344
  * @summary: Get specific custom form using it's slug
178
345
  * @description: Get specific custom form using it's slug, this is used to view the form.
179
346
  */
180
- getCustomForm({ slug } = {}) {
347
+ async getCustomForm({ slug } = {}) {
181
348
  const { error } = LeadValidator.getCustomForm().validate(
182
349
  {
183
350
  slug,
@@ -188,25 +355,56 @@ class Lead {
188
355
  return Promise.reject(new FDKClientValidationError(error));
189
356
  }
190
357
 
358
+ // Showing warrnings if extra unknown parameters are found
359
+ const { error: warrning } = LeadValidator.getCustomForm().validate(
360
+ {
361
+ slug,
362
+ },
363
+ { abortEarly: false, allowUnknown: false }
364
+ );
365
+ if (warrning) {
366
+ Logger({
367
+ level: "WARN",
368
+ message: "Parameter Validation warrnings for getCustomForm",
369
+ });
370
+ Logger({ level: "WARN", message: warrning });
371
+ }
372
+
191
373
  const query_params = {};
192
374
 
193
- return PlatformAPIClient.execute(
375
+ const response = await PlatformAPIClient.execute(
194
376
  this.config,
195
377
  "get",
196
378
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/form/${slug}`,
197
379
  query_params,
198
380
  undefined
199
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;
200
397
  }
201
398
 
202
399
  /**
203
400
  * @param {Object} arg - Arg object.
204
401
  * @param {string} arg.slug - Slug of form whose response is getting submitted
205
402
  * @param {EditCustomFormPayload} arg.body
403
+ * @returns {Promise<CustomForm>} - Success response
206
404
  * @summary: Edit the given custom form
207
405
  * @description: Edit the given custom form field such as adding or deleting input, assignee, title, decription, notification and polling information.
208
406
  */
209
- editCustomForm({ slug, body } = {}) {
407
+ async editCustomForm({ slug, body } = {}) {
210
408
  const { error } = LeadValidator.editCustomForm().validate(
211
409
  {
212
410
  slug,
@@ -218,23 +416,55 @@ class Lead {
218
416
  return Promise.reject(new FDKClientValidationError(error));
219
417
  }
220
418
 
419
+ // Showing warrnings if extra unknown parameters are found
420
+ const { error: warrning } = LeadValidator.editCustomForm().validate(
421
+ {
422
+ slug,
423
+ body,
424
+ },
425
+ { abortEarly: false, allowUnknown: false }
426
+ );
427
+ if (warrning) {
428
+ Logger({
429
+ level: "WARN",
430
+ message: "Parameter Validation warrnings for editCustomForm",
431
+ });
432
+ Logger({ level: "WARN", message: warrning });
433
+ }
434
+
221
435
  const query_params = {};
222
436
 
223
- return PlatformAPIClient.execute(
437
+ const response = await PlatformAPIClient.execute(
224
438
  this.config,
225
439
  "put",
226
440
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/form/${slug}`,
227
441
  query_params,
228
442
  body
229
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;
230
459
  }
231
460
 
232
461
  /**
233
462
  * @param {Object} arg - Arg object.
463
+ * @returns {Promise<CustomFormList>} - Success response
234
464
  * @summary: Get list of custom form
235
465
  * @description: Get list of custom form for given application
236
466
  */
237
- getCustomForms({} = {}) {
467
+ async getCustomForms({} = {}) {
238
468
  const { error } = LeadValidator.getCustomForms().validate(
239
469
  {},
240
470
  { abortEarly: false, allowUnknown: true }
@@ -243,24 +473,53 @@ class Lead {
243
473
  return Promise.reject(new FDKClientValidationError(error));
244
474
  }
245
475
 
476
+ // Showing warrnings if extra unknown parameters are found
477
+ const { error: warrning } = LeadValidator.getCustomForms().validate(
478
+ {},
479
+ { abortEarly: false, allowUnknown: false }
480
+ );
481
+ if (warrning) {
482
+ Logger({
483
+ level: "WARN",
484
+ message: "Parameter Validation warrnings for getCustomForms",
485
+ });
486
+ Logger({ level: "WARN", message: warrning });
487
+ }
488
+
246
489
  const query_params = {};
247
490
 
248
- return PlatformAPIClient.execute(
491
+ const response = await PlatformAPIClient.execute(
249
492
  this.config,
250
493
  "get",
251
494
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/form`,
252
495
  query_params,
253
496
  undefined
254
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;
255
513
  }
256
514
 
257
515
  /**
258
516
  * @param {Object} arg - Arg object.
259
517
  * @param {CreateCustomFormPayload} arg.body
518
+ * @returns {Promise<CustomForm>} - Success response
260
519
  * @summary: Creates a new custom form
261
520
  * @description: Creates a new custom form for given application
262
521
  */
263
- createCustomForm({ body } = {}) {
522
+ async createCustomForm({ body } = {}) {
264
523
  const { error } = LeadValidator.createCustomForm().validate(
265
524
  {
266
525
  body,
@@ -271,24 +530,55 @@ class Lead {
271
530
  return Promise.reject(new FDKClientValidationError(error));
272
531
  }
273
532
 
533
+ // Showing warrnings if extra unknown parameters are found
534
+ const { error: warrning } = LeadValidator.createCustomForm().validate(
535
+ {
536
+ body,
537
+ },
538
+ { abortEarly: false, allowUnknown: false }
539
+ );
540
+ if (warrning) {
541
+ Logger({
542
+ level: "WARN",
543
+ message: "Parameter Validation warrnings for createCustomForm",
544
+ });
545
+ Logger({ level: "WARN", message: warrning });
546
+ }
547
+
274
548
  const query_params = {};
275
549
 
276
- return PlatformAPIClient.execute(
550
+ const response = await PlatformAPIClient.execute(
277
551
  this.config,
278
552
  "post",
279
553
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/form`,
280
554
  query_params,
281
555
  body
282
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;
283
572
  }
284
573
 
285
574
  /**
286
575
  * @param {Object} arg - Arg object.
287
576
  * @param {string} arg.uniqueName - Unique name of video room
577
+ * @returns {Promise<GetTokenForVideoRoomResponse>} - Success response
288
578
  * @summary: Get Token to join a specific Video Room using it's unqiue name
289
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.
290
580
  */
291
- getTokenForVideoRoom({ uniqueName } = {}) {
581
+ async getTokenForVideoRoom({ uniqueName } = {}) {
292
582
  const { error } = LeadValidator.getTokenForVideoRoom().validate(
293
583
  {
294
584
  uniqueName,
@@ -299,24 +589,57 @@ class Lead {
299
589
  return Promise.reject(new FDKClientValidationError(error));
300
590
  }
301
591
 
592
+ // Showing warrnings if extra unknown parameters are found
593
+ const { error: warrning } = LeadValidator.getTokenForVideoRoom().validate(
594
+ {
595
+ uniqueName,
596
+ },
597
+ { abortEarly: false, allowUnknown: false }
598
+ );
599
+ if (warrning) {
600
+ Logger({
601
+ level: "WARN",
602
+ message: "Parameter Validation warrnings for getTokenForVideoRoom",
603
+ });
604
+ Logger({ level: "WARN", message: warrning });
605
+ }
606
+
302
607
  const query_params = {};
303
608
 
304
- return PlatformAPIClient.execute(
609
+ const response = await PlatformAPIClient.execute(
305
610
  this.config,
306
611
  "get",
307
612
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/video/room/${uniqueName}/token`,
308
613
  query_params,
309
614
  undefined
310
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;
311
633
  }
312
634
 
313
635
  /**
314
636
  * @param {Object} arg - Arg object.
315
637
  * @param {string} arg.uniqueName - Unique name of Video Room
638
+ * @returns {Promise<GetParticipantsInsideVideoRoomResponse>} - Success response
316
639
  * @summary: Get participants of a specific Video Room using it's unique name
317
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.
318
641
  */
319
- getVideoParticipants({ uniqueName } = {}) {
642
+ async getVideoParticipants({ uniqueName } = {}) {
320
643
  const { error } = LeadValidator.getVideoParticipants().validate(
321
644
  {
322
645
  uniqueName,
@@ -327,24 +650,57 @@ class Lead {
327
650
  return Promise.reject(new FDKClientValidationError(error));
328
651
  }
329
652
 
653
+ // Showing warrnings if extra unknown parameters are found
654
+ const { error: warrning } = LeadValidator.getVideoParticipants().validate(
655
+ {
656
+ uniqueName,
657
+ },
658
+ { abortEarly: false, allowUnknown: false }
659
+ );
660
+ if (warrning) {
661
+ Logger({
662
+ level: "WARN",
663
+ message: "Parameter Validation warrnings for getVideoParticipants",
664
+ });
665
+ Logger({ level: "WARN", message: warrning });
666
+ }
667
+
330
668
  const query_params = {};
331
669
 
332
- return PlatformAPIClient.execute(
670
+ const response = await PlatformAPIClient.execute(
333
671
  this.config,
334
672
  "get",
335
673
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/video/room/${uniqueName}/participants`,
336
674
  query_params,
337
675
  undefined
338
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;
339
694
  }
340
695
 
341
696
  /**
342
697
  * @param {Object} arg - Arg object.
343
698
  * @param {CreateVideoRoomPayload} arg.body
699
+ * @returns {Promise<CreateVideoRoomResponse>} - Success response
344
700
  * @summary: Open a video room.
345
701
  * @description: Open a video room.
346
702
  */
347
- openVideoRoom({ body } = {}) {
703
+ async openVideoRoom({ body } = {}) {
348
704
  const { error } = LeadValidator.openVideoRoom().validate(
349
705
  {
350
706
  body,
@@ -355,24 +711,57 @@ class Lead {
355
711
  return Promise.reject(new FDKClientValidationError(error));
356
712
  }
357
713
 
714
+ // Showing warrnings if extra unknown parameters are found
715
+ const { error: warrning } = LeadValidator.openVideoRoom().validate(
716
+ {
717
+ body,
718
+ },
719
+ { abortEarly: false, allowUnknown: false }
720
+ );
721
+ if (warrning) {
722
+ Logger({
723
+ level: "WARN",
724
+ message: "Parameter Validation warrnings for openVideoRoom",
725
+ });
726
+ Logger({ level: "WARN", message: warrning });
727
+ }
728
+
358
729
  const query_params = {};
359
730
 
360
- return PlatformAPIClient.execute(
731
+ const response = await PlatformAPIClient.execute(
361
732
  this.config,
362
733
  "post",
363
734
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/video/room`,
364
735
  query_params,
365
736
  body
366
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;
367
755
  }
368
756
 
369
757
  /**
370
758
  * @param {Object} arg - Arg object.
371
759
  * @param {string} arg.uniqueName - Unique name of Video Room
760
+ * @returns {Promise<CloseVideoRoomResponse>} - Success response
372
761
  * @summary: Close the video room and force all participants to leave.
373
762
  * @description: Close the video room and force all participants to leave.
374
763
  */
375
- closeVideoRoom({ uniqueName } = {}) {
764
+ async closeVideoRoom({ uniqueName } = {}) {
376
765
  const { error } = LeadValidator.closeVideoRoom().validate(
377
766
  {
378
767
  uniqueName,
@@ -383,15 +772,47 @@ class Lead {
383
772
  return Promise.reject(new FDKClientValidationError(error));
384
773
  }
385
774
 
775
+ // Showing warrnings if extra unknown parameters are found
776
+ const { error: warrning } = LeadValidator.closeVideoRoom().validate(
777
+ {
778
+ uniqueName,
779
+ },
780
+ { abortEarly: false, allowUnknown: false }
781
+ );
782
+ if (warrning) {
783
+ Logger({
784
+ level: "WARN",
785
+ message: "Parameter Validation warrnings for closeVideoRoom",
786
+ });
787
+ Logger({ level: "WARN", message: warrning });
788
+ }
789
+
386
790
  const query_params = {};
387
791
 
388
- return PlatformAPIClient.execute(
792
+ const response = await PlatformAPIClient.execute(
389
793
  this.config,
390
794
  "delete",
391
795
  `/service/platform/lead/v1.0/company/${this.config.companyId}/application/${this.applicationId}/video/room/${uniqueName}`,
392
796
  query_params,
393
797
  undefined
394
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;
395
816
  }
396
817
  }
397
818
  module.exports = Lead;