@gofynd/fdk-client-javascript 1.4.5 → 1.4.7
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.
- package/README.md +1 -1
- package/package.json +2 -2
- package/sdk/application/ApplicationClient.d.ts +2 -2
- package/sdk/application/ApplicationClient.js +2 -2
- package/sdk/application/Catalog/CatalogApplicationClient.d.ts +5 -5
- package/sdk/application/Catalog/CatalogApplicationClient.js +5 -5
- package/sdk/application/Catalog/CatalogApplicationModel.d.ts +6 -0
- package/sdk/application/Catalog/CatalogApplicationModel.js +6 -0
- package/sdk/application/Content/ContentApplicationModel.d.ts +2 -0
- package/sdk/application/Content/ContentApplicationModel.js +2 -0
- package/sdk/application/Logistic/LogisticApplicationModel.js +2 -2
- package/sdk/application/Order/OrderApplicationClient.d.ts +1 -1
- package/sdk/application/Order/OrderApplicationClient.js +1 -1
- package/sdk/application/Order/OrderApplicationModel.d.ts +70 -9
- package/sdk/application/Order/OrderApplicationModel.js +43 -7
- package/sdk/application/Order/OrderApplicationValidator.d.ts +2 -2
- package/sdk/application/Order/OrderApplicationValidator.js +1 -1
- package/sdk/application/Payment/PaymentApplicationModel.d.ts +18 -18
- package/sdk/application/Payment/PaymentApplicationModel.js +41 -35
- package/sdk/application/Webhook/WebhookApplicationClient.d.ts +22 -0
- package/sdk/application/Webhook/WebhookApplicationClient.js +115 -0
- package/sdk/application/Webhook/WebhookApplicationModel.d.ts +37 -0
- package/sdk/application/Webhook/WebhookApplicationModel.js +46 -0
- package/sdk/application/Webhook/WebhookApplicationValidator.d.ts +16 -0
- package/sdk/application/Webhook/WebhookApplicationValidator.js +19 -0
- package/sdk/application/index.d.ts +1 -1
- package/sdk/application/index.js +2 -2
- package/sdk/partner/Webhook/WebhookPartnerClient.d.ts +2 -2
- package/sdk/partner/Webhook/WebhookPartnerClient.js +2 -2
- package/sdk/partner/Webhook/WebhookPartnerModel.d.ts +23 -19
- package/sdk/partner/Webhook/WebhookPartnerModel.js +20 -23
- package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.d.ts +43 -0
- package/sdk/platform/Analytics/AnalyticsPlatformApplicationClient.js +257 -0
- package/sdk/platform/Analytics/AnalyticsPlatformApplicationValidator.d.ts +39 -0
- package/sdk/platform/Analytics/AnalyticsPlatformApplicationValidator.js +45 -0
- package/sdk/platform/Analytics/AnalyticsPlatformModel.d.ts +60 -0
- package/sdk/platform/Analytics/AnalyticsPlatformModel.js +57 -0
- package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +10 -0
- package/sdk/platform/Cart/CartPlatformApplicationClient.js +80 -0
- package/sdk/platform/Cart/CartPlatformApplicationValidator.d.ts +13 -1
- package/sdk/platform/Cart/CartPlatformApplicationValidator.js +12 -0
- package/sdk/platform/Cart/CartPlatformModel.d.ts +2 -0
- package/sdk/platform/Cart/CartPlatformModel.js +2 -0
- package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +34 -7
- package/sdk/platform/Catalog/CatalogPlatformClient.js +88 -13
- package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +120 -17
- package/sdk/platform/Catalog/CatalogPlatformModel.js +153 -27
- package/sdk/platform/Catalog/CatalogPlatformValidator.d.ts +71 -7
- package/sdk/platform/Catalog/CatalogPlatformValidator.js +32 -5
- package/sdk/platform/Content/ContentPlatformModel.d.ts +2 -0
- package/sdk/platform/Content/ContentPlatformModel.js +2 -0
- package/sdk/platform/Order/OrderPlatformClient.d.ts +11 -1
- package/sdk/platform/Order/OrderPlatformClient.js +82 -5
- package/sdk/platform/Order/OrderPlatformModel.d.ts +163 -15
- package/sdk/platform/Order/OrderPlatformModel.js +157 -55
- package/sdk/platform/Order/OrderPlatformValidator.d.ts +58 -17
- package/sdk/platform/Order/OrderPlatformValidator.js +28 -16
- package/sdk/platform/Payment/PaymentPlatformModel.d.ts +2 -2
- package/sdk/platform/Payment/PaymentPlatformModel.js +24 -18
- package/sdk/platform/PlatformApplicationClient.d.ts +2 -0
- package/sdk/platform/PlatformApplicationClient.js +4 -0
- package/sdk/platform/Webhook/WebhookPlatformClient.d.ts +24 -0
- package/sdk/platform/Webhook/WebhookPlatformClient.js +164 -0
- package/sdk/platform/Webhook/WebhookPlatformModel.d.ts +71 -18
- package/sdk/platform/Webhook/WebhookPlatformModel.js +76 -23
- package/sdk/platform/Webhook/WebhookPlatformValidator.d.ts +19 -1
- package/sdk/platform/Webhook/WebhookPlatformValidator.js +24 -0
- package/sdk/platform/index.d.ts +1 -0
- package/sdk/platform/index.js +2 -0
- package/sdk/public/Webhook/WebhookPublicClient.d.ts +2 -2
- package/sdk/public/Webhook/WebhookPublicClient.js +2 -2
- package/sdk/public/Webhook/WebhookPublicModel.d.ts +2 -0
- package/sdk/public/Webhook/WebhookPublicModel.js +3 -1
- package/sdk/application/PosCart/PosCartApplicationClient.d.ts +0 -323
- package/sdk/application/PosCart/PosCartApplicationClient.js +0 -2364
- package/sdk/application/PosCart/PosCartApplicationModel.d.ts +0 -1857
- package/sdk/application/PosCart/PosCartApplicationModel.js +0 -1906
- package/sdk/application/PosCart/PosCartApplicationValidator.d.ts +0 -483
- package/sdk/application/PosCart/PosCartApplicationValidator.js +0 -492
|
@@ -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 {
|
|
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
|
*/
|
|
@@ -1544,11 +1544,11 @@ type PaymentStatusUpdateRequest = {
|
|
|
1544
1544
|
/**
|
|
1545
1545
|
* - Status of payment.
|
|
1546
1546
|
*/
|
|
1547
|
-
status
|
|
1547
|
+
status?: string;
|
|
1548
1548
|
/**
|
|
1549
1549
|
* - Unique fynd transaction id
|
|
1550
1550
|
*/
|
|
1551
|
-
merchant_transaction_id
|
|
1551
|
+
merchant_transaction_id?: string;
|
|
1552
1552
|
/**
|
|
1553
1553
|
* - Payment method
|
|
1554
1554
|
*/
|
|
@@ -1564,11 +1564,11 @@ type PaymentStatusUpdateRequest = {
|
|
|
1564
1564
|
/**
|
|
1565
1565
|
* - Payment gateway customer id.
|
|
1566
1566
|
*/
|
|
1567
|
-
customer_id
|
|
1567
|
+
customer_id?: string;
|
|
1568
1568
|
/**
|
|
1569
1569
|
* - Customer valid mobile number
|
|
1570
1570
|
*/
|
|
1571
|
-
contact
|
|
1571
|
+
contact?: string;
|
|
1572
1572
|
/**
|
|
1573
1573
|
* - Unique fynd order id
|
|
1574
1574
|
*/
|
|
@@ -1580,19 +1580,19 @@ type PaymentStatusUpdateRequest = {
|
|
|
1580
1580
|
/**
|
|
1581
1581
|
* - Payment gateway order id
|
|
1582
1582
|
*/
|
|
1583
|
-
order_id
|
|
1583
|
+
order_id?: string;
|
|
1584
1584
|
/**
|
|
1585
1585
|
* - Currency code.
|
|
1586
1586
|
*/
|
|
1587
|
-
currency
|
|
1587
|
+
currency?: string;
|
|
1588
1588
|
/**
|
|
1589
1589
|
* - Payable amount.
|
|
1590
1590
|
*/
|
|
1591
|
-
amount
|
|
1591
|
+
amount?: number;
|
|
1592
1592
|
/**
|
|
1593
1593
|
* - Customer valid email
|
|
1594
1594
|
*/
|
|
1595
|
-
email
|
|
1595
|
+
email?: string;
|
|
1596
1596
|
};
|
|
1597
1597
|
/** @returns {PaymentStatusUpdateResponse} */
|
|
1598
1598
|
declare function PaymentStatusUpdateResponse(): PaymentStatusUpdateResponse;
|
|
@@ -1849,7 +1849,7 @@ type AggregatorRoute = {
|
|
|
1849
1849
|
/**
|
|
1850
1850
|
* - Payment_flow_data
|
|
1851
1851
|
*/
|
|
1852
|
-
payment_flow_data?:
|
|
1852
|
+
payment_flow_data?: any;
|
|
1853
1853
|
/**
|
|
1854
1854
|
* - Payment_flow
|
|
1855
1855
|
*/
|
|
@@ -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 {
|
|
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
|
*/
|
|
@@ -1399,19 +1399,19 @@ class PaymentApplicationModel {
|
|
|
1399
1399
|
/** @returns {PaymentStatusUpdateRequest} */
|
|
1400
1400
|
static PaymentStatusUpdateRequest() {
|
|
1401
1401
|
return Joi.object({
|
|
1402
|
-
status: Joi.string().allow("")
|
|
1403
|
-
merchant_transaction_id: Joi.string().allow("")
|
|
1402
|
+
status: Joi.string().allow(""),
|
|
1403
|
+
merchant_transaction_id: Joi.string().allow(""),
|
|
1404
1404
|
method: Joi.string().allow("").required(),
|
|
1405
1405
|
device_id: Joi.string().allow("").allow(null),
|
|
1406
1406
|
aggregator: Joi.string().allow("").required(),
|
|
1407
|
-
customer_id: Joi.string().allow("")
|
|
1408
|
-
contact: Joi.string().allow("")
|
|
1407
|
+
customer_id: Joi.string().allow(""),
|
|
1408
|
+
contact: Joi.string().allow(""),
|
|
1409
1409
|
merchant_order_id: Joi.string().allow("").required(),
|
|
1410
1410
|
vpa: Joi.string().allow(""),
|
|
1411
|
-
order_id: Joi.string().allow("")
|
|
1412
|
-
currency: Joi.string().allow("")
|
|
1413
|
-
amount: Joi.number().allow(null)
|
|
1414
|
-
email: Joi.string().allow("")
|
|
1411
|
+
order_id: Joi.string().allow(""),
|
|
1412
|
+
currency: Joi.string().allow(""),
|
|
1413
|
+
amount: Joi.number().allow(null),
|
|
1414
|
+
email: Joi.string().allow(""),
|
|
1415
1415
|
});
|
|
1416
1416
|
}
|
|
1417
1417
|
|
|
@@ -1464,13 +1464,17 @@ class PaymentApplicationModel {
|
|
|
1464
1464
|
cod_limit: Joi.number().allow(null),
|
|
1465
1465
|
intent_flow: Joi.boolean().allow(null),
|
|
1466
1466
|
fynd_vpa: Joi.string().allow("").allow(null),
|
|
1467
|
-
intent_app_error_dict_list: Joi.array()
|
|
1468
|
-
PaymentApplicationModel.IntentAppErrorList()
|
|
1469
|
-
|
|
1467
|
+
intent_app_error_dict_list: Joi.array()
|
|
1468
|
+
.items(PaymentApplicationModel.IntentAppErrorList())
|
|
1469
|
+
.allow(null, ""),
|
|
1470
1470
|
aggregator_name: Joi.string().allow("").required(),
|
|
1471
1471
|
card_fingerprint: Joi.string().allow("").allow(null),
|
|
1472
|
-
intent_app_error_list: Joi.array()
|
|
1473
|
-
|
|
1472
|
+
intent_app_error_list: Joi.array()
|
|
1473
|
+
.items(Joi.string().allow(""))
|
|
1474
|
+
.allow(null, ""),
|
|
1475
|
+
intent_app: Joi.array()
|
|
1476
|
+
.items(PaymentApplicationModel.IntentApp())
|
|
1477
|
+
.allow(null, ""),
|
|
1474
1478
|
expired: Joi.boolean().allow(null),
|
|
1475
1479
|
retry_count: Joi.number().allow(null),
|
|
1476
1480
|
exp_year: Joi.number().allow(null),
|
|
@@ -1513,7 +1517,7 @@ class PaymentApplicationModel {
|
|
|
1513
1517
|
static AggregatorRoute() {
|
|
1514
1518
|
return Joi.object({
|
|
1515
1519
|
data: Joi.any().allow(null),
|
|
1516
|
-
payment_flow_data: Joi.
|
|
1520
|
+
payment_flow_data: Joi.any().allow(null),
|
|
1517
1521
|
payment_flow: Joi.string().allow("").allow(null),
|
|
1518
1522
|
api_link: Joi.string().allow("").allow(null),
|
|
1519
1523
|
});
|
|
@@ -1571,9 +1575,9 @@ class PaymentApplicationModel {
|
|
|
1571
1575
|
prepayment_value: Joi.number().allow(null),
|
|
1572
1576
|
cancellation_type: Joi.string().allow("").allow(null),
|
|
1573
1577
|
refund_time_limit: Joi.number().allow(null),
|
|
1574
|
-
all_prepayment_type: Joi.array()
|
|
1575
|
-
Joi.string().allow("").allow(null)
|
|
1576
|
-
|
|
1578
|
+
all_prepayment_type: Joi.array()
|
|
1579
|
+
.items(Joi.string().allow("").allow(null))
|
|
1580
|
+
.allow(null, ""),
|
|
1577
1581
|
allow_custom_advance_amount: Joi.boolean().allow(null),
|
|
1578
1582
|
});
|
|
1579
1583
|
}
|
|
@@ -1594,7 +1598,9 @@ class PaymentApplicationModel {
|
|
|
1594
1598
|
display_priority: Joi.number().allow(null),
|
|
1595
1599
|
payment_mode_id: Joi.number().allow(null),
|
|
1596
1600
|
display_name: Joi.string().allow("").allow(null),
|
|
1597
|
-
list: Joi.array()
|
|
1601
|
+
list: Joi.array()
|
|
1602
|
+
.items(PaymentApplicationModel.PaymentModeList())
|
|
1603
|
+
.allow(null, ""),
|
|
1598
1604
|
split: PaymentApplicationModel.SplitObject(),
|
|
1599
1605
|
advance: PaymentApplicationModel.AdvanceObject(),
|
|
1600
1606
|
});
|
|
@@ -1606,9 +1612,9 @@ class PaymentApplicationModel {
|
|
|
1606
1612
|
payment_options: PaymentApplicationModel.PaymentOptionAndFlow().required(),
|
|
1607
1613
|
success: Joi.boolean().required(),
|
|
1608
1614
|
payment_breakup: Joi.any(),
|
|
1609
|
-
advance_payment: Joi.array()
|
|
1610
|
-
PaymentApplicationModel.AdvancePaymentObject()
|
|
1611
|
-
|
|
1615
|
+
advance_payment: Joi.array()
|
|
1616
|
+
.items(PaymentApplicationModel.AdvancePaymentObject())
|
|
1617
|
+
.allow(null, ""),
|
|
1612
1618
|
});
|
|
1613
1619
|
}
|
|
1614
1620
|
|
|
@@ -1847,9 +1853,9 @@ class PaymentApplicationModel {
|
|
|
1847
1853
|
static OrderBeneficiaryResponse() {
|
|
1848
1854
|
return Joi.object({
|
|
1849
1855
|
show_beneficiary_details: Joi.boolean(),
|
|
1850
|
-
beneficiaries: Joi.array()
|
|
1851
|
-
PaymentApplicationModel.OrderBeneficiaryDetails()
|
|
1852
|
-
|
|
1856
|
+
beneficiaries: Joi.array()
|
|
1857
|
+
.items(PaymentApplicationModel.OrderBeneficiaryDetails())
|
|
1858
|
+
.allow(null, ""),
|
|
1853
1859
|
});
|
|
1854
1860
|
}
|
|
1855
1861
|
|
|
@@ -2355,7 +2361,7 @@ class PaymentApplicationModel {
|
|
|
2355
2361
|
static OutstandingOrderDetailsResponse() {
|
|
2356
2362
|
return Joi.object({
|
|
2357
2363
|
status_code: Joi.number().required(),
|
|
2358
|
-
data: Joi.array().items(Joi.any()),
|
|
2364
|
+
data: Joi.array().items(Joi.any()).allow(null, ""),
|
|
2359
2365
|
success: Joi.boolean().required(),
|
|
2360
2366
|
message: Joi.string().allow("").allow(null),
|
|
2361
2367
|
});
|
|
@@ -2365,7 +2371,7 @@ class PaymentApplicationModel {
|
|
|
2365
2371
|
static PaidOrderDetailsResponse() {
|
|
2366
2372
|
return Joi.object({
|
|
2367
2373
|
status_code: Joi.number().required(),
|
|
2368
|
-
data: Joi.array().items(Joi.any()),
|
|
2374
|
+
data: Joi.array().items(Joi.any()).allow(null, ""),
|
|
2369
2375
|
success: Joi.boolean().required(),
|
|
2370
2376
|
message: Joi.string().allow("").allow(null),
|
|
2371
2377
|
});
|
|
@@ -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;
|
|
@@ -12,9 +12,9 @@ export namespace ApplicationModel {
|
|
|
12
12
|
const LogisticApplicationModel: typeof import("./Logistic/LogisticApplicationModel");
|
|
13
13
|
const OrderApplicationModel: typeof import("./Order/OrderApplicationModel");
|
|
14
14
|
const PaymentApplicationModel: typeof import("./Payment/PaymentApplicationModel");
|
|
15
|
-
const PosCartApplicationModel: typeof import("./PosCart/PosCartApplicationModel");
|
|
16
15
|
const RewardsApplicationModel: typeof import("./Rewards/RewardsApplicationModel");
|
|
17
16
|
const ShareApplicationModel: typeof import("./Share/ShareApplicationModel");
|
|
18
17
|
const ThemeApplicationModel: typeof import("./Theme/ThemeApplicationModel");
|
|
19
18
|
const UserApplicationModel: typeof import("./User/UserApplicationModel");
|
|
19
|
+
const WebhookApplicationModel: typeof import("./Webhook/WebhookApplicationModel");
|
|
20
20
|
}
|
package/sdk/application/index.js
CHANGED
|
@@ -24,8 +24,6 @@ module.exports = {
|
|
|
24
24
|
|
|
25
25
|
PaymentApplicationModel: require("./Payment/PaymentApplicationModel"),
|
|
26
26
|
|
|
27
|
-
PosCartApplicationModel: require("./PosCart/PosCartApplicationModel"),
|
|
28
|
-
|
|
29
27
|
RewardsApplicationModel: require("./Rewards/RewardsApplicationModel"),
|
|
30
28
|
|
|
31
29
|
ShareApplicationModel: require("./Share/ShareApplicationModel"),
|
|
@@ -33,5 +31,7 @@ module.exports = {
|
|
|
33
31
|
ThemeApplicationModel: require("./Theme/ThemeApplicationModel"),
|
|
34
32
|
|
|
35
33
|
UserApplicationModel: require("./User/UserApplicationModel"),
|
|
34
|
+
|
|
35
|
+
WebhookApplicationModel: require("./Webhook/WebhookApplicationModel"),
|
|
36
36
|
},
|
|
37
37
|
};
|
|
@@ -58,7 +58,7 @@ declare class Webhook {
|
|
|
58
58
|
* @param {import("../PartnerAPIClient").Options} - Options
|
|
59
59
|
* @returns {Promise<WebhookPartnerModel.HistoryResponse>} - Success response
|
|
60
60
|
* @name getHistoricalReports
|
|
61
|
-
* @summary: Get report download history
|
|
61
|
+
* @summary: Get report download history.
|
|
62
62
|
* @description: Retrieve history reports for a specific company based on the provided filters.
|
|
63
63
|
* - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/partner/webhook/getHistoricalReports/).
|
|
64
64
|
*/
|
|
@@ -90,7 +90,7 @@ declare class Webhook {
|
|
|
90
90
|
* @param {import("../PartnerAPIClient").Options} - Options
|
|
91
91
|
* @returns {Promise<WebhookPartnerModel.UpdateSubscriberResponse>} - Success response
|
|
92
92
|
* @name updateSubscriber
|
|
93
|
-
* @summary: Update subscriber status by id
|
|
93
|
+
* @summary: Update subscriber status by id.
|
|
94
94
|
* @description: Update subscriber status by id.
|
|
95
95
|
* - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/partner/webhook/updateSubscriber/).
|
|
96
96
|
*/
|
|
@@ -438,7 +438,7 @@ class Webhook {
|
|
|
438
438
|
* @param {import("../PartnerAPIClient").Options} - Options
|
|
439
439
|
* @returns {Promise<WebhookPartnerModel.HistoryResponse>} - Success response
|
|
440
440
|
* @name getHistoricalReports
|
|
441
|
-
* @summary: Get report download history
|
|
441
|
+
* @summary: Get report download history.
|
|
442
442
|
* @description: Retrieve history reports for a specific company based on the provided filters.
|
|
443
443
|
* - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/partner/webhook/getHistoricalReports/).
|
|
444
444
|
*/
|
|
@@ -672,7 +672,7 @@ class Webhook {
|
|
|
672
672
|
* @param {import("../PartnerAPIClient").Options} - Options
|
|
673
673
|
* @returns {Promise<WebhookPartnerModel.UpdateSubscriberResponse>} - Success response
|
|
674
674
|
* @name updateSubscriber
|
|
675
|
-
* @summary: Update subscriber status by id
|
|
675
|
+
* @summary: Update subscriber status by id.
|
|
676
676
|
* @description: Update subscriber status by id.
|
|
677
677
|
* - Check out [method documentation](https://partners.fynd.com/help/docs/sdk/partner/webhook/updateSubscriber/).
|
|
678
678
|
*/
|