@gofynd/fdk-client-javascript 3.16.3 → 3.17.1
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 +1 -1
- package/sdk/application/ApplicationClient.d.ts +0 -2
- package/sdk/application/ApplicationClient.js +0 -2
- package/sdk/application/Cart/CartApplicationClient.d.ts +40 -0
- package/sdk/application/Cart/CartApplicationClient.js +176 -0
- package/sdk/application/Catalog/CatalogApplicationClient.d.ts +18 -4
- package/sdk/application/Catalog/CatalogApplicationClient.js +47 -4
- package/sdk/application/Content/ContentApplicationClient.d.ts +21 -1
- package/sdk/application/Content/ContentApplicationClient.js +93 -2
- package/sdk/application/Logistic/LogisticApplicationClient.d.ts +11 -21
- package/sdk/application/Logistic/LogisticApplicationClient.js +34 -83
- package/sdk/application/Order/OrderApplicationClient.d.ts +11 -0
- package/sdk/application/Order/OrderApplicationClient.js +50 -0
- package/sdk/application/Payment/PaymentApplicationClient.d.ts +5 -5
- package/sdk/application/Payment/PaymentApplicationClient.js +5 -4
- package/sdk/partner/Logistics/LogisticsPartnerClient.d.ts +84 -0
- package/sdk/partner/Logistics/LogisticsPartnerClient.js +712 -0
- package/sdk/partner/Logistics/LogisticsPartnerModel.d.ts +237 -1
- package/sdk/partner/Logistics/LogisticsPartnerModel.js +157 -0
- package/sdk/partner/Logistics/LogisticsPartnerValidator.d.ts +8 -0
- package/sdk/partner/Logistics/LogisticsPartnerValidator.js +70 -0
- package/sdk/platform/Cart/CartPlatformApplicationClient.d.ts +74 -12
- package/sdk/platform/Cart/CartPlatformApplicationClient.js +637 -36
- package/sdk/platform/Cart/CartPlatformApplicationValidator.d.ts +225 -1
- package/sdk/platform/Cart/CartPlatformApplicationValidator.js +147 -0
- package/sdk/platform/Cart/CartPlatformModel.d.ts +952 -5
- package/sdk/platform/Cart/CartPlatformModel.js +598 -2
- package/sdk/platform/Catalog/CatalogPlatformApplicationClient.d.ts +125 -5
- package/sdk/platform/Catalog/CatalogPlatformApplicationClient.js +831 -41
- package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.d.ts +205 -7
- package/sdk/platform/Catalog/CatalogPlatformApplicationValidator.js +154 -3
- package/sdk/platform/Catalog/CatalogPlatformClient.d.ts +5 -16
- package/sdk/platform/Catalog/CatalogPlatformClient.js +8 -85
- package/sdk/platform/Catalog/CatalogPlatformModel.d.ts +1025 -159
- package/sdk/platform/Catalog/CatalogPlatformModel.js +840 -165
- package/sdk/platform/Catalog/CatalogPlatformValidator.d.ts +8 -10
- package/sdk/platform/Catalog/CatalogPlatformValidator.js +3 -12
- package/sdk/platform/Common/CommonPlatformModel.d.ts +18 -1
- package/sdk/platform/Common/CommonPlatformModel.js +14 -0
- package/sdk/platform/Communication/CommunicationPlatformApplicationClient.d.ts +1 -73
- package/sdk/platform/Communication/CommunicationPlatformApplicationClient.js +4 -462
- package/sdk/platform/Communication/CommunicationPlatformApplicationValidator.d.ts +7 -45
- package/sdk/platform/Communication/CommunicationPlatformApplicationValidator.js +4 -55
- package/sdk/platform/Communication/CommunicationPlatformModel.d.ts +10 -2
- package/sdk/platform/Communication/CommunicationPlatformModel.js +3 -2
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.d.ts +14 -0
- package/sdk/platform/CompanyProfile/CompanyProfilePlatformModel.js +6 -0
- package/sdk/platform/Configuration/ConfigurationPlatformModel.d.ts +92 -1
- package/sdk/platform/Configuration/ConfigurationPlatformModel.js +54 -0
- package/sdk/platform/Discount/DiscountPlatformModel.d.ts +21 -0
- package/sdk/platform/Discount/DiscountPlatformModel.js +9 -0
- package/sdk/platform/Order/OrderPlatformClient.d.ts +27 -19
- package/sdk/platform/Order/OrderPlatformClient.js +176 -108
- package/sdk/platform/Order/OrderPlatformModel.d.ts +359 -45
- package/sdk/platform/Order/OrderPlatformModel.js +218 -44
- package/sdk/platform/Order/OrderPlatformValidator.d.ts +40 -43
- package/sdk/platform/Order/OrderPlatformValidator.js +35 -30
- package/sdk/platform/Payment/PaymentPlatformApplicationClient.d.ts +14 -3
- package/sdk/platform/Payment/PaymentPlatformApplicationClient.js +88 -6
- package/sdk/platform/Payment/PaymentPlatformApplicationValidator.d.ts +28 -3
- package/sdk/platform/Payment/PaymentPlatformApplicationValidator.js +22 -2
- package/sdk/platform/Payment/PaymentPlatformModel.d.ts +376 -11
- package/sdk/platform/Payment/PaymentPlatformModel.js +243 -10
- package/sdk/platform/PlatformApplicationClient.d.ts +0 -2
- package/sdk/platform/PlatformApplicationClient.js +0 -4
- package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationClient.d.ts +0 -13
- package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationClient.js +0 -82
- package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationValidator.d.ts +1 -10
- package/sdk/platform/Serviceability/ServiceabilityPlatformApplicationValidator.js +0 -12
- package/sdk/platform/Serviceability/ServiceabilityPlatformModel.d.ts +212 -28
- package/sdk/platform/Serviceability/ServiceabilityPlatformModel.js +133 -13
- package/sdk/platform/User/UserPlatformModel.d.ts +2 -2
- package/sdk/platform/User/UserPlatformModel.js +4 -4
- package/sdk/platform/Webhook/WebhookPlatformModel.d.ts +29 -0
- package/sdk/platform/Webhook/WebhookPlatformModel.js +13 -0
- package/sdk/platform/index.d.ts +0 -1
- package/sdk/platform/index.js +0 -2
- package/sdk/public/Configuration/ConfigurationPublicModel.d.ts +27 -1
- package/sdk/public/Configuration/ConfigurationPublicModel.js +19 -0
- package/sdk/public/Webhook/WebhookPublicModel.d.ts +29 -0
- package/sdk/public/Webhook/WebhookPublicModel.js +13 -0
- package/sdk/application/Rewards/RewardsApplicationClient.d.ts +0 -79
- package/sdk/application/Rewards/RewardsApplicationClient.js +0 -315
- package/sdk/platform/Rewards/RewardsPlatformApplicationClient.d.ts +0 -136
- package/sdk/platform/Rewards/RewardsPlatformApplicationClient.js +0 -976
- package/sdk/platform/Rewards/RewardsPlatformApplicationValidator.d.ts +0 -152
- package/sdk/platform/Rewards/RewardsPlatformApplicationValidator.js +0 -157
- package/sdk/platform/Rewards/RewardsPlatformModel.d.ts +0 -387
- package/sdk/platform/Rewards/RewardsPlatformModel.js +0 -410
|
@@ -263,15 +263,24 @@ class Cart {
|
|
|
263
263
|
* @description: Apply a coupon code to the customer's cart to trigger discounts on eligible items - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/applyCoupon/).
|
|
264
264
|
*/
|
|
265
265
|
async applyCoupon(
|
|
266
|
-
{
|
|
267
|
-
|
|
268
|
-
|
|
266
|
+
{
|
|
267
|
+
body,
|
|
268
|
+
xOrderingSource,
|
|
269
|
+
xAnonymousCart,
|
|
270
|
+
i,
|
|
271
|
+
b,
|
|
272
|
+
p,
|
|
273
|
+
id,
|
|
274
|
+
buyNow,
|
|
275
|
+
requestHeaders,
|
|
276
|
+
} = { requestHeaders: {} },
|
|
269
277
|
{ responseHeaders } = { responseHeaders: false }
|
|
270
278
|
) {
|
|
271
279
|
const { error } = CartPlatformApplicationValidator.applyCoupon().validate(
|
|
272
280
|
{
|
|
273
281
|
body,
|
|
274
282
|
xOrderingSource,
|
|
283
|
+
xAnonymousCart,
|
|
275
284
|
i,
|
|
276
285
|
b,
|
|
277
286
|
p,
|
|
@@ -291,6 +300,7 @@ class Cart {
|
|
|
291
300
|
{
|
|
292
301
|
body,
|
|
293
302
|
xOrderingSource,
|
|
303
|
+
xAnonymousCart,
|
|
294
304
|
i,
|
|
295
305
|
b,
|
|
296
306
|
p,
|
|
@@ -538,13 +548,16 @@ class Cart {
|
|
|
538
548
|
* @description: The checkout cart initiates the order creation process based on the selected address and payment method. It revalidates the cart details to ensure safe and seamless order placement. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/checkoutCart/).
|
|
539
549
|
*/
|
|
540
550
|
async checkoutCart(
|
|
541
|
-
{ body, xOrderingSource, requestHeaders } = {
|
|
551
|
+
{ body, xOrderingSource, xAnonymousCart, requestHeaders } = {
|
|
552
|
+
requestHeaders: {},
|
|
553
|
+
},
|
|
542
554
|
{ responseHeaders } = { responseHeaders: false }
|
|
543
555
|
) {
|
|
544
556
|
const { error } = CartPlatformApplicationValidator.checkoutCart().validate(
|
|
545
557
|
{
|
|
546
558
|
body,
|
|
547
559
|
xOrderingSource,
|
|
560
|
+
xAnonymousCart,
|
|
548
561
|
},
|
|
549
562
|
{ abortEarly: false, allowUnknown: true }
|
|
550
563
|
);
|
|
@@ -559,6 +572,7 @@ class Cart {
|
|
|
559
572
|
{
|
|
560
573
|
body,
|
|
561
574
|
xOrderingSource,
|
|
575
|
+
xAnonymousCart,
|
|
562
576
|
},
|
|
563
577
|
{ abortEarly: false, allowUnknown: false }
|
|
564
578
|
);
|
|
@@ -765,6 +779,83 @@ class Cart {
|
|
|
765
779
|
return response;
|
|
766
780
|
}
|
|
767
781
|
|
|
782
|
+
/**
|
|
783
|
+
* @param {CartPlatformApplicationValidator.CreateOfferParam} arg - Arg object
|
|
784
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
785
|
+
* @param {import("../PlatformAPIClient").Options} - Options
|
|
786
|
+
* @returns {Promise<CartPlatformModel.OfferSchema>} - Success response
|
|
787
|
+
* @name createOffer
|
|
788
|
+
* @summary: Create an offer
|
|
789
|
+
* @description: Creates a new offer based on the selected offer type. Sellers can choose from multiple supported offer types, including percentage value, fixed amount value, bundled discount, buy X get Y items, and more, along with customizable offer criteria to meet specific business requirements. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/createOffer/).
|
|
790
|
+
*/
|
|
791
|
+
async createOffer(
|
|
792
|
+
{ body, requestHeaders } = { requestHeaders: {} },
|
|
793
|
+
{ responseHeaders } = { responseHeaders: false }
|
|
794
|
+
) {
|
|
795
|
+
const { error } = CartPlatformApplicationValidator.createOffer().validate(
|
|
796
|
+
{
|
|
797
|
+
body,
|
|
798
|
+
},
|
|
799
|
+
{ abortEarly: false, allowUnknown: true }
|
|
800
|
+
);
|
|
801
|
+
if (error) {
|
|
802
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// Showing warrnings if extra unknown parameters are found
|
|
806
|
+
const {
|
|
807
|
+
error: warrning,
|
|
808
|
+
} = CartPlatformApplicationValidator.createOffer().validate(
|
|
809
|
+
{
|
|
810
|
+
body,
|
|
811
|
+
},
|
|
812
|
+
{ abortEarly: false, allowUnknown: false }
|
|
813
|
+
);
|
|
814
|
+
if (warrning) {
|
|
815
|
+
Logger({
|
|
816
|
+
level: "WARN",
|
|
817
|
+
message: `Parameter Validation warrnings for platform > Cart > createOffer \n ${warrning}`,
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
const query_params = {};
|
|
822
|
+
|
|
823
|
+
const response = await PlatformAPIClient.execute(
|
|
824
|
+
this.config,
|
|
825
|
+
"post",
|
|
826
|
+
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers`,
|
|
827
|
+
query_params,
|
|
828
|
+
body,
|
|
829
|
+
requestHeaders,
|
|
830
|
+
{ responseHeaders }
|
|
831
|
+
);
|
|
832
|
+
|
|
833
|
+
let responseData = response;
|
|
834
|
+
if (responseHeaders) {
|
|
835
|
+
responseData = response[0];
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
const {
|
|
839
|
+
error: res_error,
|
|
840
|
+
} = CartPlatformModel.OfferSchema().validate(responseData, {
|
|
841
|
+
abortEarly: false,
|
|
842
|
+
allowUnknown: true,
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
if (res_error) {
|
|
846
|
+
if (this.config.options.strictResponseCheck === true) {
|
|
847
|
+
return Promise.reject(new FDKResponseValidationError(res_error));
|
|
848
|
+
} else {
|
|
849
|
+
Logger({
|
|
850
|
+
level: "WARN",
|
|
851
|
+
message: `Response Validation Warnings for platform > Cart > createOffer \n ${res_error}`,
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
return response;
|
|
857
|
+
}
|
|
858
|
+
|
|
768
859
|
/**
|
|
769
860
|
* @param {CartPlatformApplicationValidator.CreatePromotionParam} arg - Arg object
|
|
770
861
|
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
@@ -1001,6 +1092,83 @@ class Cart {
|
|
|
1001
1092
|
return response;
|
|
1002
1093
|
}
|
|
1003
1094
|
|
|
1095
|
+
/**
|
|
1096
|
+
* @param {CartPlatformApplicationValidator.DeleteOfferParam} arg - Arg object
|
|
1097
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
1098
|
+
* @param {import("../PlatformAPIClient").Options} - Options
|
|
1099
|
+
* @returns {Promise<CartPlatformModel.SuccessMessage>} - Success response
|
|
1100
|
+
* @name deleteOffer
|
|
1101
|
+
* @summary: Delete draft offer
|
|
1102
|
+
* @description: Delete details of a draft offer by providing its unique identifier to delete information such as offer type, rules, validity period and other related information. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/deleteOffer/).
|
|
1103
|
+
*/
|
|
1104
|
+
async deleteOffer(
|
|
1105
|
+
{ id, requestHeaders } = { requestHeaders: {} },
|
|
1106
|
+
{ responseHeaders } = { responseHeaders: false }
|
|
1107
|
+
) {
|
|
1108
|
+
const { error } = CartPlatformApplicationValidator.deleteOffer().validate(
|
|
1109
|
+
{
|
|
1110
|
+
id,
|
|
1111
|
+
},
|
|
1112
|
+
{ abortEarly: false, allowUnknown: true }
|
|
1113
|
+
);
|
|
1114
|
+
if (error) {
|
|
1115
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
// Showing warrnings if extra unknown parameters are found
|
|
1119
|
+
const {
|
|
1120
|
+
error: warrning,
|
|
1121
|
+
} = CartPlatformApplicationValidator.deleteOffer().validate(
|
|
1122
|
+
{
|
|
1123
|
+
id,
|
|
1124
|
+
},
|
|
1125
|
+
{ abortEarly: false, allowUnknown: false }
|
|
1126
|
+
);
|
|
1127
|
+
if (warrning) {
|
|
1128
|
+
Logger({
|
|
1129
|
+
level: "WARN",
|
|
1130
|
+
message: `Parameter Validation warrnings for platform > Cart > deleteOffer \n ${warrning}`,
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
const query_params = {};
|
|
1135
|
+
|
|
1136
|
+
const response = await PlatformAPIClient.execute(
|
|
1137
|
+
this.config,
|
|
1138
|
+
"delete",
|
|
1139
|
+
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers/${id}`,
|
|
1140
|
+
query_params,
|
|
1141
|
+
undefined,
|
|
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
|
+
} = CartPlatformModel.SuccessMessage().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 platform > Cart > deleteOffer \n ${res_error}`,
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
return response;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1004
1172
|
/**
|
|
1005
1173
|
* @param {CartPlatformApplicationValidator.DeletePromotionParam} arg - Arg object
|
|
1006
1174
|
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
@@ -1836,6 +2004,7 @@ class Cart {
|
|
|
1836
2004
|
async getCart(
|
|
1837
2005
|
{
|
|
1838
2006
|
xOrderingSource,
|
|
2007
|
+
xAnonymousCart,
|
|
1839
2008
|
id,
|
|
1840
2009
|
userId,
|
|
1841
2010
|
orderType,
|
|
@@ -1850,6 +2019,7 @@ class Cart {
|
|
|
1850
2019
|
const { error } = CartPlatformApplicationValidator.getCart().validate(
|
|
1851
2020
|
{
|
|
1852
2021
|
xOrderingSource,
|
|
2022
|
+
xAnonymousCart,
|
|
1853
2023
|
id,
|
|
1854
2024
|
userId,
|
|
1855
2025
|
orderType,
|
|
@@ -1870,6 +2040,7 @@ class Cart {
|
|
|
1870
2040
|
} = CartPlatformApplicationValidator.getCart().validate(
|
|
1871
2041
|
{
|
|
1872
2042
|
xOrderingSource,
|
|
2043
|
+
xAnonymousCart,
|
|
1873
2044
|
id,
|
|
1874
2045
|
userId,
|
|
1875
2046
|
orderType,
|
|
@@ -2554,10 +2725,198 @@ class Cart {
|
|
|
2554
2725
|
{ id, buyNow, requestHeaders } = { requestHeaders: {} },
|
|
2555
2726
|
{ responseHeaders } = { responseHeaders: false }
|
|
2556
2727
|
) {
|
|
2557
|
-
const { error } = CartPlatformApplicationValidator.getItemCount().validate(
|
|
2728
|
+
const { error } = CartPlatformApplicationValidator.getItemCount().validate(
|
|
2729
|
+
{
|
|
2730
|
+
id,
|
|
2731
|
+
buyNow,
|
|
2732
|
+
},
|
|
2733
|
+
{ abortEarly: false, allowUnknown: true }
|
|
2734
|
+
);
|
|
2735
|
+
if (error) {
|
|
2736
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
2737
|
+
}
|
|
2738
|
+
|
|
2739
|
+
// Showing warrnings if extra unknown parameters are found
|
|
2740
|
+
const {
|
|
2741
|
+
error: warrning,
|
|
2742
|
+
} = CartPlatformApplicationValidator.getItemCount().validate(
|
|
2743
|
+
{
|
|
2744
|
+
id,
|
|
2745
|
+
buyNow,
|
|
2746
|
+
},
|
|
2747
|
+
{ abortEarly: false, allowUnknown: false }
|
|
2748
|
+
);
|
|
2749
|
+
if (warrning) {
|
|
2750
|
+
Logger({
|
|
2751
|
+
level: "WARN",
|
|
2752
|
+
message: `Parameter Validation warrnings for platform > Cart > getItemCount \n ${warrning}`,
|
|
2753
|
+
});
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
const query_params = {};
|
|
2757
|
+
query_params["id"] = id;
|
|
2758
|
+
query_params["buy_now"] = buyNow;
|
|
2759
|
+
|
|
2760
|
+
const response = await PlatformAPIClient.execute(
|
|
2761
|
+
this.config,
|
|
2762
|
+
"get",
|
|
2763
|
+
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/basic`,
|
|
2764
|
+
query_params,
|
|
2765
|
+
undefined,
|
|
2766
|
+
requestHeaders,
|
|
2767
|
+
{ responseHeaders }
|
|
2768
|
+
);
|
|
2769
|
+
|
|
2770
|
+
let responseData = response;
|
|
2771
|
+
if (responseHeaders) {
|
|
2772
|
+
responseData = response[0];
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
const {
|
|
2776
|
+
error: res_error,
|
|
2777
|
+
} = CartPlatformModel.CartItemCountResult().validate(responseData, {
|
|
2778
|
+
abortEarly: false,
|
|
2779
|
+
allowUnknown: true,
|
|
2780
|
+
});
|
|
2781
|
+
|
|
2782
|
+
if (res_error) {
|
|
2783
|
+
if (this.config.options.strictResponseCheck === true) {
|
|
2784
|
+
return Promise.reject(new FDKResponseValidationError(res_error));
|
|
2785
|
+
} else {
|
|
2786
|
+
Logger({
|
|
2787
|
+
level: "WARN",
|
|
2788
|
+
message: `Response Validation Warnings for platform > Cart > getItemCount \n ${res_error}`,
|
|
2789
|
+
});
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
return response;
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
/**
|
|
2797
|
+
* @param {CartPlatformApplicationValidator.GetOfferByIdParam} arg - Arg object
|
|
2798
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
2799
|
+
* @param {import("../PlatformAPIClient").Options} - Options
|
|
2800
|
+
* @returns {Promise<CartPlatformModel.OfferSchema>} - Success response
|
|
2801
|
+
* @name getOfferById
|
|
2802
|
+
* @summary: Get a specific offer
|
|
2803
|
+
* @description: Retrieve details of a specific offer by providing its unique identifier to obtain information such as offer type, rules, validity period and other related information. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/getOfferById/).
|
|
2804
|
+
*/
|
|
2805
|
+
async getOfferById(
|
|
2806
|
+
{ id, requestHeaders } = { requestHeaders: {} },
|
|
2807
|
+
{ responseHeaders } = { responseHeaders: false }
|
|
2808
|
+
) {
|
|
2809
|
+
const { error } = CartPlatformApplicationValidator.getOfferById().validate(
|
|
2810
|
+
{
|
|
2811
|
+
id,
|
|
2812
|
+
},
|
|
2813
|
+
{ abortEarly: false, allowUnknown: true }
|
|
2814
|
+
);
|
|
2815
|
+
if (error) {
|
|
2816
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
// Showing warrnings if extra unknown parameters are found
|
|
2820
|
+
const {
|
|
2821
|
+
error: warrning,
|
|
2822
|
+
} = CartPlatformApplicationValidator.getOfferById().validate(
|
|
2823
|
+
{
|
|
2824
|
+
id,
|
|
2825
|
+
},
|
|
2826
|
+
{ abortEarly: false, allowUnknown: false }
|
|
2827
|
+
);
|
|
2828
|
+
if (warrning) {
|
|
2829
|
+
Logger({
|
|
2830
|
+
level: "WARN",
|
|
2831
|
+
message: `Parameter Validation warrnings for platform > Cart > getOfferById \n ${warrning}`,
|
|
2832
|
+
});
|
|
2833
|
+
}
|
|
2834
|
+
|
|
2835
|
+
const query_params = {};
|
|
2836
|
+
|
|
2837
|
+
const response = await PlatformAPIClient.execute(
|
|
2838
|
+
this.config,
|
|
2839
|
+
"get",
|
|
2840
|
+
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers/${id}`,
|
|
2841
|
+
query_params,
|
|
2842
|
+
undefined,
|
|
2843
|
+
requestHeaders,
|
|
2844
|
+
{ responseHeaders }
|
|
2845
|
+
);
|
|
2846
|
+
|
|
2847
|
+
let responseData = response;
|
|
2848
|
+
if (responseHeaders) {
|
|
2849
|
+
responseData = response[0];
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2852
|
+
const {
|
|
2853
|
+
error: res_error,
|
|
2854
|
+
} = CartPlatformModel.OfferSchema().validate(responseData, {
|
|
2855
|
+
abortEarly: false,
|
|
2856
|
+
allowUnknown: true,
|
|
2857
|
+
});
|
|
2858
|
+
|
|
2859
|
+
if (res_error) {
|
|
2860
|
+
if (this.config.options.strictResponseCheck === true) {
|
|
2861
|
+
return Promise.reject(new FDKResponseValidationError(res_error));
|
|
2862
|
+
} else {
|
|
2863
|
+
Logger({
|
|
2864
|
+
level: "WARN",
|
|
2865
|
+
message: `Response Validation Warnings for platform > Cart > getOfferById \n ${res_error}`,
|
|
2866
|
+
});
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2870
|
+
return response;
|
|
2871
|
+
}
|
|
2872
|
+
|
|
2873
|
+
/**
|
|
2874
|
+
* @param {CartPlatformApplicationValidator.GetOffersParam} arg - Arg object
|
|
2875
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
2876
|
+
* @param {import("../PlatformAPIClient").Options} - Options
|
|
2877
|
+
* @returns {Promise<CartPlatformModel.OfferListResult>} - Success response
|
|
2878
|
+
* @name getOffers
|
|
2879
|
+
* @summary: List of offers
|
|
2880
|
+
* @description: Retrieve a list of all created offers for specific sales channel. It also supports efficient text search and pagination functionalities, ensuring optimized offers listing for streamlined navigation and management. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/getOffers/).
|
|
2881
|
+
*/
|
|
2882
|
+
async getOffers(
|
|
2883
|
+
{
|
|
2884
|
+
pageNo,
|
|
2885
|
+
pageSize,
|
|
2886
|
+
search,
|
|
2887
|
+
mode,
|
|
2888
|
+
type,
|
|
2889
|
+
promoGroup,
|
|
2890
|
+
excludeContractOffers,
|
|
2891
|
+
offerId,
|
|
2892
|
+
createdBy,
|
|
2893
|
+
reviewedBy,
|
|
2894
|
+
approvedStartTime,
|
|
2895
|
+
approvedEndTime,
|
|
2896
|
+
status,
|
|
2897
|
+
code,
|
|
2898
|
+
isPublic,
|
|
2899
|
+
requestHeaders,
|
|
2900
|
+
} = { requestHeaders: {} },
|
|
2901
|
+
{ responseHeaders } = { responseHeaders: false }
|
|
2902
|
+
) {
|
|
2903
|
+
const { error } = CartPlatformApplicationValidator.getOffers().validate(
|
|
2558
2904
|
{
|
|
2559
|
-
|
|
2560
|
-
|
|
2905
|
+
pageNo,
|
|
2906
|
+
pageSize,
|
|
2907
|
+
search,
|
|
2908
|
+
mode,
|
|
2909
|
+
type,
|
|
2910
|
+
promoGroup,
|
|
2911
|
+
excludeContractOffers,
|
|
2912
|
+
offerId,
|
|
2913
|
+
createdBy,
|
|
2914
|
+
reviewedBy,
|
|
2915
|
+
approvedStartTime,
|
|
2916
|
+
approvedEndTime,
|
|
2917
|
+
status,
|
|
2918
|
+
code,
|
|
2919
|
+
isPublic,
|
|
2561
2920
|
},
|
|
2562
2921
|
{ abortEarly: false, allowUnknown: true }
|
|
2563
2922
|
);
|
|
@@ -2568,28 +2927,54 @@ class Cart {
|
|
|
2568
2927
|
// Showing warrnings if extra unknown parameters are found
|
|
2569
2928
|
const {
|
|
2570
2929
|
error: warrning,
|
|
2571
|
-
} = CartPlatformApplicationValidator.
|
|
2930
|
+
} = CartPlatformApplicationValidator.getOffers().validate(
|
|
2572
2931
|
{
|
|
2573
|
-
|
|
2574
|
-
|
|
2932
|
+
pageNo,
|
|
2933
|
+
pageSize,
|
|
2934
|
+
search,
|
|
2935
|
+
mode,
|
|
2936
|
+
type,
|
|
2937
|
+
promoGroup,
|
|
2938
|
+
excludeContractOffers,
|
|
2939
|
+
offerId,
|
|
2940
|
+
createdBy,
|
|
2941
|
+
reviewedBy,
|
|
2942
|
+
approvedStartTime,
|
|
2943
|
+
approvedEndTime,
|
|
2944
|
+
status,
|
|
2945
|
+
code,
|
|
2946
|
+
isPublic,
|
|
2575
2947
|
},
|
|
2576
2948
|
{ abortEarly: false, allowUnknown: false }
|
|
2577
2949
|
);
|
|
2578
2950
|
if (warrning) {
|
|
2579
2951
|
Logger({
|
|
2580
2952
|
level: "WARN",
|
|
2581
|
-
message: `Parameter Validation warrnings for platform > Cart >
|
|
2953
|
+
message: `Parameter Validation warrnings for platform > Cart > getOffers \n ${warrning}`,
|
|
2582
2954
|
});
|
|
2583
2955
|
}
|
|
2584
2956
|
|
|
2585
2957
|
const query_params = {};
|
|
2586
|
-
query_params["
|
|
2587
|
-
query_params["
|
|
2958
|
+
query_params["page_no"] = pageNo;
|
|
2959
|
+
query_params["page_size"] = pageSize;
|
|
2960
|
+
query_params["search"] = search;
|
|
2961
|
+
query_params["mode"] = mode;
|
|
2962
|
+
query_params["type"] = type;
|
|
2963
|
+
query_params["promo_group"] = promoGroup;
|
|
2964
|
+
query_params["exclude_contract_offers"] = excludeContractOffers;
|
|
2965
|
+
query_params["offer_id"] = offerId;
|
|
2966
|
+
query_params["created_by"] = createdBy;
|
|
2967
|
+
query_params["reviewed_by"] = reviewedBy;
|
|
2968
|
+
query_params["approved_start_time"] = approvedStartTime;
|
|
2969
|
+
query_params["approved_end_time"] = approvedEndTime;
|
|
2970
|
+
query_params["status"] = status;
|
|
2971
|
+
query_params["code"] = code;
|
|
2972
|
+
query_params["is_public"] = isPublic;
|
|
2588
2973
|
|
|
2589
2974
|
const response = await PlatformAPIClient.execute(
|
|
2590
2975
|
this.config,
|
|
2591
2976
|
"get",
|
|
2592
|
-
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/
|
|
2977
|
+
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers`,
|
|
2593
2978
|
query_params,
|
|
2594
2979
|
undefined,
|
|
2595
2980
|
requestHeaders,
|
|
@@ -2603,7 +2988,7 @@ class Cart {
|
|
|
2603
2988
|
|
|
2604
2989
|
const {
|
|
2605
2990
|
error: res_error,
|
|
2606
|
-
} = CartPlatformModel.
|
|
2991
|
+
} = CartPlatformModel.OfferListResult().validate(responseData, {
|
|
2607
2992
|
abortEarly: false,
|
|
2608
2993
|
allowUnknown: true,
|
|
2609
2994
|
});
|
|
@@ -2614,7 +2999,7 @@ class Cart {
|
|
|
2614
2999
|
} else {
|
|
2615
3000
|
Logger({
|
|
2616
3001
|
level: "WARN",
|
|
2617
|
-
message: `Response Validation Warnings for platform > Cart >
|
|
3002
|
+
message: `Response Validation Warnings for platform > Cart > getOffers \n ${res_error}`,
|
|
2618
3003
|
});
|
|
2619
3004
|
}
|
|
2620
3005
|
}
|
|
@@ -3561,9 +3946,17 @@ class Cart {
|
|
|
3561
3946
|
* @description: Adds product items to a customer's shopping cart. If the customer does not have an existing cart, a new one is created automatically. - The `new_cart` flag forces creation of a new cart even if one already exists. - The `default_cart` flag determines whether the item is added to the user's default storefront-visible cart. If `true`, the item is added to the user's default cart that is accessible via the storefront. If `false`, an existing active cart is fetched if available; otherwise, a new hidden cart is created. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/platformAddItems/).
|
|
3562
3947
|
*/
|
|
3563
3948
|
async platformAddItems(
|
|
3564
|
-
{
|
|
3565
|
-
|
|
3566
|
-
|
|
3949
|
+
{
|
|
3950
|
+
body,
|
|
3951
|
+
xOrderingSource,
|
|
3952
|
+
xAnonymousCart,
|
|
3953
|
+
i,
|
|
3954
|
+
b,
|
|
3955
|
+
buyNow,
|
|
3956
|
+
orderType,
|
|
3957
|
+
id,
|
|
3958
|
+
requestHeaders,
|
|
3959
|
+
} = { requestHeaders: {} },
|
|
3567
3960
|
{ responseHeaders } = { responseHeaders: false }
|
|
3568
3961
|
) {
|
|
3569
3962
|
const {
|
|
@@ -3572,6 +3965,7 @@ class Cart {
|
|
|
3572
3965
|
{
|
|
3573
3966
|
body,
|
|
3574
3967
|
xOrderingSource,
|
|
3968
|
+
xAnonymousCart,
|
|
3575
3969
|
i,
|
|
3576
3970
|
b,
|
|
3577
3971
|
buyNow,
|
|
@@ -3591,6 +3985,7 @@ class Cart {
|
|
|
3591
3985
|
{
|
|
3592
3986
|
body,
|
|
3593
3987
|
xOrderingSource,
|
|
3988
|
+
xAnonymousCart,
|
|
3594
3989
|
i,
|
|
3595
3990
|
b,
|
|
3596
3991
|
buyNow,
|
|
@@ -3661,7 +4056,9 @@ class Cart {
|
|
|
3661
4056
|
* @description: The checkout cart initiates the order creation process based on the selected address and payment method. It revalidates the cart details to ensure safe and seamless order placement. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/platformCheckoutCart/).
|
|
3662
4057
|
*/
|
|
3663
4058
|
async platformCheckoutCart(
|
|
3664
|
-
{ body, xOrderingSource, id, requestHeaders } = {
|
|
4059
|
+
{ body, xOrderingSource, xAnonymousCart, id, requestHeaders } = {
|
|
4060
|
+
requestHeaders: {},
|
|
4061
|
+
},
|
|
3665
4062
|
{ responseHeaders } = { responseHeaders: false }
|
|
3666
4063
|
) {
|
|
3667
4064
|
const {
|
|
@@ -3670,6 +4067,7 @@ class Cart {
|
|
|
3670
4067
|
{
|
|
3671
4068
|
body,
|
|
3672
4069
|
xOrderingSource,
|
|
4070
|
+
xAnonymousCart,
|
|
3673
4071
|
id,
|
|
3674
4072
|
},
|
|
3675
4073
|
{ abortEarly: false, allowUnknown: true }
|
|
@@ -3685,6 +4083,7 @@ class Cart {
|
|
|
3685
4083
|
{
|
|
3686
4084
|
body,
|
|
3687
4085
|
xOrderingSource,
|
|
4086
|
+
xAnonymousCart,
|
|
3688
4087
|
id,
|
|
3689
4088
|
},
|
|
3690
4089
|
{ abortEarly: false, allowUnknown: false }
|
|
@@ -3831,9 +4230,17 @@ class Cart {
|
|
|
3831
4230
|
* @description: Customers can modify added product attributes such as quantity and size, as well as remove items from the cart. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/platformUpdateCart/).
|
|
3832
4231
|
*/
|
|
3833
4232
|
async platformUpdateCart(
|
|
3834
|
-
{
|
|
3835
|
-
|
|
3836
|
-
|
|
4233
|
+
{
|
|
4234
|
+
body,
|
|
4235
|
+
xOrderingSource,
|
|
4236
|
+
xAnonymousCart,
|
|
4237
|
+
id,
|
|
4238
|
+
i,
|
|
4239
|
+
orderType,
|
|
4240
|
+
b,
|
|
4241
|
+
buyNow,
|
|
4242
|
+
requestHeaders,
|
|
4243
|
+
} = { requestHeaders: {} },
|
|
3837
4244
|
{ responseHeaders } = { responseHeaders: false }
|
|
3838
4245
|
) {
|
|
3839
4246
|
const {
|
|
@@ -3842,6 +4249,7 @@ class Cart {
|
|
|
3842
4249
|
{
|
|
3843
4250
|
body,
|
|
3844
4251
|
xOrderingSource,
|
|
4252
|
+
xAnonymousCart,
|
|
3845
4253
|
id,
|
|
3846
4254
|
i,
|
|
3847
4255
|
orderType,
|
|
@@ -3861,6 +4269,7 @@ class Cart {
|
|
|
3861
4269
|
{
|
|
3862
4270
|
body,
|
|
3863
4271
|
xOrderingSource,
|
|
4272
|
+
xAnonymousCart,
|
|
3864
4273
|
id,
|
|
3865
4274
|
i,
|
|
3866
4275
|
orderType,
|
|
@@ -4009,12 +4418,15 @@ class Cart {
|
|
|
4009
4418
|
* @description: Remove an applied coupon from the customer's cart, thereby removing the associated discount from the cart total. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/removeCoupon/).
|
|
4010
4419
|
*/
|
|
4011
4420
|
async removeCoupon(
|
|
4012
|
-
{ xOrderingSource, uid, buyNow, requestHeaders } = {
|
|
4421
|
+
{ xOrderingSource, xAnonymousCart, uid, buyNow, requestHeaders } = {
|
|
4422
|
+
requestHeaders: {},
|
|
4423
|
+
},
|
|
4013
4424
|
{ responseHeaders } = { responseHeaders: false }
|
|
4014
4425
|
) {
|
|
4015
4426
|
const { error } = CartPlatformApplicationValidator.removeCoupon().validate(
|
|
4016
4427
|
{
|
|
4017
4428
|
xOrderingSource,
|
|
4429
|
+
xAnonymousCart,
|
|
4018
4430
|
uid,
|
|
4019
4431
|
buyNow,
|
|
4020
4432
|
},
|
|
@@ -4030,6 +4442,7 @@ class Cart {
|
|
|
4030
4442
|
} = CartPlatformApplicationValidator.removeCoupon().validate(
|
|
4031
4443
|
{
|
|
4032
4444
|
xOrderingSource,
|
|
4445
|
+
xAnonymousCart,
|
|
4033
4446
|
uid,
|
|
4034
4447
|
buyNow,
|
|
4035
4448
|
},
|
|
@@ -4173,15 +4586,23 @@ class Cart {
|
|
|
4173
4586
|
* @description: Select an address from the saved customer addresses and validates the availability of items in the cart. Additionally, it verifies and updates the delivery promise based on the selected address. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/selectAddress/).
|
|
4174
4587
|
*/
|
|
4175
4588
|
async selectAddress(
|
|
4176
|
-
{
|
|
4177
|
-
|
|
4178
|
-
|
|
4589
|
+
{
|
|
4590
|
+
body,
|
|
4591
|
+
xOrderingSource,
|
|
4592
|
+
xAnonymousCart,
|
|
4593
|
+
cartId,
|
|
4594
|
+
buyNow,
|
|
4595
|
+
i,
|
|
4596
|
+
b,
|
|
4597
|
+
requestHeaders,
|
|
4598
|
+
} = { requestHeaders: {} },
|
|
4179
4599
|
{ responseHeaders } = { responseHeaders: false }
|
|
4180
4600
|
) {
|
|
4181
4601
|
const { error } = CartPlatformApplicationValidator.selectAddress().validate(
|
|
4182
4602
|
{
|
|
4183
4603
|
body,
|
|
4184
4604
|
xOrderingSource,
|
|
4605
|
+
xAnonymousCart,
|
|
4185
4606
|
cartId,
|
|
4186
4607
|
buyNow,
|
|
4187
4608
|
i,
|
|
@@ -4200,6 +4621,7 @@ class Cart {
|
|
|
4200
4621
|
{
|
|
4201
4622
|
body,
|
|
4202
4623
|
xOrderingSource,
|
|
4624
|
+
xAnonymousCart,
|
|
4203
4625
|
cartId,
|
|
4204
4626
|
buyNow,
|
|
4205
4627
|
i,
|
|
@@ -4266,9 +4688,15 @@ class Cart {
|
|
|
4266
4688
|
* @description: Customers can select a preferred payment mode from available options during the cart checkout process to securely and efficiently complete their transaction. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/selectPaymentMode/).
|
|
4267
4689
|
*/
|
|
4268
4690
|
async selectPaymentMode(
|
|
4269
|
-
{
|
|
4270
|
-
|
|
4271
|
-
|
|
4691
|
+
{
|
|
4692
|
+
body,
|
|
4693
|
+
xOrderingSource,
|
|
4694
|
+
xAnonymousCart,
|
|
4695
|
+
id,
|
|
4696
|
+
buyNow,
|
|
4697
|
+
orderType,
|
|
4698
|
+
requestHeaders,
|
|
4699
|
+
} = { requestHeaders: {} },
|
|
4272
4700
|
{ responseHeaders } = { responseHeaders: false }
|
|
4273
4701
|
) {
|
|
4274
4702
|
const {
|
|
@@ -4277,6 +4705,7 @@ class Cart {
|
|
|
4277
4705
|
{
|
|
4278
4706
|
body,
|
|
4279
4707
|
xOrderingSource,
|
|
4708
|
+
xAnonymousCart,
|
|
4280
4709
|
id,
|
|
4281
4710
|
buyNow,
|
|
4282
4711
|
orderType,
|
|
@@ -4294,6 +4723,7 @@ class Cart {
|
|
|
4294
4723
|
{
|
|
4295
4724
|
body,
|
|
4296
4725
|
xOrderingSource,
|
|
4726
|
+
xAnonymousCart,
|
|
4297
4727
|
id,
|
|
4298
4728
|
buyNow,
|
|
4299
4729
|
orderType,
|
|
@@ -4605,15 +5035,22 @@ class Cart {
|
|
|
4605
5035
|
* @param {CartPlatformApplicationValidator.UpdateCartBreakupParam} arg - Arg object
|
|
4606
5036
|
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
4607
5037
|
* @param {import("../PlatformAPIClient").Options} - Options
|
|
4608
|
-
* @returns {Promise<CartPlatformModel.
|
|
5038
|
+
* @returns {Promise<CartPlatformModel.CartDetailResult>} - Success response
|
|
4609
5039
|
* @name updateCartBreakup
|
|
4610
5040
|
* @summary: Update cart breakup values
|
|
4611
|
-
* @description: Updates the cart breakup based on the enabled features and user preferences.
|
|
5041
|
+
* @description: Updates the cart breakup based on the enabled features and user preferences. This endpoint allows customers to modify how their cart totals are calculated — including options such as applying store credits, loyalty points, discounts, and other promotional benefits. The API recalculates and returns the updated breakup reflecting the selected configurations in real-time. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/updateCartBreakup/).
|
|
4612
5042
|
*/
|
|
4613
5043
|
async updateCartBreakup(
|
|
4614
|
-
{
|
|
4615
|
-
|
|
4616
|
-
|
|
5044
|
+
{
|
|
5045
|
+
body,
|
|
5046
|
+
xOrderingSource,
|
|
5047
|
+
xAnonymousCart,
|
|
5048
|
+
id,
|
|
5049
|
+
i,
|
|
5050
|
+
b,
|
|
5051
|
+
buyNow,
|
|
5052
|
+
requestHeaders,
|
|
5053
|
+
} = { requestHeaders: {} },
|
|
4617
5054
|
{ responseHeaders } = { responseHeaders: false }
|
|
4618
5055
|
) {
|
|
4619
5056
|
const {
|
|
@@ -4622,6 +5059,7 @@ class Cart {
|
|
|
4622
5059
|
{
|
|
4623
5060
|
body,
|
|
4624
5061
|
xOrderingSource,
|
|
5062
|
+
xAnonymousCart,
|
|
4625
5063
|
id,
|
|
4626
5064
|
i,
|
|
4627
5065
|
b,
|
|
@@ -4640,6 +5078,7 @@ class Cart {
|
|
|
4640
5078
|
{
|
|
4641
5079
|
body,
|
|
4642
5080
|
xOrderingSource,
|
|
5081
|
+
xAnonymousCart,
|
|
4643
5082
|
id,
|
|
4644
5083
|
i,
|
|
4645
5084
|
b,
|
|
@@ -4677,7 +5116,7 @@ class Cart {
|
|
|
4677
5116
|
|
|
4678
5117
|
const {
|
|
4679
5118
|
error: res_error,
|
|
4680
|
-
} = CartPlatformModel.
|
|
5119
|
+
} = CartPlatformModel.CartDetailResult().validate(responseData, {
|
|
4681
5120
|
abortEarly: false,
|
|
4682
5121
|
allowUnknown: true,
|
|
4683
5122
|
});
|
|
@@ -5194,6 +5633,168 @@ class Cart {
|
|
|
5194
5633
|
return response;
|
|
5195
5634
|
}
|
|
5196
5635
|
|
|
5636
|
+
/**
|
|
5637
|
+
* @param {CartPlatformApplicationValidator.UpdateOfferParam} arg - Arg object
|
|
5638
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
5639
|
+
* @param {import("../PlatformAPIClient").Options} - Options
|
|
5640
|
+
* @returns {Promise<CartPlatformModel.OfferSchema>} - Success response
|
|
5641
|
+
* @name updateOffer
|
|
5642
|
+
* @summary: Update existing offer
|
|
5643
|
+
* @description: Update the details of an existing offer by specifying its unique identifier. This includes modifying offer attributes such as discount percentage, validity period, and associated conditions. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/updateOffer/).
|
|
5644
|
+
*/
|
|
5645
|
+
async updateOffer(
|
|
5646
|
+
{ id, body, requestHeaders } = { requestHeaders: {} },
|
|
5647
|
+
{ responseHeaders } = { responseHeaders: false }
|
|
5648
|
+
) {
|
|
5649
|
+
const { error } = CartPlatformApplicationValidator.updateOffer().validate(
|
|
5650
|
+
{
|
|
5651
|
+
id,
|
|
5652
|
+
body,
|
|
5653
|
+
},
|
|
5654
|
+
{ abortEarly: false, allowUnknown: true }
|
|
5655
|
+
);
|
|
5656
|
+
if (error) {
|
|
5657
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
5658
|
+
}
|
|
5659
|
+
|
|
5660
|
+
// Showing warrnings if extra unknown parameters are found
|
|
5661
|
+
const {
|
|
5662
|
+
error: warrning,
|
|
5663
|
+
} = CartPlatformApplicationValidator.updateOffer().validate(
|
|
5664
|
+
{
|
|
5665
|
+
id,
|
|
5666
|
+
body,
|
|
5667
|
+
},
|
|
5668
|
+
{ abortEarly: false, allowUnknown: false }
|
|
5669
|
+
);
|
|
5670
|
+
if (warrning) {
|
|
5671
|
+
Logger({
|
|
5672
|
+
level: "WARN",
|
|
5673
|
+
message: `Parameter Validation warrnings for platform > Cart > updateOffer \n ${warrning}`,
|
|
5674
|
+
});
|
|
5675
|
+
}
|
|
5676
|
+
|
|
5677
|
+
const query_params = {};
|
|
5678
|
+
|
|
5679
|
+
const response = await PlatformAPIClient.execute(
|
|
5680
|
+
this.config,
|
|
5681
|
+
"put",
|
|
5682
|
+
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers/${id}`,
|
|
5683
|
+
query_params,
|
|
5684
|
+
body,
|
|
5685
|
+
requestHeaders,
|
|
5686
|
+
{ responseHeaders }
|
|
5687
|
+
);
|
|
5688
|
+
|
|
5689
|
+
let responseData = response;
|
|
5690
|
+
if (responseHeaders) {
|
|
5691
|
+
responseData = response[0];
|
|
5692
|
+
}
|
|
5693
|
+
|
|
5694
|
+
const {
|
|
5695
|
+
error: res_error,
|
|
5696
|
+
} = CartPlatformModel.OfferSchema().validate(responseData, {
|
|
5697
|
+
abortEarly: false,
|
|
5698
|
+
allowUnknown: true,
|
|
5699
|
+
});
|
|
5700
|
+
|
|
5701
|
+
if (res_error) {
|
|
5702
|
+
if (this.config.options.strictResponseCheck === true) {
|
|
5703
|
+
return Promise.reject(new FDKResponseValidationError(res_error));
|
|
5704
|
+
} else {
|
|
5705
|
+
Logger({
|
|
5706
|
+
level: "WARN",
|
|
5707
|
+
message: `Response Validation Warnings for platform > Cart > updateOffer \n ${res_error}`,
|
|
5708
|
+
});
|
|
5709
|
+
}
|
|
5710
|
+
}
|
|
5711
|
+
|
|
5712
|
+
return response;
|
|
5713
|
+
}
|
|
5714
|
+
|
|
5715
|
+
/**
|
|
5716
|
+
* @param {CartPlatformApplicationValidator.UpdateOfferPartiallyParam} arg
|
|
5717
|
+
* - Arg object
|
|
5718
|
+
*
|
|
5719
|
+
* @param {object} [arg.requestHeaders={}] - Request headers. Default is `{}`
|
|
5720
|
+
* @param {import("../PlatformAPIClient").Options} - Options
|
|
5721
|
+
* @returns {Promise<CartPlatformModel.SuccessMessage>} - Success response
|
|
5722
|
+
* @name updateOfferPartially
|
|
5723
|
+
* @summary: Partially update offer
|
|
5724
|
+
* @description: Seller can make partial adjustments of an existing offer by specifying its unique identifier. It enables businesses to modify specific attributes of the offer while preserving other details intact. - Check out [method documentation](https://docs.fynd.com/partners/commerce/sdk/platform/cart/updateOfferPartially/).
|
|
5725
|
+
*/
|
|
5726
|
+
async updateOfferPartially(
|
|
5727
|
+
{ id, body, requestHeaders } = { requestHeaders: {} },
|
|
5728
|
+
{ responseHeaders } = { responseHeaders: false }
|
|
5729
|
+
) {
|
|
5730
|
+
const {
|
|
5731
|
+
error,
|
|
5732
|
+
} = CartPlatformApplicationValidator.updateOfferPartially().validate(
|
|
5733
|
+
{
|
|
5734
|
+
id,
|
|
5735
|
+
body,
|
|
5736
|
+
},
|
|
5737
|
+
{ abortEarly: false, allowUnknown: true }
|
|
5738
|
+
);
|
|
5739
|
+
if (error) {
|
|
5740
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
5741
|
+
}
|
|
5742
|
+
|
|
5743
|
+
// Showing warrnings if extra unknown parameters are found
|
|
5744
|
+
const {
|
|
5745
|
+
error: warrning,
|
|
5746
|
+
} = CartPlatformApplicationValidator.updateOfferPartially().validate(
|
|
5747
|
+
{
|
|
5748
|
+
id,
|
|
5749
|
+
body,
|
|
5750
|
+
},
|
|
5751
|
+
{ abortEarly: false, allowUnknown: false }
|
|
5752
|
+
);
|
|
5753
|
+
if (warrning) {
|
|
5754
|
+
Logger({
|
|
5755
|
+
level: "WARN",
|
|
5756
|
+
message: `Parameter Validation warrnings for platform > Cart > updateOfferPartially \n ${warrning}`,
|
|
5757
|
+
});
|
|
5758
|
+
}
|
|
5759
|
+
|
|
5760
|
+
const query_params = {};
|
|
5761
|
+
|
|
5762
|
+
const response = await PlatformAPIClient.execute(
|
|
5763
|
+
this.config,
|
|
5764
|
+
"patch",
|
|
5765
|
+
`/service/platform/cart/v1.0/company/${this.config.companyId}/application/${this.applicationId}/offers/${id}`,
|
|
5766
|
+
query_params,
|
|
5767
|
+
body,
|
|
5768
|
+
requestHeaders,
|
|
5769
|
+
{ responseHeaders }
|
|
5770
|
+
);
|
|
5771
|
+
|
|
5772
|
+
let responseData = response;
|
|
5773
|
+
if (responseHeaders) {
|
|
5774
|
+
responseData = response[0];
|
|
5775
|
+
}
|
|
5776
|
+
|
|
5777
|
+
const {
|
|
5778
|
+
error: res_error,
|
|
5779
|
+
} = CartPlatformModel.SuccessMessage().validate(responseData, {
|
|
5780
|
+
abortEarly: false,
|
|
5781
|
+
allowUnknown: true,
|
|
5782
|
+
});
|
|
5783
|
+
|
|
5784
|
+
if (res_error) {
|
|
5785
|
+
if (this.config.options.strictResponseCheck === true) {
|
|
5786
|
+
return Promise.reject(new FDKResponseValidationError(res_error));
|
|
5787
|
+
} else {
|
|
5788
|
+
Logger({
|
|
5789
|
+
level: "WARN",
|
|
5790
|
+
message: `Response Validation Warnings for platform > Cart > updateOfferPartially \n ${res_error}`,
|
|
5791
|
+
});
|
|
5792
|
+
}
|
|
5793
|
+
}
|
|
5794
|
+
|
|
5795
|
+
return response;
|
|
5796
|
+
}
|
|
5797
|
+
|
|
5197
5798
|
/**
|
|
5198
5799
|
* @param {CartPlatformApplicationValidator.UpdatePriceAdjustmentParam} arg
|
|
5199
5800
|
* - Arg object
|