@gofynd/fdk-client-javascript 3.17.2 → 3.19.0
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 +6 -2
- package/sdk/application/Order/OrderApplicationClient.d.ts +11 -0
- package/sdk/application/Order/OrderApplicationClient.js +49 -0
- package/sdk/application/Payment/PaymentApplicationClient.d.ts +1 -1
- package/sdk/application/Payment/PaymentApplicationClient.js +2 -0
- package/sdk/common/AxiosHelper.js +10 -3
- package/sdk/common/utils.d.ts +10 -0
- package/sdk/common/utils.js +18 -0
- package/sdk/partner/Webhook/WebhookPartnerClient.d.ts +46 -0
- package/sdk/partner/Webhook/WebhookPartnerClient.js +334 -0
- package/sdk/partner/Webhook/WebhookPartnerModel.d.ts +222 -1
- package/sdk/partner/Webhook/WebhookPartnerModel.js +165 -0
- package/sdk/partner/Webhook/WebhookPartnerValidator.d.ts +4 -0
- package/sdk/partner/Webhook/WebhookPartnerValidator.js +30 -0
- package/sdk/platform/Communication/CommunicationPlatformModel.d.ts +0 -7
- package/sdk/platform/Communication/CommunicationPlatformModel.js +0 -3
- package/sdk/platform/Order/OrderPlatformClient.d.ts +1 -1
- package/sdk/platform/Order/OrderPlatformClient.js +1 -1
- package/sdk/platform/Order/OrderPlatformModel.d.ts +9 -9
- package/sdk/platform/Order/OrderPlatformModel.js +7 -7
- package/sdk/platform/User/UserPlatformModel.d.ts +26 -2
- package/sdk/platform/User/UserPlatformModel.js +10 -2
package/README.md
CHANGED
|
@@ -234,7 +234,7 @@ console.log("Active Theme: ", response.information.name);
|
|
|
234
234
|
The above code will log the curl command in the console
|
|
235
235
|
|
|
236
236
|
```bash
|
|
237
|
-
curl --request GET "https://api.fynd.com/service/application/theme/v1.0/applied-theme" --header 'authorization: Bearer <authorization-token>' --header 'x-fp-sdk-version: 3.
|
|
237
|
+
curl --request GET "https://api.fynd.com/service/application/theme/v1.0/applied-theme" --header 'authorization: Bearer <authorization-token>' --header 'x-fp-sdk-version: 3.19.0' --header 'x-fp-date: 20230222T115108Z' --header 'x-fp-signature: v1.1:1e3ab3b02b5bc626e3c32a37ee844266ade02bbcbaafc28fc7a0e46a76a7a1a8'
|
|
238
238
|
Active Theme: Emerge
|
|
239
239
|
```
|
|
240
240
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gofynd/fdk-client-javascript",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.19.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
},
|
|
13
13
|
"author": "Jigar Dafda",
|
|
14
14
|
"license": "ISC",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/gofynd/fdk-client-javascript.git"
|
|
18
|
+
},
|
|
15
19
|
"dependencies": {
|
|
16
20
|
"axios": "^1.6.4",
|
|
17
21
|
"camelcase": "^6.3.0",
|
|
@@ -42,4 +46,4 @@
|
|
|
42
46
|
"!dist",
|
|
43
47
|
"!cypress"
|
|
44
48
|
]
|
|
45
|
-
}
|
|
49
|
+
}
|
|
@@ -9,6 +9,7 @@ declare class Order {
|
|
|
9
9
|
getOrders: string;
|
|
10
10
|
getPosOrderById: string;
|
|
11
11
|
getRefundModes: string;
|
|
12
|
+
getRefundModesWithPriceBreakup: string;
|
|
12
13
|
getShipmentBagReasons: string;
|
|
13
14
|
getShipmentById: string;
|
|
14
15
|
getShipmentReasons: string;
|
|
@@ -75,6 +76,16 @@ declare class Order {
|
|
|
75
76
|
* - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/application/order/getRefundModes/).
|
|
76
77
|
*/
|
|
77
78
|
getRefundModes({ shipmentId, lineNumbers, requestHeaders }?: object, { responseHeaders }?: import("../ApplicationAPIClient").Options, ...args: any[]): Promise<RefundOptions>;
|
|
79
|
+
/**
|
|
80
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
81
|
+
* @param {import("../ApplicationAPIClient").Options} - Options
|
|
82
|
+
* @returns {Promise<RefundOptions>} - Success response
|
|
83
|
+
* @name getRefundModesWithPriceBreakup
|
|
84
|
+
* @summary: Get refund modes and Refund Price Break for a shipment
|
|
85
|
+
* @description: Returns a list of available refund options for the given company and shipment.
|
|
86
|
+
* - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/application/order/getRefundModesWithPriceBreakup/).
|
|
87
|
+
*/
|
|
88
|
+
getRefundModesWithPriceBreakup({ shipmentId, body, requestHeaders }?: object, { responseHeaders }?: import("../ApplicationAPIClient").Options, ...args: any[]): Promise<RefundOptions>;
|
|
78
89
|
/**
|
|
79
90
|
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
80
91
|
* @param {import("../ApplicationAPIClient").Options} - Options
|
|
@@ -22,6 +22,8 @@ class Order {
|
|
|
22
22
|
"/service/application/order/v1.0/orders/pos-order/{order_id}",
|
|
23
23
|
getRefundModes:
|
|
24
24
|
"/service/application/order-manage/v1.0/shipment/{shipment_id}/refund/modes",
|
|
25
|
+
getRefundModesWithPriceBreakup:
|
|
26
|
+
"/service/application/order-manage/v1.0/shipment/{shipment_id}/refund/modes",
|
|
25
27
|
getShipmentBagReasons:
|
|
26
28
|
"/service/application/order/v1.0/orders/shipments/{shipment_id}/bags/{bag_id}/reasons",
|
|
27
29
|
getShipmentById:
|
|
@@ -348,6 +350,53 @@ class Order {
|
|
|
348
350
|
return response;
|
|
349
351
|
}
|
|
350
352
|
|
|
353
|
+
/**
|
|
354
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
355
|
+
* @param {import("../ApplicationAPIClient").Options} - Options
|
|
356
|
+
* @returns {Promise<RefundOptions>} - Success response
|
|
357
|
+
* @name getRefundModesWithPriceBreakup
|
|
358
|
+
* @summary: Get refund modes and Refund Price Break for a shipment
|
|
359
|
+
* @description: Returns a list of available refund options for the given company and shipment.
|
|
360
|
+
* - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/application/order/getRefundModesWithPriceBreakup/).
|
|
361
|
+
*/
|
|
362
|
+
async getRefundModesWithPriceBreakup(
|
|
363
|
+
{ shipmentId, body, requestHeaders } = { requestHeaders: {} },
|
|
364
|
+
{ responseHeaders } = { responseHeaders: false }
|
|
365
|
+
) {
|
|
366
|
+
const errors = validateRequiredParams(arguments[0], ["shipmentId"]);
|
|
367
|
+
if (errors.length > 0) {
|
|
368
|
+
const error = new FDKClientValidationError({
|
|
369
|
+
message: "Missing required field",
|
|
370
|
+
details: errors,
|
|
371
|
+
});
|
|
372
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const query_params = {};
|
|
376
|
+
|
|
377
|
+
const xHeaders = {};
|
|
378
|
+
|
|
379
|
+
const response = await ApplicationAPIClient.execute(
|
|
380
|
+
this._conf,
|
|
381
|
+
"post",
|
|
382
|
+
constructUrl({
|
|
383
|
+
url: this._urls["getRefundModesWithPriceBreakup"],
|
|
384
|
+
params: { shipmentId },
|
|
385
|
+
}),
|
|
386
|
+
query_params,
|
|
387
|
+
body,
|
|
388
|
+
{ ...xHeaders, ...requestHeaders },
|
|
389
|
+
{ responseHeaders }
|
|
390
|
+
);
|
|
391
|
+
|
|
392
|
+
let responseData = response;
|
|
393
|
+
if (responseHeaders) {
|
|
394
|
+
responseData = response[0];
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
return response;
|
|
398
|
+
}
|
|
399
|
+
|
|
351
400
|
/**
|
|
352
401
|
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
353
402
|
* @param {import("../ApplicationAPIClient").Options} - Options
|
|
@@ -306,7 +306,7 @@ declare class Payment {
|
|
|
306
306
|
* @summary: POS payment modes
|
|
307
307
|
* @description: Get available payment methods on the payment page for POS, specifying the aggregator for each option, such as 'CARD powered by Juspay' and 'QR powered by Razorpay'. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/application/payment/getPosPaymentModeRoutes/).
|
|
308
308
|
*/
|
|
309
|
-
getPosPaymentModeRoutes({ amount, cartId, pincode, orderType, checkoutMode, refresh, cardReference, userDetails, requestHeaders, }?: object, { responseHeaders }?: import("../ApplicationAPIClient").Options): Promise<PaymentModeRouteDetails>;
|
|
309
|
+
getPosPaymentModeRoutes({ amount, cartId, pincode, orderType, checkoutMode, refresh, cardReference, fulfillmentOption, userDetails, requestHeaders, }?: object, { responseHeaders }?: import("../ApplicationAPIClient").Options): Promise<PaymentModeRouteDetails>;
|
|
310
310
|
/**
|
|
311
311
|
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
312
312
|
* @param {import("../ApplicationAPIClient").Options} - Options
|
|
@@ -1180,6 +1180,7 @@ class Payment {
|
|
|
1180
1180
|
checkoutMode,
|
|
1181
1181
|
refresh,
|
|
1182
1182
|
cardReference,
|
|
1183
|
+
fulfillmentOption,
|
|
1183
1184
|
userDetails,
|
|
1184
1185
|
requestHeaders,
|
|
1185
1186
|
} = { requestHeaders: {} },
|
|
@@ -1193,6 +1194,7 @@ class Payment {
|
|
|
1193
1194
|
query_params["refresh"] = refresh;
|
|
1194
1195
|
query_params["card_reference"] = cardReference;
|
|
1195
1196
|
query_params["order_type"] = orderType;
|
|
1197
|
+
query_params["fulfillment_option"] = fulfillmentOption;
|
|
1196
1198
|
query_params["user_details"] = userDetails;
|
|
1197
1199
|
|
|
1198
1200
|
const xHeaders = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { isAbsoluteURL, combineURLs } = require("./utils");
|
|
1
|
+
const { isAbsoluteURL, combineURLs, isWebWorker } = require("./utils");
|
|
2
2
|
const axios = require("axios").default;
|
|
3
3
|
const querystring = require("query-string");
|
|
4
4
|
const { sign } = require("@gofynd/fp-signature");
|
|
@@ -79,12 +79,19 @@ function requestInterceptorFn() {
|
|
|
79
79
|
return config;
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
|
|
83
|
+
const axiosConfig = {
|
|
83
84
|
withCredentials: true,
|
|
84
85
|
paramsSerializer: (params) => {
|
|
85
86
|
return querystring.stringify(params);
|
|
86
87
|
},
|
|
87
|
-
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
if (isWebWorker()) {
|
|
91
|
+
axiosConfig.adapter = "fetch";
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const fdkAxios = axios.create(axiosConfig);
|
|
88
95
|
|
|
89
96
|
// Generate Curl in debug mode
|
|
90
97
|
fdkAxios.interceptors.request.use(
|
package/sdk/common/utils.d.ts
CHANGED
|
@@ -29,3 +29,13 @@ export function combineURLs(baseURL: string, relativeURL: string): string;
|
|
|
29
29
|
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
30
30
|
*/
|
|
31
31
|
export function isAbsoluteURL(url: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Checks if the current execution context is a Web Worker (DedicatedWorker).
|
|
34
|
+
*
|
|
35
|
+
* This function determines whether the code is running inside a Dedicated Web
|
|
36
|
+
* Worker by verifying that the global `self` object exists, has a constructor,
|
|
37
|
+
* and that the constructor's name is "DedicatedWorkerGlobalScope".
|
|
38
|
+
*
|
|
39
|
+
* @returns {boolean} True if running in a Dedicated Web Worker, otherwise false.
|
|
40
|
+
*/
|
|
41
|
+
export function isWebWorker(): boolean;
|
package/sdk/common/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { FDKException } = require("./FDKError");
|
|
2
|
+
const { Buffer: BufferPolyFill } = require("buffer");
|
|
2
3
|
|
|
3
4
|
const SLUG_DELIMETER = ":::";
|
|
4
5
|
const transformRequestOptions = (params) => {
|
|
@@ -166,11 +167,27 @@ const isNode = () => {
|
|
|
166
167
|
);
|
|
167
168
|
};
|
|
168
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Checks if the current execution context is a Web Worker (DedicatedWorker).
|
|
172
|
+
*
|
|
173
|
+
* This function determines whether the code is running inside a Dedicated Web
|
|
174
|
+
* Worker by verifying that the global `self` object exists, has a constructor,
|
|
175
|
+
* and that the constructor's name is "DedicatedWorkerGlobalScope".
|
|
176
|
+
*
|
|
177
|
+
* @returns {boolean} True if running in a Dedicated Web Worker, otherwise false.
|
|
178
|
+
*/
|
|
179
|
+
const isWebWorker = () =>
|
|
180
|
+
typeof self === "object" &&
|
|
181
|
+
self.constructor &&
|
|
182
|
+
self.constructor.name === "DedicatedWorkerGlobalScope";
|
|
183
|
+
|
|
169
184
|
const convertStringToBase64 = (string) => {
|
|
170
185
|
if (isNode()) {
|
|
171
186
|
return Buffer.from(string, "utf-8").toString("base64");
|
|
172
187
|
} else if (isBrowser()) {
|
|
173
188
|
return window.btoa(string);
|
|
189
|
+
} else if (isWebWorker()) {
|
|
190
|
+
return BufferPolyFill.from(string, "utf-8").toString("base64");
|
|
174
191
|
} else {
|
|
175
192
|
throw new FDKException("Base64 conversion error: Unsupported environment");
|
|
176
193
|
}
|
|
@@ -217,4 +234,5 @@ module.exports = {
|
|
|
217
234
|
NAV_TYPE,
|
|
218
235
|
combineURLs,
|
|
219
236
|
isAbsoluteURL,
|
|
237
|
+
isWebWorker,
|
|
220
238
|
};
|
|
@@ -52,6 +52,16 @@ declare class Webhook {
|
|
|
52
52
|
* @description: Fetch webhook report filters - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/partner/webhook/fetchReportFilters/).
|
|
53
53
|
*/
|
|
54
54
|
fetchReportFilters({ extensionId, startDate, endDate, pageNo, pageSize, requestHeaders }?: WebhookPartnerValidator.FetchReportFiltersParam, { responseHeaders }?: object): Promise<WebhookPartnerModel.FilterReportResult[]>;
|
|
55
|
+
/**
|
|
56
|
+
* @param {WebhookPartnerValidator.DownloadDeliveryReportParam} arg - Arg object.
|
|
57
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
58
|
+
* @param {import("../PartnerAPIClient").Options} - Options
|
|
59
|
+
* @returns {Promise<WebhookPartnerModel.DownloadReportResult>} - Success response
|
|
60
|
+
* @name downloadDeliveryReport
|
|
61
|
+
* @summary: Download webhook delivery report
|
|
62
|
+
* @description: Download webhook delivery report - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/partner/webhook/downloadDeliveryReport/).
|
|
63
|
+
*/
|
|
64
|
+
downloadDeliveryReport({ extensionId, body, requestHeaders }?: WebhookPartnerValidator.DownloadDeliveryReportParam, { responseHeaders }?: object): Promise<WebhookPartnerModel.DownloadReportResult>;
|
|
55
65
|
/**
|
|
56
66
|
* @param {WebhookPartnerValidator.CancelReportDownloadParam} arg - Arg object.
|
|
57
67
|
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
@@ -105,5 +115,41 @@ declare class Webhook {
|
|
|
105
115
|
* - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/partner/webhook/updateSubscriber/).
|
|
106
116
|
*/
|
|
107
117
|
updateSubscriber({ extensionId, subscriberId, body, requestHeaders }?: WebhookPartnerValidator.UpdateSubscriberParam, { responseHeaders }?: object): Promise<WebhookPartnerModel.SubscriberUpdateResult>;
|
|
118
|
+
/**
|
|
119
|
+
* @param {WebhookPartnerValidator.ValidateFilterConfigurationParam} arg - Arg object.
|
|
120
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
121
|
+
* @param {import("../PartnerAPIClient").Options} - Options
|
|
122
|
+
* @returns {Promise<WebhookPartnerModel.FilterValidationResult>} - Success response
|
|
123
|
+
* @name validateFilterConfiguration
|
|
124
|
+
* @summary: Validate filter configuration.
|
|
125
|
+
* @description: Validate a filter configuration against sample payload data.
|
|
126
|
+
* - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/partner/webhook/validateFilterConfiguration/).
|
|
127
|
+
*/
|
|
128
|
+
validateFilterConfiguration({ extensionId, body, requestHeaders }?: WebhookPartnerValidator.ValidateFilterConfigurationParam, { responseHeaders }?: object): Promise<WebhookPartnerModel.FilterValidationResult>;
|
|
129
|
+
/**
|
|
130
|
+
* @param {WebhookPartnerValidator.ValidateReducerConfigurationParam} arg -
|
|
131
|
+
* Arg object.
|
|
132
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
133
|
+
* @param {import("../PartnerAPIClient").Options} - Options
|
|
134
|
+
* @returns {Promise<WebhookPartnerModel.ReducerValidationResult>} - Success response
|
|
135
|
+
* @name validateReducerConfiguration
|
|
136
|
+
* @summary: Validate reducer configuration.
|
|
137
|
+
* @description: Validate a reducer configuration against sample payload data.
|
|
138
|
+
* - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/partner/webhook/validateReducerConfiguration/).
|
|
139
|
+
*/
|
|
140
|
+
validateReducerConfiguration({ extensionId, body, requestHeaders }?: WebhookPartnerValidator.ValidateReducerConfigurationParam, { responseHeaders }?: object): Promise<WebhookPartnerModel.ReducerValidationResult>;
|
|
141
|
+
/**
|
|
142
|
+
* @param {WebhookPartnerValidator.SaveFilterReducerConfigurationParam} arg
|
|
143
|
+
* - Arg object.
|
|
144
|
+
*
|
|
145
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
146
|
+
* @param {import("../PartnerAPIClient").Options} - Options
|
|
147
|
+
* @returns {Promise<WebhookPartnerModel.FilterReducerSaveResult>} - Success response
|
|
148
|
+
* @name saveFilterReducerConfiguration
|
|
149
|
+
* @summary: Save filter or reducer configuration.
|
|
150
|
+
* @description: Save filter and/or reducer configuration for a subscriber event mapping.
|
|
151
|
+
* - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/partner/webhook/saveFilterReducerConfiguration/).
|
|
152
|
+
*/
|
|
153
|
+
saveFilterReducerConfiguration({ extensionId, companyId, subscriberId, body, requestHeaders }?: WebhookPartnerValidator.SaveFilterReducerConfigurationParam, { responseHeaders }?: object): Promise<WebhookPartnerModel.FilterReducerSaveResult>;
|
|
108
154
|
}
|
|
109
155
|
import WebhookPartnerModel = require("./WebhookPartnerModel");
|
|
@@ -438,6 +438,85 @@ class Webhook {
|
|
|
438
438
|
return response;
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
+
/**
|
|
442
|
+
* @param {WebhookPartnerValidator.DownloadDeliveryReportParam} arg - Arg object.
|
|
443
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
444
|
+
* @param {import("../PartnerAPIClient").Options} - Options
|
|
445
|
+
* @returns {Promise<WebhookPartnerModel.DownloadReportResult>} - Success response
|
|
446
|
+
* @name downloadDeliveryReport
|
|
447
|
+
* @summary: Download webhook delivery report
|
|
448
|
+
* @description: Download webhook delivery report - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/partner/webhook/downloadDeliveryReport/).
|
|
449
|
+
*/
|
|
450
|
+
async downloadDeliveryReport(
|
|
451
|
+
{ extensionId, body, requestHeaders } = { requestHeaders: {} },
|
|
452
|
+
{ responseHeaders } = { responseHeaders: false }
|
|
453
|
+
) {
|
|
454
|
+
const { error } = WebhookPartnerValidator.downloadDeliveryReport().validate(
|
|
455
|
+
{
|
|
456
|
+
extensionId,
|
|
457
|
+
body,
|
|
458
|
+
},
|
|
459
|
+
{ abortEarly: false, allowUnknown: true }
|
|
460
|
+
);
|
|
461
|
+
if (error) {
|
|
462
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Showing warrnings if extra unknown parameters are found
|
|
466
|
+
const {
|
|
467
|
+
error: warrning,
|
|
468
|
+
} = WebhookPartnerValidator.downloadDeliveryReport().validate(
|
|
469
|
+
{
|
|
470
|
+
extensionId,
|
|
471
|
+
body,
|
|
472
|
+
},
|
|
473
|
+
{ abortEarly: false, allowUnknown: false }
|
|
474
|
+
);
|
|
475
|
+
if (warrning) {
|
|
476
|
+
Logger({
|
|
477
|
+
level: "WARN",
|
|
478
|
+
message: `Parameter Validation warrnings for partner > Webhook > downloadDeliveryReport \n ${warrning}`,
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
const query_params = {};
|
|
483
|
+
|
|
484
|
+
const response = await PartnerAPIClient.execute(
|
|
485
|
+
this.config,
|
|
486
|
+
"post",
|
|
487
|
+
`/service/partner/webhook/v1.0/organization/${this.config.organizationId}/extension/${extensionId}/report/download`,
|
|
488
|
+
query_params,
|
|
489
|
+
body,
|
|
490
|
+
requestHeaders,
|
|
491
|
+
{ responseHeaders }
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
let responseData = response;
|
|
495
|
+
if (responseHeaders) {
|
|
496
|
+
responseData = response[0];
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const {
|
|
500
|
+
error: res_error,
|
|
501
|
+
} = WebhookPartnerModel.DownloadReportResult().validate(responseData, {
|
|
502
|
+
abortEarly: false,
|
|
503
|
+
allowUnknown: true,
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
if (res_error) {
|
|
507
|
+
if (this.config.options.strictResponseCheck === true) {
|
|
508
|
+
return Promise.reject(new FDKResponseValidationError(res_error));
|
|
509
|
+
} else {
|
|
510
|
+
Logger({
|
|
511
|
+
level: "WARN",
|
|
512
|
+
message: `Response Validation Warnings for partner > Webhook > downloadDeliveryReport \n ${res_error}`,
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
return response;
|
|
518
|
+
}
|
|
519
|
+
|
|
441
520
|
/**
|
|
442
521
|
* @param {WebhookPartnerValidator.CancelReportDownloadParam} arg - Arg object.
|
|
443
522
|
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
@@ -834,5 +913,260 @@ class Webhook {
|
|
|
834
913
|
|
|
835
914
|
return response;
|
|
836
915
|
}
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* @param {WebhookPartnerValidator.ValidateFilterConfigurationParam} arg - Arg object.
|
|
919
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
920
|
+
* @param {import("../PartnerAPIClient").Options} - Options
|
|
921
|
+
* @returns {Promise<WebhookPartnerModel.FilterValidationResult>} - Success response
|
|
922
|
+
* @name validateFilterConfiguration
|
|
923
|
+
* @summary: Validate filter configuration.
|
|
924
|
+
* @description: Validate a filter configuration against sample payload data.
|
|
925
|
+
* - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/partner/webhook/validateFilterConfiguration/).
|
|
926
|
+
*/
|
|
927
|
+
async validateFilterConfiguration(
|
|
928
|
+
{ extensionId, body, requestHeaders } = { requestHeaders: {} },
|
|
929
|
+
{ responseHeaders } = { responseHeaders: false }
|
|
930
|
+
) {
|
|
931
|
+
const {
|
|
932
|
+
error,
|
|
933
|
+
} = WebhookPartnerValidator.validateFilterConfiguration().validate(
|
|
934
|
+
{
|
|
935
|
+
extensionId,
|
|
936
|
+
body,
|
|
937
|
+
},
|
|
938
|
+
{ abortEarly: false, allowUnknown: true }
|
|
939
|
+
);
|
|
940
|
+
if (error) {
|
|
941
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
// Showing warrnings if extra unknown parameters are found
|
|
945
|
+
const {
|
|
946
|
+
error: warrning,
|
|
947
|
+
} = WebhookPartnerValidator.validateFilterConfiguration().validate(
|
|
948
|
+
{
|
|
949
|
+
extensionId,
|
|
950
|
+
body,
|
|
951
|
+
},
|
|
952
|
+
{ abortEarly: false, allowUnknown: false }
|
|
953
|
+
);
|
|
954
|
+
if (warrning) {
|
|
955
|
+
Logger({
|
|
956
|
+
level: "WARN",
|
|
957
|
+
message: `Parameter Validation warrnings for partner > Webhook > validateFilterConfiguration \n ${warrning}`,
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
const query_params = {};
|
|
962
|
+
|
|
963
|
+
const response = await PartnerAPIClient.execute(
|
|
964
|
+
this.config,
|
|
965
|
+
"post",
|
|
966
|
+
`/service/partner/webhook/v1.0/organization/${this.config.organizationId}/extension/${extensionId}/validate/filter`,
|
|
967
|
+
query_params,
|
|
968
|
+
body,
|
|
969
|
+
requestHeaders,
|
|
970
|
+
{ responseHeaders }
|
|
971
|
+
);
|
|
972
|
+
|
|
973
|
+
let responseData = response;
|
|
974
|
+
if (responseHeaders) {
|
|
975
|
+
responseData = response[0];
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
const {
|
|
979
|
+
error: res_error,
|
|
980
|
+
} = WebhookPartnerModel.FilterValidationResult().validate(responseData, {
|
|
981
|
+
abortEarly: false,
|
|
982
|
+
allowUnknown: true,
|
|
983
|
+
});
|
|
984
|
+
|
|
985
|
+
if (res_error) {
|
|
986
|
+
if (this.config.options.strictResponseCheck === true) {
|
|
987
|
+
return Promise.reject(new FDKResponseValidationError(res_error));
|
|
988
|
+
} else {
|
|
989
|
+
Logger({
|
|
990
|
+
level: "WARN",
|
|
991
|
+
message: `Response Validation Warnings for partner > Webhook > validateFilterConfiguration \n ${res_error}`,
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
return response;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
/**
|
|
1000
|
+
* @param {WebhookPartnerValidator.ValidateReducerConfigurationParam} arg -
|
|
1001
|
+
* Arg object.
|
|
1002
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
1003
|
+
* @param {import("../PartnerAPIClient").Options} - Options
|
|
1004
|
+
* @returns {Promise<WebhookPartnerModel.ReducerValidationResult>} - Success response
|
|
1005
|
+
* @name validateReducerConfiguration
|
|
1006
|
+
* @summary: Validate reducer configuration.
|
|
1007
|
+
* @description: Validate a reducer configuration against sample payload data.
|
|
1008
|
+
* - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/partner/webhook/validateReducerConfiguration/).
|
|
1009
|
+
*/
|
|
1010
|
+
async validateReducerConfiguration(
|
|
1011
|
+
{ extensionId, body, requestHeaders } = { requestHeaders: {} },
|
|
1012
|
+
{ responseHeaders } = { responseHeaders: false }
|
|
1013
|
+
) {
|
|
1014
|
+
const {
|
|
1015
|
+
error,
|
|
1016
|
+
} = WebhookPartnerValidator.validateReducerConfiguration().validate(
|
|
1017
|
+
{
|
|
1018
|
+
extensionId,
|
|
1019
|
+
body,
|
|
1020
|
+
},
|
|
1021
|
+
{ abortEarly: false, allowUnknown: true }
|
|
1022
|
+
);
|
|
1023
|
+
if (error) {
|
|
1024
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1028
|
+
const {
|
|
1029
|
+
error: warrning,
|
|
1030
|
+
} = WebhookPartnerValidator.validateReducerConfiguration().validate(
|
|
1031
|
+
{
|
|
1032
|
+
extensionId,
|
|
1033
|
+
body,
|
|
1034
|
+
},
|
|
1035
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1036
|
+
);
|
|
1037
|
+
if (warrning) {
|
|
1038
|
+
Logger({
|
|
1039
|
+
level: "WARN",
|
|
1040
|
+
message: `Parameter Validation warrnings for partner > Webhook > validateReducerConfiguration \n ${warrning}`,
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
const query_params = {};
|
|
1045
|
+
|
|
1046
|
+
const response = await PartnerAPIClient.execute(
|
|
1047
|
+
this.config,
|
|
1048
|
+
"post",
|
|
1049
|
+
`/service/partner/webhook/v1.0/organization/${this.config.organizationId}/extension/${extensionId}/validate/reducer`,
|
|
1050
|
+
query_params,
|
|
1051
|
+
body,
|
|
1052
|
+
requestHeaders,
|
|
1053
|
+
{ responseHeaders }
|
|
1054
|
+
);
|
|
1055
|
+
|
|
1056
|
+
let responseData = response;
|
|
1057
|
+
if (responseHeaders) {
|
|
1058
|
+
responseData = response[0];
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
const {
|
|
1062
|
+
error: res_error,
|
|
1063
|
+
} = WebhookPartnerModel.ReducerValidationResult().validate(responseData, {
|
|
1064
|
+
abortEarly: false,
|
|
1065
|
+
allowUnknown: true,
|
|
1066
|
+
});
|
|
1067
|
+
|
|
1068
|
+
if (res_error) {
|
|
1069
|
+
if (this.config.options.strictResponseCheck === true) {
|
|
1070
|
+
return Promise.reject(new FDKResponseValidationError(res_error));
|
|
1071
|
+
} else {
|
|
1072
|
+
Logger({
|
|
1073
|
+
level: "WARN",
|
|
1074
|
+
message: `Response Validation Warnings for partner > Webhook > validateReducerConfiguration \n ${res_error}`,
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
return response;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* @param {WebhookPartnerValidator.SaveFilterReducerConfigurationParam} arg
|
|
1084
|
+
* - Arg object.
|
|
1085
|
+
*
|
|
1086
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
1087
|
+
* @param {import("../PartnerAPIClient").Options} - Options
|
|
1088
|
+
* @returns {Promise<WebhookPartnerModel.FilterReducerSaveResult>} - Success response
|
|
1089
|
+
* @name saveFilterReducerConfiguration
|
|
1090
|
+
* @summary: Save filter or reducer configuration.
|
|
1091
|
+
* @description: Save filter and/or reducer configuration for a subscriber event mapping.
|
|
1092
|
+
* - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/partner/webhook/saveFilterReducerConfiguration/).
|
|
1093
|
+
*/
|
|
1094
|
+
async saveFilterReducerConfiguration(
|
|
1095
|
+
{ extensionId, companyId, subscriberId, body, requestHeaders } = {
|
|
1096
|
+
requestHeaders: {},
|
|
1097
|
+
},
|
|
1098
|
+
{ responseHeaders } = { responseHeaders: false }
|
|
1099
|
+
) {
|
|
1100
|
+
const {
|
|
1101
|
+
error,
|
|
1102
|
+
} = WebhookPartnerValidator.saveFilterReducerConfiguration().validate(
|
|
1103
|
+
{
|
|
1104
|
+
extensionId,
|
|
1105
|
+
companyId,
|
|
1106
|
+
subscriberId,
|
|
1107
|
+
body,
|
|
1108
|
+
},
|
|
1109
|
+
{ abortEarly: false, allowUnknown: true }
|
|
1110
|
+
);
|
|
1111
|
+
if (error) {
|
|
1112
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1116
|
+
const {
|
|
1117
|
+
error: warrning,
|
|
1118
|
+
} = WebhookPartnerValidator.saveFilterReducerConfiguration().validate(
|
|
1119
|
+
{
|
|
1120
|
+
extensionId,
|
|
1121
|
+
companyId,
|
|
1122
|
+
subscriberId,
|
|
1123
|
+
body,
|
|
1124
|
+
},
|
|
1125
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1126
|
+
);
|
|
1127
|
+
if (warrning) {
|
|
1128
|
+
Logger({
|
|
1129
|
+
level: "WARN",
|
|
1130
|
+
message: `Parameter Validation warrnings for partner > Webhook > saveFilterReducerConfiguration \n ${warrning}`,
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
const query_params = {};
|
|
1135
|
+
|
|
1136
|
+
const response = await PartnerAPIClient.execute(
|
|
1137
|
+
this.config,
|
|
1138
|
+
"put",
|
|
1139
|
+
`/service/partner/webhook/v1.0/organization/${this.config.organizationId}/extension/${extensionId}/company/${companyId}/subscriber/${subscriberId}/filter_reducer`,
|
|
1140
|
+
query_params,
|
|
1141
|
+
body,
|
|
1142
|
+
requestHeaders,
|
|
1143
|
+
{ responseHeaders }
|
|
1144
|
+
);
|
|
1145
|
+
|
|
1146
|
+
let responseData = response;
|
|
1147
|
+
if (responseHeaders) {
|
|
1148
|
+
responseData = response[0];
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
const {
|
|
1152
|
+
error: res_error,
|
|
1153
|
+
} = WebhookPartnerModel.FilterReducerSaveResult().validate(responseData, {
|
|
1154
|
+
abortEarly: false,
|
|
1155
|
+
allowUnknown: true,
|
|
1156
|
+
});
|
|
1157
|
+
|
|
1158
|
+
if (res_error) {
|
|
1159
|
+
if (this.config.options.strictResponseCheck === true) {
|
|
1160
|
+
return Promise.reject(new FDKResponseValidationError(res_error));
|
|
1161
|
+
} else {
|
|
1162
|
+
Logger({
|
|
1163
|
+
level: "WARN",
|
|
1164
|
+
message: `Response Validation Warnings for partner > Webhook > saveFilterReducerConfiguration \n ${res_error}`,
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
return response;
|
|
1170
|
+
}
|
|
837
1171
|
}
|
|
838
1172
|
module.exports = Webhook;
|