@gofynd/fdk-client-javascript 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/documentation/application/CART.md +251 -251
  2. package/documentation/application/CATALOG.md +393 -393
  3. package/documentation/application/CONTENT.md +15 -1
  4. package/documentation/application/ORDER.md +268 -268
  5. package/documentation/application/PAYMENT.md +249 -249
  6. package/documentation/application/POSCART.md +297 -297
  7. package/documentation/platform/CART.md +499 -499
  8. package/documentation/platform/CATALOG.md +3497 -3097
  9. package/documentation/platform/COMPANYPROFILE.md +207 -207
  10. package/documentation/platform/CONTENT.md +123 -1
  11. package/documentation/platform/ORDER.md +1518 -1324
  12. package/documentation/platform/PARTNER.md +7 -7
  13. package/documentation/platform/PAYMENT.md +96 -96
  14. package/index.js +7 -1
  15. package/package.json +1 -1
  16. package/sdk/application/ApplicationConfig.js +1 -1
  17. package/sdk/application/Cart/CartApplicationClient.js +865 -52
  18. package/sdk/application/Cart/CartApplicationModel.d.ts +7 -7
  19. package/sdk/application/Cart/CartApplicationModel.js +335 -335
  20. package/sdk/application/Cart/CartApplicationValidator.js +1 -0
  21. package/sdk/application/Catalog/CatalogApplicationClient.d.ts +1 -1
  22. package/sdk/application/Catalog/CatalogApplicationClient.js +1034 -60
  23. package/sdk/application/Catalog/CatalogApplicationModel.d.ts +19 -19
  24. package/sdk/application/Catalog/CatalogApplicationModel.js +532 -532
  25. package/sdk/application/Catalog/CatalogApplicationValidator.js +1 -0
  26. package/sdk/application/Common/CommonApplicationClient.js +66 -4
  27. package/sdk/application/Common/CommonApplicationValidator.js +1 -0
  28. package/sdk/application/Communication/CommunicationApplicationClient.js +108 -6
  29. package/sdk/application/Communication/CommunicationApplicationValidator.js +1 -0
  30. package/sdk/application/Configuration/ConfigurationApplicationClient.d.ts +1 -1
  31. package/sdk/application/Configuration/ConfigurationApplicationClient.js +558 -32
  32. package/sdk/application/Configuration/ConfigurationApplicationValidator.js +1 -0
  33. package/sdk/application/Content/ContentApplicationClient.js +621 -38
  34. package/sdk/application/Content/ContentApplicationModel.d.ts +1 -0
  35. package/sdk/application/Content/ContentApplicationModel.js +11 -1
  36. package/sdk/application/Content/ContentApplicationValidator.js +1 -0
  37. package/sdk/application/FileStorage/FileStorageApplicationClient.js +101 -6
  38. package/sdk/application/FileStorage/FileStorageApplicationValidator.js +1 -0
  39. package/sdk/application/Lead/LeadApplicationClient.js +229 -14
  40. package/sdk/application/Lead/LeadApplicationValidator.js +1 -0
  41. package/sdk/application/Logistic/LogisticApplicationClient.js +134 -8
  42. package/sdk/application/Logistic/LogisticApplicationValidator.js +1 -0
  43. package/sdk/application/Order/OrderApplicationClient.d.ts +1 -1
  44. package/sdk/application/Order/OrderApplicationClient.js +403 -24
  45. package/sdk/application/Order/OrderApplicationModel.d.ts +20 -20
  46. package/sdk/application/Order/OrderApplicationModel.js +334 -334
  47. package/sdk/application/Order/OrderApplicationValidator.js +1 -0
  48. package/sdk/application/Payment/PaymentApplicationClient.js +1381 -78
  49. package/sdk/application/Payment/PaymentApplicationModel.d.ts +2 -2
  50. package/sdk/application/Payment/PaymentApplicationModel.js +350 -350
  51. package/sdk/application/Payment/PaymentApplicationValidator.js +1 -0
  52. package/sdk/application/PosCart/PosCartApplicationClient.js +914 -54
  53. package/sdk/application/PosCart/PosCartApplicationModel.d.ts +15 -15
  54. package/sdk/application/PosCart/PosCartApplicationModel.js +389 -389
  55. package/sdk/application/PosCart/PosCartApplicationValidator.js +1 -0
  56. package/sdk/application/Rewards/RewardsApplicationClient.js +235 -14
  57. package/sdk/application/Rewards/RewardsApplicationValidator.js +1 -0
  58. package/sdk/application/Share/ShareApplicationClient.js +226 -14
  59. package/sdk/application/Share/ShareApplicationValidator.js +1 -0
  60. package/sdk/application/Theme/ThemeApplicationClient.js +130 -8
  61. package/sdk/application/Theme/ThemeApplicationValidator.js +1 -0
  62. package/sdk/application/User/UserApplicationClient.js +1133 -70
  63. package/sdk/application/User/UserApplicationValidator.js +1 -0
  64. package/sdk/common/AxiosHelper.js +1 -1
  65. package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.d.ts +16 -8
  66. package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.js +287 -16
  67. package/sdk/platform/Analytics/AnalyticsPlatformClient.d.ts +8 -4
  68. package/sdk/platform/Analytics/AnalyticsPlatformClient.js +153 -8
  69. package/sdk/platform/AuditTrail/AuditTrailPlatformClient.d.ts +8 -4
  70. package/sdk/platform/AuditTrail/AuditTrailPlatformClient.js +141 -8
  71. package/sdk/platform/Billing/BillingPlatformClient.d.ts +24 -12
  72. package/sdk/platform/Billing/BillingPlatformClient.js +429 -24
  73. package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +34 -17
  74. package/sdk/platform/Cart/CartPlatformApplicationClient.js +617 -34
  75. package/sdk/platform/Cart/CartPlatformModel.d.ts +35 -35
  76. package/sdk/platform/Cart/CartPlatformModel.js +617 -617
  77. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.d.ts +191 -138
  78. package/sdk/platform/Catalog/CatalogPlatformApplicationClient.js +2202 -302
  79. package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.d.ts +11 -11
  80. package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.js +45 -45
  81. package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +344 -226
  82. package/sdk/platform/Catalog/CatalogPlatformClient.js +3282 -488
  83. package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +110 -100
  84. package/sdk/platform/Catalog/CatalogPlatformModel.js +2073 -1795
  85. package/sdk/platform/Catalog/CatalogPlatformValidator.d.ts +23 -21
  86. package/sdk/platform/Catalog/CatalogPlatformValidator.js +103 -84
  87. package/sdk/platform/Common/CommonPlatformClient.d.ts +4 -2
  88. package/sdk/platform/Common/CommonPlatformClient.js +73 -4
  89. package/sdk/platform/Communication/CommunicationPlatformApplicationClient.d.ts +80 -40
  90. package/sdk/platform/Communication/CommunicationPlatformApplicationClient.js +1499 -80
  91. package/sdk/platform/Communication/CommunicationPlatformClient.d.ts +2 -1
  92. package/sdk/platform/Communication/CommunicationPlatformClient.js +41 -2
  93. package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.d.ts +27 -14
  94. package/sdk/platform/CompanyProfile/CompanyProfilePlatformClient.js +486 -26
  95. package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.d.ts +9 -9
  96. package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.js +274 -274
  97. package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.d.ts +56 -28
  98. package/sdk/platform/Configuration/ConfigurationPlatformApplicationClient.js +1022 -56
  99. package/sdk/platform/Configuration/ConfigurationPlatformClient.d.ts +36 -18
  100. package/sdk/platform/Configuration/ConfigurationPlatformClient.js +693 -36
  101. package/sdk/platform/Content/ContentPlatformApplicationClient.d.ts +148 -67
  102. package/sdk/platform/Content/ContentPlatformApplicationClient.js +2446 -140
  103. package/sdk/platform/Content/ContentPlatformApplicationValidator.d.ts +1 -0
  104. package/sdk/platform/Content/ContentPlatformApplicationValidator.js +7 -0
  105. package/sdk/platform/Content/ContentPlatformModel.d.ts +4 -0
  106. package/sdk/platform/Content/ContentPlatformModel.js +43 -1
  107. package/sdk/platform/Discount/DiscountPlatformClient.d.ts +21 -10
  108. package/sdk/platform/Discount/DiscountPlatformClient.js +400 -22
  109. package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.d.ts +8 -4
  110. package/sdk/platform/FileStorage/FileStoragePlatformApplicationClient.js +148 -8
  111. package/sdk/platform/FileStorage/FileStoragePlatformClient.d.ts +12 -6
  112. package/sdk/platform/FileStorage/FileStoragePlatformClient.js +214 -12
  113. package/sdk/platform/Inventory/InventoryPlatformClient.d.ts +27 -14
  114. package/sdk/platform/Inventory/InventoryPlatformClient.js +449 -24
  115. package/sdk/platform/Lead/LeadPlatformApplicationClient.d.ts +26 -13
  116. package/sdk/platform/Lead/LeadPlatformApplicationClient.js +447 -26
  117. package/sdk/platform/Lead/LeadPlatformClient.d.ts +22 -11
  118. package/sdk/platform/Lead/LeadPlatformClient.js +384 -22
  119. package/sdk/platform/OAuthClient.js +8 -8
  120. package/sdk/platform/Order/OrderPlatformApplicationClient.d.ts +6 -3
  121. package/sdk/platform/Order/OrderPlatformApplicationClient.js +125 -6
  122. package/sdk/platform/Order/OrderPlatformClient.d.ts +108 -47
  123. package/sdk/platform/Order/OrderPlatformClient.js +1641 -100
  124. package/sdk/platform/Order/OrderPlatformModel.d.ts +69 -58
  125. package/sdk/platform/Order/OrderPlatformModel.js +1485 -1493
  126. package/sdk/platform/Order/OrderPlatformValidator.d.ts +2 -1
  127. package/sdk/platform/Order/OrderPlatformValidator.js +15 -4
  128. package/sdk/platform/Partner/PartnerPlatformApplicationClient.d.ts +4 -2
  129. package/sdk/platform/Partner/PartnerPlatformApplicationClient.js +74 -4
  130. package/sdk/platform/Partner/PartnerPlatformModel.d.ts +1 -1
  131. package/sdk/platform/Partner/PartnerPlatformModel.js +8 -8
  132. package/sdk/platform/Payment/PaymentPlatformApplicationClient.d.ts +22 -11
  133. package/sdk/platform/Payment/PaymentPlatformApplicationClient.js +418 -22
  134. package/sdk/platform/Payment/PaymentPlatformClient.d.ts +21 -11
  135. package/sdk/platform/Payment/PaymentPlatformClient.js +374 -20
  136. package/sdk/platform/Payment/PaymentPlatformModel.js +139 -139
  137. package/sdk/platform/PlatformApplicationClient.d.ts +2973 -2827
  138. package/sdk/platform/PlatformApplicationClient.js +3461 -3263
  139. package/sdk/platform/PlatformClient.d.ts +2973 -2827
  140. package/sdk/platform/PlatformClient.js +3461 -3263
  141. package/sdk/platform/Rewards/RewardsPlatformApplicationClient.d.ts +26 -13
  142. package/sdk/platform/Rewards/RewardsPlatformApplicationClient.js +449 -26
  143. package/sdk/platform/Share/SharePlatformApplicationClient.d.ts +8 -4
  144. package/sdk/platform/Share/SharePlatformApplicationClient.js +139 -8
  145. package/sdk/platform/Theme/ThemePlatformApplicationClient.d.ts +47 -23
  146. package/sdk/platform/Theme/ThemePlatformApplicationClient.js +816 -48
  147. package/sdk/platform/User/UserPlatformApplicationClient.d.ts +24 -12
  148. package/sdk/platform/User/UserPlatformApplicationClient.js +417 -24
  149. package/sdk/platform/Webhook/WebhookPlatformClient.d.ts +12 -6
  150. package/sdk/platform/Webhook/WebhookPlatformClient.js +229 -12
  151. package/sdk/public/Configuration/ConfigurationPublicClient.js +72 -4
  152. package/sdk/public/Configuration/ConfigurationPublicValidator.js +3 -1
  153. package/sdk/public/Inventory/InventoryPublicClient.js +210 -12
  154. package/sdk/public/Inventory/InventoryPublicValidator.js +3 -1
  155. package/sdk/public/Webhook/WebhookPublicClient.js +74 -4
  156. package/sdk/public/Webhook/WebhookPublicValidator.js +3 -1
@@ -2,6 +2,9 @@ const Paginator = require("../../common/Paginator");
2
2
  const { FDKClientValidationError } = require("../../common/FDKError");
3
3
  const PlatformAPIClient = require("../PlatformAPIClient");
4
4
  const AnalyticsValidator = require("./AnalyticsPlatformValidator");
5
+ const AnalyticsModel = require("./AnalyticsPlatformModel");
6
+ const { Logger } = require("./../../common/Logger");
7
+
5
8
  class Analytics {
6
9
  constructor(config) {
7
10
  this.config = config;
@@ -11,10 +14,11 @@ class Analytics {
11
14
  * @param {Object} arg - Arg object.
12
15
  * @param {string} arg.exportType - Export type / format
13
16
  * @param {ExportJobReq} arg.body
17
+ * @returns {Promise<ExportJobRes>} - Success response
14
18
  * @summary: Create data export job in required format
15
19
  * @description: Create data export job in required format
16
20
  */
17
- createExportJob({ exportType, body } = {}) {
21
+ async createExportJob({ exportType, body } = {}) {
18
22
  const { error } = AnalyticsValidator.createExportJob().validate(
19
23
  {
20
24
  exportType,
@@ -26,11 +30,27 @@ class Analytics {
26
30
  return Promise.reject(new FDKClientValidationError(error));
27
31
  }
28
32
 
33
+ // Showing warrnings if extra unknown parameters are found
34
+ const { error: warrning } = AnalyticsValidator.createExportJob().validate(
35
+ {
36
+ exportType,
37
+ body,
38
+ },
39
+ { abortEarly: false, allowUnknown: false }
40
+ );
41
+ if (warrning) {
42
+ Logger({
43
+ level: "WARN",
44
+ message: "Parameter Validation warrnings for createExportJob",
45
+ });
46
+ Logger({ level: "WARN", message: warrning });
47
+ }
48
+
29
49
  const query_params = {};
30
50
 
31
51
  const xHeaders = {};
32
52
 
33
- return PlatformAPIClient.execute(
53
+ const response = await PlatformAPIClient.execute(
34
54
  this.config,
35
55
  "post",
36
56
  `/service/platform/analytics/v1.0/company/${this.config.companyId}/export/${exportType}`,
@@ -38,16 +58,34 @@ class Analytics {
38
58
  body,
39
59
  xHeaders
40
60
  );
61
+
62
+ const {
63
+ error: res_error,
64
+ } = AnalyticsModel.ExportJobRes().validate(response, {
65
+ abortEarly: false,
66
+ allowUnknown: false,
67
+ });
68
+
69
+ if (res_error) {
70
+ Logger({
71
+ level: "WARN",
72
+ message: "Response Validation Warnnings for createExportJob",
73
+ });
74
+ Logger({ level: "WARN", message: res_error });
75
+ }
76
+
77
+ return response;
41
78
  }
42
79
 
43
80
  /**
44
81
  * @param {Object} arg - Arg object.
45
82
  * @param {string} arg.exportType - Export type / format
46
83
  * @param {string} arg.jobId - Export job id
84
+ * @returns {Promise<ExportJobStatusRes>} - Success response
47
85
  * @summary: Get data export job status
48
86
  * @description: Get data export job status
49
87
  */
50
- getExportJobStatus({ exportType, jobId } = {}) {
88
+ async getExportJobStatus({ exportType, jobId } = {}) {
51
89
  const { error } = AnalyticsValidator.getExportJobStatus().validate(
52
90
  {
53
91
  exportType,
@@ -59,11 +97,29 @@ class Analytics {
59
97
  return Promise.reject(new FDKClientValidationError(error));
60
98
  }
61
99
 
100
+ // Showing warrnings if extra unknown parameters are found
101
+ const {
102
+ error: warrning,
103
+ } = AnalyticsValidator.getExportJobStatus().validate(
104
+ {
105
+ exportType,
106
+ jobId,
107
+ },
108
+ { abortEarly: false, allowUnknown: false }
109
+ );
110
+ if (warrning) {
111
+ Logger({
112
+ level: "WARN",
113
+ message: "Parameter Validation warrnings for getExportJobStatus",
114
+ });
115
+ Logger({ level: "WARN", message: warrning });
116
+ }
117
+
62
118
  const query_params = {};
63
119
 
64
120
  const xHeaders = {};
65
121
 
66
- return PlatformAPIClient.execute(
122
+ const response = await PlatformAPIClient.execute(
67
123
  this.config,
68
124
  "get",
69
125
  `/service/platform/analytics/v1.0/company/${this.config.companyId}/export/${exportType}/job/${jobId}`,
@@ -71,6 +127,23 @@ class Analytics {
71
127
  undefined,
72
128
  xHeaders
73
129
  );
130
+
131
+ const {
132
+ error: res_error,
133
+ } = AnalyticsModel.ExportJobStatusRes().validate(response, {
134
+ abortEarly: false,
135
+ allowUnknown: false,
136
+ });
137
+
138
+ if (res_error) {
139
+ Logger({
140
+ level: "WARN",
141
+ message: "Response Validation Warnnings for getExportJobStatus",
142
+ });
143
+ Logger({ level: "WARN", message: res_error });
144
+ }
145
+
146
+ return response;
74
147
  }
75
148
 
76
149
  /**
@@ -79,10 +152,11 @@ class Analytics {
79
152
  * @param {number} [arg.pageNo] - Current page number
80
153
  * @param {number} [arg.pageSize] - Current page size
81
154
  * @param {GetLogsListReq} arg.body
155
+ * @returns {Promise<GetLogsListRes>} - Success response
82
156
  * @summary: Get logs list
83
157
  * @description: Get logs list
84
158
  */
85
- getLogsList({ logType, body, pageNo, pageSize } = {}) {
159
+ async getLogsList({ logType, body, pageNo, pageSize } = {}) {
86
160
  const { error } = AnalyticsValidator.getLogsList().validate(
87
161
  {
88
162
  logType,
@@ -96,13 +170,31 @@ class Analytics {
96
170
  return Promise.reject(new FDKClientValidationError(error));
97
171
  }
98
172
 
173
+ // Showing warrnings if extra unknown parameters are found
174
+ const { error: warrning } = AnalyticsValidator.getLogsList().validate(
175
+ {
176
+ logType,
177
+ body,
178
+ pageNo,
179
+ pageSize,
180
+ },
181
+ { abortEarly: false, allowUnknown: false }
182
+ );
183
+ if (warrning) {
184
+ Logger({
185
+ level: "WARN",
186
+ message: "Parameter Validation warrnings for getLogsList",
187
+ });
188
+ Logger({ level: "WARN", message: warrning });
189
+ }
190
+
99
191
  const query_params = {};
100
192
  query_params["page_no"] = pageNo;
101
193
  query_params["page_size"] = pageSize;
102
194
 
103
195
  const xHeaders = {};
104
196
 
105
- return PlatformAPIClient.execute(
197
+ const response = await PlatformAPIClient.execute(
106
198
  this.config,
107
199
  "post",
108
200
  `/service/platform/analytics/v1.0/company/${this.config.companyId}/logs/${logType}`,
@@ -110,6 +202,23 @@ class Analytics {
110
202
  body,
111
203
  xHeaders
112
204
  );
205
+
206
+ const {
207
+ error: res_error,
208
+ } = AnalyticsModel.GetLogsListRes().validate(response, {
209
+ abortEarly: false,
210
+ allowUnknown: false,
211
+ });
212
+
213
+ if (res_error) {
214
+ Logger({
215
+ level: "WARN",
216
+ message: "Response Validation Warnnings for getLogsList",
217
+ });
218
+ Logger({ level: "WARN", message: res_error });
219
+ }
220
+
221
+ return response;
113
222
  }
114
223
 
115
224
  /**
@@ -148,10 +257,11 @@ class Analytics {
148
257
  * @param {number} [arg.pageSize] - Current page size
149
258
  * @param {string} arg.logType - Log type
150
259
  * @param {SearchLogReq} arg.body
260
+ * @returns {Promise<SearchLogRes>} - Success response
151
261
  * @summary: Search logs
152
262
  * @description: Search logs
153
263
  */
154
- searchLogs({ logType, body, pageNo, pageSize } = {}) {
264
+ async searchLogs({ logType, body, pageNo, pageSize } = {}) {
155
265
  const { error } = AnalyticsValidator.searchLogs().validate(
156
266
  {
157
267
  logType,
@@ -165,13 +275,31 @@ class Analytics {
165
275
  return Promise.reject(new FDKClientValidationError(error));
166
276
  }
167
277
 
278
+ // Showing warrnings if extra unknown parameters are found
279
+ const { error: warrning } = AnalyticsValidator.searchLogs().validate(
280
+ {
281
+ logType,
282
+ body,
283
+ pageNo,
284
+ pageSize,
285
+ },
286
+ { abortEarly: false, allowUnknown: false }
287
+ );
288
+ if (warrning) {
289
+ Logger({
290
+ level: "WARN",
291
+ message: "Parameter Validation warrnings for searchLogs",
292
+ });
293
+ Logger({ level: "WARN", message: warrning });
294
+ }
295
+
168
296
  const query_params = {};
169
297
  query_params["page_no"] = pageNo;
170
298
  query_params["page_size"] = pageSize;
171
299
 
172
300
  const xHeaders = {};
173
301
 
174
- return PlatformAPIClient.execute(
302
+ const response = await PlatformAPIClient.execute(
175
303
  this.config,
176
304
  "post",
177
305
  `/service/platform/analytics/v1.0/company/${this.config.companyId}/logs/${logType}/search`,
@@ -179,6 +307,23 @@ class Analytics {
179
307
  body,
180
308
  xHeaders
181
309
  );
310
+
311
+ const {
312
+ error: res_error,
313
+ } = AnalyticsModel.SearchLogRes().validate(response, {
314
+ abortEarly: false,
315
+ allowUnknown: false,
316
+ });
317
+
318
+ if (res_error) {
319
+ Logger({
320
+ level: "WARN",
321
+ message: "Response Validation Warnnings for searchLogs",
322
+ });
323
+ Logger({ level: "WARN", message: res_error });
324
+ }
325
+
326
+ return response;
182
327
  }
183
328
 
184
329
  /**
@@ -5,34 +5,38 @@ declare class AuditTrail {
5
5
  /**
6
6
  * @param {Object} arg - Arg object.
7
7
  * @param {string} arg.qs - Logs Query
8
+ * @returns {Promise<LogSchemaResponse>} - Success response
8
9
  * @summary: Get paginated audit logs
9
10
  * @description: Get a paginated set of logs that can be filtered using the available set of parameters and get the relevant group of logs
10
11
  */
11
12
  getAuditLogs({ qs }?: {
12
13
  qs: string;
13
- }): Promise<any>;
14
+ }): Promise<LogSchemaResponse>;
14
15
  /**
15
16
  * @param {Object} arg - Arg object.
16
17
  * @param {RequestBodyAuditLog} arg.body
18
+ * @returns {Promise<CreateLogResponse>} - Success response
17
19
  * @summary: Create logs for auditing later on
18
20
  * @description: Create a log instance that stores all the relevant info to be logged
19
21
  */
20
22
  createAuditLog({ body }?: {
21
23
  body: RequestBodyAuditLog;
22
- }): Promise<any>;
24
+ }): Promise<CreateLogResponse>;
23
25
  /**
24
26
  * @param {Object} arg - Arg object.
25
27
  * @param {string} arg.id - Log uuid
28
+ * @returns {Promise<LogSchemaResponse>} - Success response
26
29
  * @summary: Get audit log
27
30
  * @description: Get detailed log information by their id
28
31
  */
29
32
  getAuditLog({ id }?: {
30
33
  id: string;
31
- }): Promise<any>;
34
+ }): Promise<LogSchemaResponse>;
32
35
  /**
33
36
  * @param {Object} arg - Arg object.
37
+ * @returns {Promise<EntityTypesResponse>} - Success response
34
38
  * @summary: Get entity types
35
39
  * @description: Get a consolidated list of entity types from all the logs stored on the db, which further helps to filter the logs better
36
40
  */
37
- getEntityTypes({}?: any): Promise<any>;
41
+ getEntityTypes({}?: any): Promise<EntityTypesResponse>;
38
42
  }
@@ -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 AuditTrailValidator = require("./AuditTrailPlatformValidator");
5
+ const AuditTrailModel = require("./AuditTrailPlatformModel");
6
+ const { Logger } = require("./../../common/Logger");
7
+
5
8
  class AuditTrail {
6
9
  constructor(config) {
7
10
  this.config = config;
@@ -10,10 +13,11 @@ class AuditTrail {
10
13
  /**
11
14
  * @param {Object} arg - Arg object.
12
15
  * @param {string} arg.qs - Logs Query
16
+ * @returns {Promise<LogSchemaResponse>} - Success response
13
17
  * @summary: Get paginated audit logs
14
18
  * @description: Get a paginated set of logs that can be filtered using the available set of parameters and get the relevant group of logs
15
19
  */
16
- getAuditLogs({ qs } = {}) {
20
+ async getAuditLogs({ qs } = {}) {
17
21
  const { error } = AuditTrailValidator.getAuditLogs().validate(
18
22
  {
19
23
  qs,
@@ -24,12 +28,27 @@ class AuditTrail {
24
28
  return Promise.reject(new FDKClientValidationError(error));
25
29
  }
26
30
 
31
+ // Showing warrnings if extra unknown parameters are found
32
+ const { error: warrning } = AuditTrailValidator.getAuditLogs().validate(
33
+ {
34
+ qs,
35
+ },
36
+ { abortEarly: false, allowUnknown: false }
37
+ );
38
+ if (warrning) {
39
+ Logger({
40
+ level: "WARN",
41
+ message: "Parameter Validation warrnings for getAuditLogs",
42
+ });
43
+ Logger({ level: "WARN", message: warrning });
44
+ }
45
+
27
46
  const query_params = {};
28
47
  query_params["qs"] = qs;
29
48
 
30
49
  const xHeaders = {};
31
50
 
32
- return PlatformAPIClient.execute(
51
+ const response = await PlatformAPIClient.execute(
33
52
  this.config,
34
53
  "get",
35
54
  `/service/platform/audit-trail/v1.0/company/${this.config.companyId}/logs/`,
@@ -37,15 +56,33 @@ class AuditTrail {
37
56
  undefined,
38
57
  xHeaders
39
58
  );
59
+
60
+ const {
61
+ error: res_error,
62
+ } = AuditTrailModel.LogSchemaResponse().validate(response, {
63
+ abortEarly: false,
64
+ allowUnknown: false,
65
+ });
66
+
67
+ if (res_error) {
68
+ Logger({
69
+ level: "WARN",
70
+ message: "Response Validation Warnnings for getAuditLogs",
71
+ });
72
+ Logger({ level: "WARN", message: res_error });
73
+ }
74
+
75
+ return response;
40
76
  }
41
77
 
42
78
  /**
43
79
  * @param {Object} arg - Arg object.
44
80
  * @param {RequestBodyAuditLog} arg.body
81
+ * @returns {Promise<CreateLogResponse>} - Success response
45
82
  * @summary: Create logs for auditing later on
46
83
  * @description: Create a log instance that stores all the relevant info to be logged
47
84
  */
48
- createAuditLog({ body } = {}) {
85
+ async createAuditLog({ body } = {}) {
49
86
  const { error } = AuditTrailValidator.createAuditLog().validate(
50
87
  {
51
88
  body,
@@ -56,11 +93,26 @@ class AuditTrail {
56
93
  return Promise.reject(new FDKClientValidationError(error));
57
94
  }
58
95
 
96
+ // Showing warrnings if extra unknown parameters are found
97
+ const { error: warrning } = AuditTrailValidator.createAuditLog().validate(
98
+ {
99
+ body,
100
+ },
101
+ { abortEarly: false, allowUnknown: false }
102
+ );
103
+ if (warrning) {
104
+ Logger({
105
+ level: "WARN",
106
+ message: "Parameter Validation warrnings for createAuditLog",
107
+ });
108
+ Logger({ level: "WARN", message: warrning });
109
+ }
110
+
59
111
  const query_params = {};
60
112
 
61
113
  const xHeaders = {};
62
114
 
63
- return PlatformAPIClient.execute(
115
+ const response = await PlatformAPIClient.execute(
64
116
  this.config,
65
117
  "post",
66
118
  `/service/platform/audit-trail/v1.0/company/${this.config.companyId}/logs/`,
@@ -68,15 +120,33 @@ class AuditTrail {
68
120
  body,
69
121
  xHeaders
70
122
  );
123
+
124
+ const {
125
+ error: res_error,
126
+ } = AuditTrailModel.CreateLogResponse().validate(response, {
127
+ abortEarly: false,
128
+ allowUnknown: false,
129
+ });
130
+
131
+ if (res_error) {
132
+ Logger({
133
+ level: "WARN",
134
+ message: "Response Validation Warnnings for createAuditLog",
135
+ });
136
+ Logger({ level: "WARN", message: res_error });
137
+ }
138
+
139
+ return response;
71
140
  }
72
141
 
73
142
  /**
74
143
  * @param {Object} arg - Arg object.
75
144
  * @param {string} arg.id - Log uuid
145
+ * @returns {Promise<LogSchemaResponse>} - Success response
76
146
  * @summary: Get audit log
77
147
  * @description: Get detailed log information by their id
78
148
  */
79
- getAuditLog({ id } = {}) {
149
+ async getAuditLog({ id } = {}) {
80
150
  const { error } = AuditTrailValidator.getAuditLog().validate(
81
151
  {
82
152
  id,
@@ -87,11 +157,26 @@ class AuditTrail {
87
157
  return Promise.reject(new FDKClientValidationError(error));
88
158
  }
89
159
 
160
+ // Showing warrnings if extra unknown parameters are found
161
+ const { error: warrning } = AuditTrailValidator.getAuditLog().validate(
162
+ {
163
+ id,
164
+ },
165
+ { abortEarly: false, allowUnknown: false }
166
+ );
167
+ if (warrning) {
168
+ Logger({
169
+ level: "WARN",
170
+ message: "Parameter Validation warrnings for getAuditLog",
171
+ });
172
+ Logger({ level: "WARN", message: warrning });
173
+ }
174
+
90
175
  const query_params = {};
91
176
 
92
177
  const xHeaders = {};
93
178
 
94
- return PlatformAPIClient.execute(
179
+ const response = await PlatformAPIClient.execute(
95
180
  this.config,
96
181
  "get",
97
182
  `/service/platform/audit-trail/v1.0/company/${this.config.companyId}/logs/${id}`,
@@ -99,14 +184,32 @@ class AuditTrail {
99
184
  undefined,
100
185
  xHeaders
101
186
  );
187
+
188
+ const {
189
+ error: res_error,
190
+ } = AuditTrailModel.LogSchemaResponse().validate(response, {
191
+ abortEarly: false,
192
+ allowUnknown: false,
193
+ });
194
+
195
+ if (res_error) {
196
+ Logger({
197
+ level: "WARN",
198
+ message: "Response Validation Warnnings for getAuditLog",
199
+ });
200
+ Logger({ level: "WARN", message: res_error });
201
+ }
202
+
203
+ return response;
102
204
  }
103
205
 
104
206
  /**
105
207
  * @param {Object} arg - Arg object.
208
+ * @returns {Promise<EntityTypesResponse>} - Success response
106
209
  * @summary: Get entity types
107
210
  * @description: Get a consolidated list of entity types from all the logs stored on the db, which further helps to filter the logs better
108
211
  */
109
- getEntityTypes({} = {}) {
212
+ async getEntityTypes({} = {}) {
110
213
  const { error } = AuditTrailValidator.getEntityTypes().validate(
111
214
  {},
112
215
  { abortEarly: false, allowUnknown: true }
@@ -115,11 +218,24 @@ class AuditTrail {
115
218
  return Promise.reject(new FDKClientValidationError(error));
116
219
  }
117
220
 
221
+ // Showing warrnings if extra unknown parameters are found
222
+ const { error: warrning } = AuditTrailValidator.getEntityTypes().validate(
223
+ {},
224
+ { abortEarly: false, allowUnknown: false }
225
+ );
226
+ if (warrning) {
227
+ Logger({
228
+ level: "WARN",
229
+ message: "Parameter Validation warrnings for getEntityTypes",
230
+ });
231
+ Logger({ level: "WARN", message: warrning });
232
+ }
233
+
118
234
  const query_params = {};
119
235
 
120
236
  const xHeaders = {};
121
237
 
122
- return PlatformAPIClient.execute(
238
+ const response = await PlatformAPIClient.execute(
123
239
  this.config,
124
240
  "get",
125
241
  `/service/platform/audit-trail/v1.0/company/${this.config.companyId}/entity-types`,
@@ -127,6 +243,23 @@ class AuditTrail {
127
243
  undefined,
128
244
  xHeaders
129
245
  );
246
+
247
+ const {
248
+ error: res_error,
249
+ } = AuditTrailModel.EntityTypesResponse().validate(response, {
250
+ abortEarly: false,
251
+ allowUnknown: false,
252
+ });
253
+
254
+ if (res_error) {
255
+ Logger({
256
+ level: "WARN",
257
+ message: "Response Validation Warnnings for getEntityTypes",
258
+ });
259
+ Logger({ level: "WARN", message: res_error });
260
+ }
261
+
262
+ return response;
130
263
  }
131
264
  }
132
265