@gofynd/fdk-client-javascript 1.4.6 → 1.4.8-beta.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 (140) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -2
  3. package/sdk/application/ApplicationClient.d.ts +2 -0
  4. package/sdk/application/ApplicationClient.js +2 -0
  5. package/sdk/application/Cart/CartApplicationClient.d.ts +16 -3
  6. package/sdk/application/Cart/CartApplicationClient.js +118 -13
  7. package/sdk/application/Cart/CartApplicationModel.d.ts +121 -45
  8. package/sdk/application/Cart/CartApplicationModel.js +98 -26
  9. package/sdk/application/Cart/CartApplicationValidator.d.ts +45 -1
  10. package/sdk/application/Cart/CartApplicationValidator.js +26 -0
  11. package/sdk/application/Catalog/CatalogApplicationModel.d.ts +10 -2
  12. package/sdk/application/Catalog/CatalogApplicationModel.js +10 -2
  13. package/sdk/application/Content/ContentApplicationClient.d.ts +1 -1
  14. package/sdk/application/Content/ContentApplicationClient.js +5 -3
  15. package/sdk/application/Content/ContentApplicationModel.d.ts +7 -18
  16. package/sdk/application/Content/ContentApplicationModel.js +6 -20
  17. package/sdk/application/Content/ContentApplicationValidator.d.ts +10 -0
  18. package/sdk/application/Content/ContentApplicationValidator.js +4 -0
  19. package/sdk/application/Lead/LeadApplicationClient.d.ts +0 -27
  20. package/sdk/application/Lead/LeadApplicationClient.js +0 -167
  21. package/sdk/application/Lead/LeadApplicationModel.d.ts +1 -146
  22. package/sdk/application/Lead/LeadApplicationModel.js +0 -126
  23. package/sdk/application/Lead/LeadApplicationValidator.d.ts +1 -25
  24. package/sdk/application/Lead/LeadApplicationValidator.js +0 -24
  25. package/sdk/application/Logistic/LogisticApplicationClient.js +1 -1
  26. package/sdk/application/Logistic/LogisticApplicationModel.d.ts +2 -0
  27. package/sdk/application/Logistic/LogisticApplicationModel.js +2 -0
  28. package/sdk/application/Order/OrderApplicationModel.d.ts +72 -9
  29. package/sdk/application/Order/OrderApplicationModel.js +45 -7
  30. package/sdk/application/Payment/PaymentApplicationModel.d.ts +27 -20
  31. package/sdk/application/Payment/PaymentApplicationModel.js +23 -20
  32. package/sdk/application/Theme/ThemeApplicationModel.d.ts +2 -0
  33. package/sdk/application/Theme/ThemeApplicationModel.js +2 -0
  34. package/sdk/application/Webhook/WebhookApplicationClient.d.ts +22 -0
  35. package/sdk/application/Webhook/WebhookApplicationClient.js +115 -0
  36. package/sdk/application/Webhook/WebhookApplicationModel.d.ts +37 -0
  37. package/sdk/application/Webhook/WebhookApplicationModel.js +46 -0
  38. package/sdk/application/Webhook/WebhookApplicationValidator.d.ts +16 -0
  39. package/sdk/application/Webhook/WebhookApplicationValidator.js +19 -0
  40. package/sdk/application/index.d.ts +1 -0
  41. package/sdk/application/index.js +2 -0
  42. package/sdk/partner/Lead/LeadPartnerClient.d.ts +0 -23
  43. package/sdk/partner/Lead/LeadPartnerClient.js +0 -157
  44. package/sdk/partner/Lead/LeadPartnerModel.d.ts +12 -581
  45. package/sdk/partner/Lead/LeadPartnerModel.js +14 -403
  46. package/sdk/partner/Lead/LeadPartnerValidator.d.ts +0 -2
  47. package/sdk/partner/Lead/LeadPartnerValidator.js +0 -12
  48. package/sdk/partner/Logistics/LogisticsPartnerClient.js +1 -1
  49. package/sdk/partner/Logistics/LogisticsPartnerModel.js +4 -4
  50. package/sdk/partner/Theme/ThemePartnerClient.d.ts +22 -0
  51. package/sdk/partner/Theme/ThemePartnerClient.js +162 -0
  52. package/sdk/partner/Theme/ThemePartnerModel.d.ts +119 -1
  53. package/sdk/partner/Theme/ThemePartnerModel.js +142 -0
  54. package/sdk/partner/Theme/ThemePartnerValidator.d.ts +2 -0
  55. package/sdk/partner/Theme/ThemePartnerValidator.js +14 -0
  56. package/sdk/partner/Webhook/WebhookPartnerClient.d.ts +2 -2
  57. package/sdk/partner/Webhook/WebhookPartnerClient.js +2 -2
  58. package/sdk/partner/Webhook/WebhookPartnerModel.d.ts +23 -19
  59. package/sdk/partner/Webhook/WebhookPartnerModel.js +19 -22
  60. package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.d.ts +43 -0
  61. package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.js +257 -0
  62. package/sdk/platform/Analytics/AnalyticsPlatformApplicationValidator.d.ts +39 -0
  63. package/sdk/platform/Analytics/AnalyticsPlatformApplicationValidator.js +45 -0
  64. package/sdk/platform/Analytics/AnalyticsPlatformModel.d.ts +60 -0
  65. package/sdk/platform/Analytics/AnalyticsPlatformModel.js +57 -0
  66. package/sdk/platform/Billing/BillingPlatformClient.d.ts +304 -43
  67. package/sdk/platform/Billing/BillingPlatformClient.js +2218 -118
  68. package/sdk/platform/Billing/BillingPlatformModel.d.ts +1330 -282
  69. package/sdk/platform/Billing/BillingPlatformModel.js +1808 -590
  70. package/sdk/platform/Billing/BillingPlatformValidator.d.ts +324 -16
  71. package/sdk/platform/Billing/BillingPlatformValidator.js +340 -12
  72. package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +36 -3
  73. package/sdk/platform/Cart/CartPlatformApplicationClient.js +276 -3
  74. package/sdk/platform/Cart/CartPlatformApplicationValidator.d.ts +93 -1
  75. package/sdk/platform/Cart/CartPlatformApplicationValidator.js +60 -0
  76. package/sdk/platform/Cart/CartPlatformModel.d.ts +216 -40
  77. package/sdk/platform/Cart/CartPlatformModel.js +166 -24
  78. package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +11 -7
  79. package/sdk/platform/Catalog/CatalogPlatformClient.js +37 -14
  80. package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +122 -17
  81. package/sdk/platform/Catalog/CatalogPlatformModel.js +141 -15
  82. package/sdk/platform/Catalog/CatalogPlatformValidator.d.ts +40 -7
  83. package/sdk/platform/Catalog/CatalogPlatformValidator.js +19 -5
  84. package/sdk/platform/Content/ContentPlatformApplicationClient.d.ts +1 -1
  85. package/sdk/platform/Content/ContentPlatformApplicationClient.js +18 -1
  86. package/sdk/platform/Content/ContentPlatformApplicationValidator.d.ts +25 -0
  87. package/sdk/platform/Content/ContentPlatformApplicationValidator.js +10 -0
  88. package/sdk/platform/Content/ContentPlatformModel.d.ts +8 -4
  89. package/sdk/platform/Content/ContentPlatformModel.js +8 -4
  90. package/sdk/platform/Finance/FinancePlatformClient.d.ts +49 -28
  91. package/sdk/platform/Finance/FinancePlatformClient.js +181 -28
  92. package/sdk/platform/Finance/FinancePlatformModel.d.ts +350 -127
  93. package/sdk/platform/Finance/FinancePlatformModel.js +378 -108
  94. package/sdk/platform/Finance/FinancePlatformValidator.d.ts +56 -43
  95. package/sdk/platform/Finance/FinancePlatformValidator.js +61 -42
  96. package/sdk/platform/Lead/LeadPlatformApplicationClient.d.ts +0 -47
  97. package/sdk/platform/Lead/LeadPlatformApplicationClient.js +0 -321
  98. package/sdk/platform/Lead/LeadPlatformApplicationValidator.d.ts +1 -46
  99. package/sdk/platform/Lead/LeadPlatformApplicationValidator.js +0 -48
  100. package/sdk/platform/Lead/LeadPlatformClient.d.ts +2 -25
  101. package/sdk/platform/Lead/LeadPlatformClient.js +2 -167
  102. package/sdk/platform/Lead/LeadPlatformModel.d.ts +82 -204
  103. package/sdk/platform/Lead/LeadPlatformModel.js +98 -178
  104. package/sdk/platform/Lead/LeadPlatformValidator.d.ts +1 -25
  105. package/sdk/platform/Lead/LeadPlatformValidator.js +0 -24
  106. package/sdk/platform/Order/OrderPlatformClient.d.ts +11 -1
  107. package/sdk/platform/Order/OrderPlatformClient.js +82 -5
  108. package/sdk/platform/Order/OrderPlatformModel.d.ts +270 -29
  109. package/sdk/platform/Order/OrderPlatformModel.js +139 -28
  110. package/sdk/platform/Order/OrderPlatformValidator.d.ts +58 -17
  111. package/sdk/platform/Order/OrderPlatformValidator.js +28 -16
  112. package/sdk/platform/Payment/PaymentPlatformModel.d.ts +14 -2
  113. package/sdk/platform/Payment/PaymentPlatformModel.js +7 -2
  114. package/sdk/platform/PlatformApplicationClient.d.ts +2 -0
  115. package/sdk/platform/PlatformApplicationClient.js +4 -0
  116. package/sdk/platform/Serviceability/ServiceabilityPlatformModel.js +4 -4
  117. package/sdk/platform/Theme/ThemePlatformApplicationClient.d.ts +12 -0
  118. package/sdk/platform/Theme/ThemePlatformApplicationClient.js +82 -0
  119. package/sdk/platform/Theme/ThemePlatformApplicationValidator.d.ts +18 -1
  120. package/sdk/platform/Theme/ThemePlatformApplicationValidator.js +14 -0
  121. package/sdk/platform/Theme/ThemePlatformModel.d.ts +67 -1
  122. package/sdk/platform/Theme/ThemePlatformModel.js +78 -0
  123. package/sdk/platform/Webhook/WebhookPlatformClient.d.ts +24 -40
  124. package/sdk/platform/Webhook/WebhookPlatformClient.js +78 -221
  125. package/sdk/platform/Webhook/WebhookPlatformModel.d.ts +168 -167
  126. package/sdk/platform/Webhook/WebhookPlatformModel.js +180 -178
  127. package/sdk/platform/Webhook/WebhookPlatformValidator.d.ts +23 -31
  128. package/sdk/platform/Webhook/WebhookPlatformValidator.js +28 -42
  129. package/sdk/platform/index.d.ts +1 -0
  130. package/sdk/platform/index.js +2 -0
  131. package/sdk/public/Billing/BillingPublicClient.d.ts +24 -2
  132. package/sdk/public/Billing/BillingPublicClient.js +156 -3
  133. package/sdk/public/Billing/BillingPublicModel.d.ts +368 -26
  134. package/sdk/public/Billing/BillingPublicModel.js +317 -18
  135. package/sdk/public/Billing/BillingPublicValidator.d.ts +19 -3
  136. package/sdk/public/Billing/BillingPublicValidator.js +22 -3
  137. package/sdk/public/Webhook/WebhookPublicClient.d.ts +2 -2
  138. package/sdk/public/Webhook/WebhookPublicClient.js +2 -2
  139. package/sdk/public/Webhook/WebhookPublicModel.d.ts +24 -22
  140. package/sdk/public/Webhook/WebhookPublicModel.js +24 -22
@@ -169,19 +169,19 @@ export = PaymentApplicationModel;
169
169
  */
170
170
  /**
171
171
  * @typedef PaymentStatusUpdateRequest
172
- * @property {string} status - Status of payment.
173
- * @property {string} merchant_transaction_id - Unique fynd transaction id
172
+ * @property {string} [status] - Status of payment.
173
+ * @property {string} [merchant_transaction_id] - Unique fynd transaction id
174
174
  * @property {string} method - Payment method
175
175
  * @property {string} [device_id] - EDC machine Unique Identifier
176
176
  * @property {string} aggregator - Payment gateway name
177
- * @property {string} customer_id - Payment gateway customer id.
178
- * @property {string} contact - Customer valid mobile number
177
+ * @property {string} [customer_id] - Payment gateway customer id.
178
+ * @property {string} [contact] - Customer valid mobile number
179
179
  * @property {string} merchant_order_id - Unique fynd order id
180
180
  * @property {string} [vpa] - Customer vpa address
181
- * @property {string} order_id - Payment gateway order id
182
- * @property {string} currency - Currency code.
183
- * @property {number} amount - Payable amount.
184
- * @property {string} email - Customer valid email
181
+ * @property {string} [order_id] - Payment gateway order id
182
+ * @property {string} [currency] - Currency code.
183
+ * @property {number} [amount] - Payable amount.
184
+ * @property {string} [email] - Customer valid email
185
185
  */
186
186
  /**
187
187
  * @typedef PaymentStatusUpdateResponse
@@ -263,7 +263,7 @@ export = PaymentApplicationModel;
263
263
  /**
264
264
  * @typedef AggregatorRoute
265
265
  * @property {Object} [data] - Data
266
- * @property {string} [payment_flow_data] - Payment_flow_data
266
+ * @property {Object} [payment_flow_data] - Payment_flow_data
267
267
  * @property {string} [payment_flow] - Payment_flow
268
268
  * @property {string} [api_link] - Api_link
269
269
  */
@@ -386,8 +386,10 @@ export = PaymentApplicationModel;
386
386
  */
387
387
  /**
388
388
  * @typedef LinkStatus
389
- * @property {boolean} status - Link action status
389
+ * @property {string} status - Link action status
390
390
  * @property {string} message - Message
391
+ * @property {boolean} [is_payment_done] - This key specifies payment done
392
+ * status of payment link.
391
393
  */
392
394
  /**
393
395
  * @typedef ResendOrCancelPaymentResponse
@@ -1544,11 +1546,11 @@ type PaymentStatusUpdateRequest = {
1544
1546
  /**
1545
1547
  * - Status of payment.
1546
1548
  */
1547
- status: string;
1549
+ status?: string;
1548
1550
  /**
1549
1551
  * - Unique fynd transaction id
1550
1552
  */
1551
- merchant_transaction_id: string;
1553
+ merchant_transaction_id?: string;
1552
1554
  /**
1553
1555
  * - Payment method
1554
1556
  */
@@ -1564,11 +1566,11 @@ type PaymentStatusUpdateRequest = {
1564
1566
  /**
1565
1567
  * - Payment gateway customer id.
1566
1568
  */
1567
- customer_id: string;
1569
+ customer_id?: string;
1568
1570
  /**
1569
1571
  * - Customer valid mobile number
1570
1572
  */
1571
- contact: string;
1573
+ contact?: string;
1572
1574
  /**
1573
1575
  * - Unique fynd order id
1574
1576
  */
@@ -1580,19 +1582,19 @@ type PaymentStatusUpdateRequest = {
1580
1582
  /**
1581
1583
  * - Payment gateway order id
1582
1584
  */
1583
- order_id: string;
1585
+ order_id?: string;
1584
1586
  /**
1585
1587
  * - Currency code.
1586
1588
  */
1587
- currency: string;
1589
+ currency?: string;
1588
1590
  /**
1589
1591
  * - Payable amount.
1590
1592
  */
1591
- amount: number;
1593
+ amount?: number;
1592
1594
  /**
1593
1595
  * - Customer valid email
1594
1596
  */
1595
- email: string;
1597
+ email?: string;
1596
1598
  };
1597
1599
  /** @returns {PaymentStatusUpdateResponse} */
1598
1600
  declare function PaymentStatusUpdateResponse(): PaymentStatusUpdateResponse;
@@ -1849,7 +1851,7 @@ type AggregatorRoute = {
1849
1851
  /**
1850
1852
  * - Payment_flow_data
1851
1853
  */
1852
- payment_flow_data?: string;
1854
+ payment_flow_data?: any;
1853
1855
  /**
1854
1856
  * - Payment_flow
1855
1857
  */
@@ -2136,11 +2138,16 @@ type LinkStatus = {
2136
2138
  /**
2137
2139
  * - Link action status
2138
2140
  */
2139
- status: boolean;
2141
+ status: string;
2140
2142
  /**
2141
2143
  * - Message
2142
2144
  */
2143
2145
  message: string;
2146
+ /**
2147
+ * - This key specifies payment done
2148
+ * status of payment link.
2149
+ */
2150
+ is_payment_done?: boolean;
2144
2151
  };
2145
2152
  /** @returns {ResendOrCancelPaymentResponse} */
2146
2153
  declare function ResendOrCancelPaymentResponse(): ResendOrCancelPaymentResponse;
@@ -188,19 +188,19 @@ const Joi = require("joi");
188
188
 
189
189
  /**
190
190
  * @typedef PaymentStatusUpdateRequest
191
- * @property {string} status - Status of payment.
192
- * @property {string} merchant_transaction_id - Unique fynd transaction id
191
+ * @property {string} [status] - Status of payment.
192
+ * @property {string} [merchant_transaction_id] - Unique fynd transaction id
193
193
  * @property {string} method - Payment method
194
194
  * @property {string} [device_id] - EDC machine Unique Identifier
195
195
  * @property {string} aggregator - Payment gateway name
196
- * @property {string} customer_id - Payment gateway customer id.
197
- * @property {string} contact - Customer valid mobile number
196
+ * @property {string} [customer_id] - Payment gateway customer id.
197
+ * @property {string} [contact] - Customer valid mobile number
198
198
  * @property {string} merchant_order_id - Unique fynd order id
199
199
  * @property {string} [vpa] - Customer vpa address
200
- * @property {string} order_id - Payment gateway order id
201
- * @property {string} currency - Currency code.
202
- * @property {number} amount - Payable amount.
203
- * @property {string} email - Customer valid email
200
+ * @property {string} [order_id] - Payment gateway order id
201
+ * @property {string} [currency] - Currency code.
202
+ * @property {number} [amount] - Payable amount.
203
+ * @property {string} [email] - Customer valid email
204
204
  */
205
205
 
206
206
  /**
@@ -289,7 +289,7 @@ const Joi = require("joi");
289
289
  /**
290
290
  * @typedef AggregatorRoute
291
291
  * @property {Object} [data] - Data
292
- * @property {string} [payment_flow_data] - Payment_flow_data
292
+ * @property {Object} [payment_flow_data] - Payment_flow_data
293
293
  * @property {string} [payment_flow] - Payment_flow
294
294
  * @property {string} [api_link] - Api_link
295
295
  */
@@ -429,8 +429,10 @@ const Joi = require("joi");
429
429
 
430
430
  /**
431
431
  * @typedef LinkStatus
432
- * @property {boolean} status - Link action status
432
+ * @property {string} status - Link action status
433
433
  * @property {string} message - Message
434
+ * @property {boolean} [is_payment_done] - This key specifies payment done
435
+ * status of payment link.
434
436
  */
435
437
 
436
438
  /**
@@ -1399,19 +1401,19 @@ class PaymentApplicationModel {
1399
1401
  /** @returns {PaymentStatusUpdateRequest} */
1400
1402
  static PaymentStatusUpdateRequest() {
1401
1403
  return Joi.object({
1402
- status: Joi.string().allow("").required(),
1403
- merchant_transaction_id: Joi.string().allow("").required(),
1404
+ status: Joi.string().allow(""),
1405
+ merchant_transaction_id: Joi.string().allow(""),
1404
1406
  method: Joi.string().allow("").required(),
1405
1407
  device_id: Joi.string().allow("").allow(null),
1406
1408
  aggregator: Joi.string().allow("").required(),
1407
- customer_id: Joi.string().allow("").required(),
1408
- contact: Joi.string().allow("").required(),
1409
+ customer_id: Joi.string().allow(""),
1410
+ contact: Joi.string().allow(""),
1409
1411
  merchant_order_id: Joi.string().allow("").required(),
1410
1412
  vpa: Joi.string().allow(""),
1411
- order_id: Joi.string().allow("").required(),
1412
- currency: Joi.string().allow("").required(),
1413
- amount: Joi.number().allow(null).required(),
1414
- email: Joi.string().allow("").required(),
1413
+ order_id: Joi.string().allow(""),
1414
+ currency: Joi.string().allow(""),
1415
+ amount: Joi.number().allow(null),
1416
+ email: Joi.string().allow(""),
1415
1417
  });
1416
1418
  }
1417
1419
 
@@ -1517,7 +1519,7 @@ class PaymentApplicationModel {
1517
1519
  static AggregatorRoute() {
1518
1520
  return Joi.object({
1519
1521
  data: Joi.any().allow(null),
1520
- payment_flow_data: Joi.string().allow("").allow(null),
1522
+ payment_flow_data: Joi.any().allow(null),
1521
1523
  payment_flow: Joi.string().allow("").allow(null),
1522
1524
  api_link: Joi.string().allow("").allow(null),
1523
1525
  });
@@ -1697,8 +1699,9 @@ class PaymentApplicationModel {
1697
1699
  /** @returns {LinkStatus} */
1698
1700
  static LinkStatus() {
1699
1701
  return Joi.object({
1700
- status: Joi.boolean().required(),
1702
+ status: Joi.string().allow("").required(),
1701
1703
  message: Joi.string().allow("").required(),
1704
+ is_payment_done: Joi.boolean(),
1702
1705
  });
1703
1706
  }
1704
1707
 
@@ -60,6 +60,7 @@ export = ThemeApplicationModel;
60
60
  * @typedef AvailablePageSchemaSections
61
61
  * @property {string} [name]
62
62
  * @property {string} [label]
63
+ * @property {string} [source]
63
64
  * @property {Object} [props]
64
65
  * @property {Object[]} [blocks]
65
66
  * @property {Object} [preset]
@@ -592,6 +593,7 @@ declare function AvailablePageSchemaSections(): AvailablePageSchemaSections;
592
593
  type AvailablePageSchemaSections = {
593
594
  name?: string;
594
595
  label?: string;
596
+ source?: string;
595
597
  props?: any;
596
598
  blocks?: any[];
597
599
  preset?: any;
@@ -70,6 +70,7 @@ const Joi = require("joi");
70
70
  * @typedef AvailablePageSchemaSections
71
71
  * @property {string} [name]
72
72
  * @property {string} [label]
73
+ * @property {string} [source]
73
74
  * @property {Object} [props]
74
75
  * @property {Object[]} [blocks]
75
76
  * @property {Object} [preset]
@@ -683,6 +684,7 @@ class ThemeApplicationModel {
683
684
  return Joi.object({
684
685
  name: Joi.string().allow(""),
685
686
  label: Joi.string().allow(""),
687
+ source: Joi.string().allow(""),
686
688
  props: Joi.any(),
687
689
  blocks: Joi.array().items(Joi.any()),
688
690
  preset: Joi.any(),
@@ -0,0 +1,22 @@
1
+ export = Webhook;
2
+ declare class Webhook {
3
+ constructor(_conf: any);
4
+ _conf: any;
5
+ _relativeUrls: {
6
+ saveClickEvent: string;
7
+ };
8
+ _urls: {};
9
+ updateUrls(urls: any): void;
10
+ /**
11
+ * @param {WebhookApplicationValidator.SaveClickEventParam} arg - Arg object.
12
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
13
+ * @param {import("../ApplicationAPIClient").Options} - Options
14
+ * @returns {Promise<WebhookApplicationModel.ClickEventResponse>} - Success response
15
+ * @name saveClickEvent
16
+ * @summary: Endpoint to capture click events from sales channels and persist them in database.
17
+ * @description: Endpoint to capture click events from sales channels. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/webhook/saveClickEvent/).
18
+ */
19
+ saveClickEvent({ body, requestHeaders }?: WebhookApplicationValidator.SaveClickEventParam, { responseHeaders }?: object): Promise<WebhookApplicationModel.ClickEventResponse>;
20
+ }
21
+ import WebhookApplicationValidator = require("./WebhookApplicationValidator");
22
+ import WebhookApplicationModel = require("./WebhookApplicationModel");
@@ -0,0 +1,115 @@
1
+ const ApplicationAPIClient = require("../ApplicationAPIClient");
2
+ const {
3
+ FDKClientValidationError,
4
+ FDKResponseValidationError,
5
+ } = require("../../common/FDKError");
6
+ const constructUrl = require("../constructUrl");
7
+ const Paginator = require("../../common/Paginator");
8
+ const WebhookApplicationValidator = require("./WebhookApplicationValidator");
9
+ const WebhookApplicationModel = require("./WebhookApplicationModel");
10
+ const { Logger } = require("./../../common/Logger");
11
+ const Joi = require("joi");
12
+
13
+ class Webhook {
14
+ constructor(_conf) {
15
+ this._conf = _conf;
16
+ this._relativeUrls = {
17
+ saveClickEvent:
18
+ "/service/application/webhook/v1.0/click-analytics/events",
19
+ };
20
+ this._urls = Object.entries(this._relativeUrls).reduce(
21
+ (urls, [method, relativeUrl]) => {
22
+ urls[method] = `${_conf.domain}${relativeUrl}`;
23
+ return urls;
24
+ },
25
+ {}
26
+ );
27
+ }
28
+
29
+ updateUrls(urls) {
30
+ this._urls = {
31
+ ...this._urls,
32
+ ...urls,
33
+ };
34
+ }
35
+
36
+ /**
37
+ * @param {WebhookApplicationValidator.SaveClickEventParam} arg - Arg object.
38
+ * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
39
+ * @param {import("../ApplicationAPIClient").Options} - Options
40
+ * @returns {Promise<WebhookApplicationModel.ClickEventResponse>} - Success response
41
+ * @name saveClickEvent
42
+ * @summary: Endpoint to capture click events from sales channels and persist them in database.
43
+ * @description: Endpoint to capture click events from sales channels. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/application/webhook/saveClickEvent/).
44
+ */
45
+ async saveClickEvent(
46
+ { body, requestHeaders } = { requestHeaders: {} },
47
+ { responseHeaders } = { responseHeaders: false }
48
+ ) {
49
+ const { error } = WebhookApplicationValidator.saveClickEvent().validate(
50
+ { body },
51
+ { abortEarly: false, allowUnknown: true }
52
+ );
53
+ if (error) {
54
+ return Promise.reject(new FDKClientValidationError(error));
55
+ }
56
+
57
+ // Showing warrnings if extra unknown parameters are found
58
+ const {
59
+ error: warrning,
60
+ } = WebhookApplicationValidator.saveClickEvent().validate(
61
+ { body },
62
+ { abortEarly: false, allowUnknown: false }
63
+ );
64
+ if (warrning) {
65
+ Logger({
66
+ level: "WARN",
67
+ message: `Parameter Validation warrnings for application > Webhook > saveClickEvent \n ${warrning}`,
68
+ });
69
+ }
70
+
71
+ const query_params = {};
72
+
73
+ const xHeaders = {};
74
+
75
+ const response = await ApplicationAPIClient.execute(
76
+ this._conf,
77
+ "post",
78
+ constructUrl({
79
+ url: this._urls["saveClickEvent"],
80
+ params: {},
81
+ }),
82
+ query_params,
83
+ body,
84
+ { ...xHeaders, ...requestHeaders },
85
+ { responseHeaders }
86
+ );
87
+
88
+ let responseData = response;
89
+ if (responseHeaders) {
90
+ responseData = response[0];
91
+ }
92
+
93
+ const {
94
+ error: res_error,
95
+ } = WebhookApplicationModel.ClickEventResponse().validate(responseData, {
96
+ abortEarly: false,
97
+ allowUnknown: true,
98
+ });
99
+
100
+ if (res_error) {
101
+ if (this._conf.options.strictResponseCheck === true) {
102
+ return Promise.reject(new FDKResponseValidationError(res_error));
103
+ } else {
104
+ Logger({
105
+ level: "WARN",
106
+ message: `Response Validation Warnings for application > Webhook > saveClickEvent \n ${res_error}`,
107
+ });
108
+ }
109
+ }
110
+
111
+ return response;
112
+ }
113
+ }
114
+
115
+ module.exports = Webhook;
@@ -0,0 +1,37 @@
1
+ export = WebhookApplicationModel;
2
+ /**
3
+ * @typedef ClickEventBatch
4
+ * @property {string} [event_name]
5
+ */
6
+ /**
7
+ * @typedef ClickEventRequest
8
+ * @property {ClickEventBatch[]} [batch]
9
+ */
10
+ /**
11
+ * @typedef ClickEventResponse
12
+ * @property {number} [success_count]
13
+ * @property {number} [failed_count]
14
+ * @property {ClickEventBatch[]} [failed_events]
15
+ */
16
+ declare class WebhookApplicationModel {
17
+ }
18
+ declare namespace WebhookApplicationModel {
19
+ export { ClickEventBatch, ClickEventRequest, ClickEventResponse };
20
+ }
21
+ /** @returns {ClickEventBatch} */
22
+ declare function ClickEventBatch(): ClickEventBatch;
23
+ type ClickEventBatch = {
24
+ event_name?: string;
25
+ };
26
+ /** @returns {ClickEventRequest} */
27
+ declare function ClickEventRequest(): ClickEventRequest;
28
+ type ClickEventRequest = {
29
+ batch?: ClickEventBatch[];
30
+ };
31
+ /** @returns {ClickEventResponse} */
32
+ declare function ClickEventResponse(): ClickEventResponse;
33
+ type ClickEventResponse = {
34
+ success_count?: number;
35
+ failed_count?: number;
36
+ failed_events?: ClickEventBatch[];
37
+ };
@@ -0,0 +1,46 @@
1
+ const Joi = require("joi");
2
+
3
+ /**
4
+ * @typedef ClickEventBatch
5
+ * @property {string} [event_name]
6
+ */
7
+
8
+ /**
9
+ * @typedef ClickEventRequest
10
+ * @property {ClickEventBatch[]} [batch]
11
+ */
12
+
13
+ /**
14
+ * @typedef ClickEventResponse
15
+ * @property {number} [success_count]
16
+ * @property {number} [failed_count]
17
+ * @property {ClickEventBatch[]} [failed_events]
18
+ */
19
+
20
+ class WebhookApplicationModel {
21
+ /** @returns {ClickEventBatch} */
22
+ static ClickEventBatch() {
23
+ return Joi.object({
24
+ event_name: Joi.string().allow(""),
25
+ });
26
+ }
27
+
28
+ /** @returns {ClickEventRequest} */
29
+ static ClickEventRequest() {
30
+ return Joi.object({
31
+ batch: Joi.array().items(WebhookApplicationModel.ClickEventBatch()),
32
+ });
33
+ }
34
+
35
+ /** @returns {ClickEventResponse} */
36
+ static ClickEventResponse() {
37
+ return Joi.object({
38
+ success_count: Joi.number(),
39
+ failed_count: Joi.number(),
40
+ failed_events: Joi.array().items(
41
+ WebhookApplicationModel.ClickEventBatch()
42
+ ),
43
+ });
44
+ }
45
+ }
46
+ module.exports = WebhookApplicationModel;
@@ -0,0 +1,16 @@
1
+ export = WebhookApplicationValidator;
2
+ /**
3
+ * @typedef SaveClickEventParam
4
+ * @property {WebhookApplicationModel.ClickEventRequest} body
5
+ */
6
+ declare class WebhookApplicationValidator {
7
+ /** @returns {SaveClickEventParam} */
8
+ static saveClickEvent(): SaveClickEventParam;
9
+ }
10
+ declare namespace WebhookApplicationValidator {
11
+ export { SaveClickEventParam };
12
+ }
13
+ type SaveClickEventParam = {
14
+ body: WebhookApplicationModel.ClickEventRequest;
15
+ };
16
+ import WebhookApplicationModel = require("./WebhookApplicationModel");
@@ -0,0 +1,19 @@
1
+ const Joi = require("joi");
2
+
3
+ const WebhookApplicationModel = require("./WebhookApplicationModel");
4
+
5
+ /**
6
+ * @typedef SaveClickEventParam
7
+ * @property {WebhookApplicationModel.ClickEventRequest} body
8
+ */
9
+
10
+ class WebhookApplicationValidator {
11
+ /** @returns {SaveClickEventParam} */
12
+ static saveClickEvent() {
13
+ return Joi.object({
14
+ body: WebhookApplicationModel.ClickEventRequest().required(),
15
+ }).required();
16
+ }
17
+ }
18
+
19
+ module.exports = WebhookApplicationValidator;
@@ -16,4 +16,5 @@ export namespace ApplicationModel {
16
16
  const ShareApplicationModel: typeof import("./Share/ShareApplicationModel");
17
17
  const ThemeApplicationModel: typeof import("./Theme/ThemeApplicationModel");
18
18
  const UserApplicationModel: typeof import("./User/UserApplicationModel");
19
+ const WebhookApplicationModel: typeof import("./Webhook/WebhookApplicationModel");
19
20
  }
@@ -31,5 +31,7 @@ module.exports = {
31
31
  ThemeApplicationModel: require("./Theme/ThemeApplicationModel"),
32
32
 
33
33
  UserApplicationModel: require("./User/UserApplicationModel"),
34
+
35
+ WebhookApplicationModel: require("./Webhook/WebhookApplicationModel"),
34
36
  },
35
37
  };
@@ -87,29 +87,6 @@ declare class Lead {
87
87
  * @description: Gets history list for specific partner level ticket, this history is seen on ticket detail page, this can be comment, log or rating. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/partner/lead/getTicketHistory/).
88
88
  */
89
89
  getTicketHistory({ id, requestHeaders }?: LeadPartnerValidator.GetTicketHistoryParam, { responseHeaders }?: object): Promise<LeadPartnerModel.TicketHistoryList>;
90
- /**
91
- * @param {LeadPartnerValidator.GetTokenForVideoRoomParam} arg - Arg object.
92
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
93
- * @param {import("../PartnerAPIClient").Options} - Options
94
- * @returns {Promise<LeadPartnerModel.GetTokenForVideoRoomResponse>} -
95
- * Success response
96
- * @name getTokenForVideoRoom
97
- * @summary: Get Token to join a specific Video Room using it's unqiue name
98
- * @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. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/partner/lead/getTokenForVideoRoom/).
99
- */
100
- getTokenForVideoRoom({ uniqueName, requestHeaders }?: LeadPartnerValidator.GetTokenForVideoRoomParam, { responseHeaders }?: object): Promise<LeadPartnerModel.GetTokenForVideoRoomResponse>;
101
- /**
102
- * @param {LeadPartnerValidator.GetVideoParticipantsParam} arg - Arg object.
103
- * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
104
- * @param {import("../PartnerAPIClient").Options} - Options
105
- * @returns {Promise<LeadPartnerModel.GetParticipantsInsideVideoRoomResponse>}
106
- * - Success response
107
- *
108
- * @name getVideoParticipants
109
- * @summary: Get participants of a specific Video Room using it's unique name
110
- * @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. - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/partner/lead/getVideoParticipants/).
111
- */
112
- getVideoParticipants({ uniqueName, requestHeaders }?: LeadPartnerValidator.GetVideoParticipantsParam, { responseHeaders }?: object): Promise<LeadPartnerModel.GetParticipantsInsideVideoRoomResponse>;
113
90
  /**
114
91
  * @param {LeadPartnerValidator.GetGeneralConfigParam} arg - Arg object.
115
92
  * @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`