@gofynd/fdk-client-javascript 0.1.35
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/.github/workflows/on_create_release.yml +23 -0
- package/.github/workflows/on_merge_main.yml +38 -0
- package/.github/workflows/on_pull_request.yml +35 -0
- package/.prettierrc +5 -0
- package/LICENSE +21 -0
- package/README.md +118 -0
- package/application.d.ts +3 -0
- package/application.js +6 -0
- package/common.d.ts +4 -0
- package/common.js +9 -0
- package/documentation/application/CART.md +7290 -0
- package/documentation/application/CATALOG.md +9570 -0
- package/documentation/application/COMMON.md +448 -0
- package/documentation/application/COMMUNICATION.md +463 -0
- package/documentation/application/CONFIGURATION.md +2902 -0
- package/documentation/application/CONTENT.md +3350 -0
- package/documentation/application/FILESTORAGE.md +491 -0
- package/documentation/application/LEAD.md +1891 -0
- package/documentation/application/LOGISTIC.md +439 -0
- package/documentation/application/ORDER.md +3428 -0
- package/documentation/application/PAYMENT.md +5035 -0
- package/documentation/application/POSCART.md +7889 -0
- package/documentation/application/README.md +21 -0
- package/documentation/application/REWARDS.md +714 -0
- package/documentation/application/SHARE.md +729 -0
- package/documentation/application/THEME.md +5796 -0
- package/documentation/application/USER.md +4326 -0
- package/documentation/platform/ANALYTICS.md +1150 -0
- package/documentation/platform/AUDITTRAIL.md +572 -0
- package/documentation/platform/BILLING.md +2396 -0
- package/documentation/platform/CART.md +5539 -0
- package/documentation/platform/CATALOG.md +21624 -0
- package/documentation/platform/COMMON.md +448 -0
- package/documentation/platform/COMMUNICATION.md +5714 -0
- package/documentation/platform/COMPANYPROFILE.md +2141 -0
- package/documentation/platform/CONFIGURATION.md +7335 -0
- package/documentation/platform/CONTENT.md +8989 -0
- package/documentation/platform/DISCOUNT.md +773 -0
- package/documentation/platform/FILESTORAGE.md +994 -0
- package/documentation/platform/INVENTORY.md +1775 -0
- package/documentation/platform/LEAD.md +4736 -0
- package/documentation/platform/ORDER.md +3764 -0
- package/documentation/platform/PARTNER.md +216 -0
- package/documentation/platform/PAYMENT.md +3444 -0
- package/documentation/platform/README.md +27 -0
- package/documentation/platform/REWARDS.md +871 -0
- package/documentation/platform/SHARE.md +602 -0
- package/documentation/platform/THEME.md +35725 -0
- package/documentation/platform/USER.md +2305 -0
- package/documentation/platform/WEBHOOK.md +587 -0
- package/documentation/public/CONFIGURATION.md +448 -0
- package/documentation/public/INVENTORY.md +686 -0
- package/documentation/public/WEBHOOK.md +348 -0
- package/index.d.ts +10 -0
- package/index.js +18 -0
- package/jest.config.d.ts +4 -0
- package/jest.config.js +6 -0
- package/package.json +35 -0
- package/platform.d.ts +3 -0
- package/platform.js +6 -0
- package/public.d.ts +3 -0
- package/public.js +6 -0
- package/sdk/application/ApplicationAPIClient.d.ts +11 -0
- package/sdk/application/ApplicationAPIClient.js +44 -0
- package/sdk/application/ApplicationClient.d.ts +40 -0
- package/sdk/application/ApplicationClient.js +84 -0
- package/sdk/application/ApplicationConfig.d.ts +19 -0
- package/sdk/application/ApplicationConfig.js +55 -0
- package/sdk/application/ApplicationModels.d.ts +826 -0
- package/sdk/application/ApplicationModels.js +10474 -0
- package/sdk/application/client/CartApplicationClient.d.ts +432 -0
- package/sdk/application/client/CartApplicationClient.js +1066 -0
- package/sdk/application/client/CatalogApplicationClient.d.ts +694 -0
- package/sdk/application/client/CatalogApplicationClient.js +1629 -0
- package/sdk/application/client/CommonApplicationClient.d.ts +38 -0
- package/sdk/application/client/CommonApplicationClient.js +105 -0
- package/sdk/application/client/CommunicationApplicationClient.d.ts +39 -0
- package/sdk/application/client/CommunicationApplicationClient.js +131 -0
- package/sdk/application/client/ConfigurationApplicationClient.d.ts +210 -0
- package/sdk/application/client/ConfigurationApplicationClient.js +649 -0
- package/sdk/application/client/ContentApplicationClient.d.ts +256 -0
- package/sdk/application/client/ContentApplicationClient.js +785 -0
- package/sdk/application/client/FileStorageApplicationClient.d.ts +88 -0
- package/sdk/application/client/FileStorageApplicationClient.js +214 -0
- package/sdk/application/client/LeadApplicationClient.d.ts +90 -0
- package/sdk/application/client/LeadApplicationClient.js +264 -0
- package/sdk/application/client/LogisticApplicationClient.d.ts +42 -0
- package/sdk/application/client/LogisticApplicationClient.js +128 -0
- package/sdk/application/client/OrderApplicationClient.d.ts +190 -0
- package/sdk/application/client/OrderApplicationClient.js +479 -0
- package/sdk/application/client/PaymentApplicationClient.d.ts +454 -0
- package/sdk/application/client/PaymentApplicationClient.js +1378 -0
- package/sdk/application/client/PosCartApplicationClient.d.ts +449 -0
- package/sdk/application/client/PosCartApplicationClient.js +1123 -0
- package/sdk/application/client/RewardsApplicationClient.d.ts +93 -0
- package/sdk/application/client/RewardsApplicationClient.js +293 -0
- package/sdk/application/client/ShareApplicationClient.d.ts +87 -0
- package/sdk/application/client/ShareApplicationClient.js +268 -0
- package/sdk/application/client/ThemeApplicationClient.d.ts +52 -0
- package/sdk/application/client/ThemeApplicationClient.js +161 -0
- package/sdk/application/client/UserApplicationClient.d.ts +446 -0
- package/sdk/application/client/UserApplicationClient.js +1275 -0
- package/sdk/application/constructUrl.d.ts +5 -0
- package/sdk/application/constructUrl.js +13 -0
- package/sdk/application/index.d.ts +2 -0
- package/sdk/application/index.js +4 -0
- package/sdk/application/models/CartValidator.d.ts +29 -0
- package/sdk/application/models/CartValidator.js +223 -0
- package/sdk/application/models/CatalogValidator.d.ts +33 -0
- package/sdk/application/models/CatalogValidator.js +233 -0
- package/sdk/application/models/CommonValidator.d.ts +5 -0
- package/sdk/application/models/CommonValidator.js +18 -0
- package/sdk/application/models/CommunicationValidator.d.ts +6 -0
- package/sdk/application/models/CommunicationValidator.js +20 -0
- package/sdk/application/models/ConfigurationValidator.d.ts +19 -0
- package/sdk/application/models/ConfigurationValidator.js +88 -0
- package/sdk/application/models/ContentValidator.d.ts +22 -0
- package/sdk/application/models/ContentValidator.js +106 -0
- package/sdk/application/models/FileStorageValidator.d.ts +6 -0
- package/sdk/application/models/FileStorageValidator.js +24 -0
- package/sdk/application/models/LeadValidator.d.ts +10 -0
- package/sdk/application/models/LeadValidator.js +48 -0
- package/sdk/application/models/LogisticValidator.d.ts +6 -0
- package/sdk/application/models/LogisticValidator.js +22 -0
- package/sdk/application/models/OrderValidator.d.ts +15 -0
- package/sdk/application/models/OrderValidator.js +87 -0
- package/sdk/application/models/PaymentValidator.d.ts +40 -0
- package/sdk/application/models/PaymentValidator.js +235 -0
- package/sdk/application/models/PosCartValidator.d.ts +30 -0
- package/sdk/application/models/PosCartValidator.js +232 -0
- package/sdk/application/models/RewardsValidator.d.ts +10 -0
- package/sdk/application/models/RewardsValidator.js +43 -0
- package/sdk/application/models/ShareValidator.d.ts +10 -0
- package/sdk/application/models/ShareValidator.js +44 -0
- package/sdk/application/models/ThemeValidator.d.ts +7 -0
- package/sdk/application/models/ThemeValidator.js +27 -0
- package/sdk/application/models/UserValidator.d.ts +38 -0
- package/sdk/application/models/UserValidator.js +233 -0
- package/sdk/common/AxiosHelper.d.ts +1 -0
- package/sdk/common/AxiosHelper.js +141 -0
- package/sdk/common/Constant.d.ts +294 -0
- package/sdk/common/Constant.js +332 -0
- package/sdk/common/FDKError.d.ts +26 -0
- package/sdk/common/FDKError.js +51 -0
- package/sdk/common/Logger.d.ts +2 -0
- package/sdk/common/Logger.js +85 -0
- package/sdk/common/Paginator.d.ts +16 -0
- package/sdk/common/Paginator.js +26 -0
- package/sdk/common/RequestSigner.d.ts +1 -0
- package/sdk/common/RequestSigner.js +306 -0
- package/sdk/common/Utility.d.ts +9 -0
- package/sdk/common/Utility.js +86 -0
- package/sdk/common/utils.d.ts +14 -0
- package/sdk/common/utils.js +165 -0
- package/sdk/platform/OAuthClient.d.ts +26 -0
- package/sdk/platform/OAuthClient.js +221 -0
- package/sdk/platform/PlatformAPIClient.d.ts +12 -0
- package/sdk/platform/PlatformAPIClient.js +43 -0
- package/sdk/platform/PlatformApplicationClient.d.ts +24398 -0
- package/sdk/platform/PlatformApplicationClient.js +23185 -0
- package/sdk/platform/PlatformApplicationModels.d.ts +333 -0
- package/sdk/platform/PlatformApplicationModels.js +21262 -0
- package/sdk/platform/PlatformClient.d.ts +9535 -0
- package/sdk/platform/PlatformClient.js +12336 -0
- package/sdk/platform/PlatformConfig.d.ts +29 -0
- package/sdk/platform/PlatformConfig.js +36 -0
- package/sdk/platform/PlatformModels.d.ts +1396 -0
- package/sdk/platform/PlatformModels.js +19222 -0
- package/sdk/platform/client/AnalyticsPlatformClient.d.ts +84 -0
- package/sdk/platform/client/AnalyticsPlatformClient.js +215 -0
- package/sdk/platform/client/AuditTrailPlatformClient.d.ts +38 -0
- package/sdk/platform/client/AuditTrailPlatformClient.js +133 -0
- package/sdk/platform/client/BillingPlatformClient.d.ts +109 -0
- package/sdk/platform/client/BillingPlatformClient.js +381 -0
- package/sdk/platform/client/CatalogPlatformClient.d.ts +806 -0
- package/sdk/platform/client/CatalogPlatformClient.js +2462 -0
- package/sdk/platform/client/CommonPlatformClient.d.ts +30 -0
- package/sdk/platform/client/CommonPlatformClient.js +84 -0
- package/sdk/platform/client/CommunicationPlatformClient.d.ts +26 -0
- package/sdk/platform/client/CommunicationPlatformClient.js +72 -0
- package/sdk/platform/client/CompanyProfilePlatformClient.d.ts +182 -0
- package/sdk/platform/client/CompanyProfilePlatformClient.js +540 -0
- package/sdk/platform/client/ConfigurationPlatformClient.d.ts +277 -0
- package/sdk/platform/client/ConfigurationPlatformClient.js +806 -0
- package/sdk/platform/client/DiscountPlatformClient.d.ts +118 -0
- package/sdk/platform/client/DiscountPlatformClient.js +364 -0
- package/sdk/platform/client/FileStoragePlatformClient.d.ts +111 -0
- package/sdk/platform/client/FileStoragePlatformClient.js +268 -0
- package/sdk/platform/client/InventoryPlatformClient.d.ts +125 -0
- package/sdk/platform/client/InventoryPlatformClient.js +409 -0
- package/sdk/platform/client/LeadPlatformClient.d.ts +150 -0
- package/sdk/platform/client/LeadPlatformClient.js +439 -0
- package/sdk/platform/client/OrderPlatformClient.d.ts +190 -0
- package/sdk/platform/client/OrderPlatformClient.js +521 -0
- package/sdk/platform/client/PaymentPlatformClient.d.ts +98 -0
- package/sdk/platform/client/PaymentPlatformClient.js +331 -0
- package/sdk/platform/client/WebhookPlatformClient.d.ts +64 -0
- package/sdk/platform/client/WebhookPlatformClient.js +207 -0
- package/sdk/platform/index.d.ts +2 -0
- package/sdk/platform/index.js +4 -0
- package/sdk/platform/models/AnalyticsValidator.d.ts +7 -0
- package/sdk/platform/models/AnalyticsValidator.js +36 -0
- package/sdk/platform/models/AuditTrailValidator.d.ts +7 -0
- package/sdk/platform/models/AuditTrailValidator.js +26 -0
- package/sdk/platform/models/BillingValidator.d.ts +15 -0
- package/sdk/platform/models/BillingValidator.js +72 -0
- package/sdk/platform/models/CartValidator.d.ts +0 -0
- package/sdk/platform/models/CartValidator.js +0 -0
- package/sdk/platform/models/CatalogValidator.d.ts +74 -0
- package/sdk/platform/models/CatalogValidator.js +484 -0
- package/sdk/platform/models/CommonValidator.d.ts +5 -0
- package/sdk/platform/models/CommonValidator.js +18 -0
- package/sdk/platform/models/CommunicationValidator.d.ts +4 -0
- package/sdk/platform/models/CommunicationValidator.js +11 -0
- package/sdk/platform/models/CompanyProfileValidator.d.ts +17 -0
- package/sdk/platform/models/CompanyProfileValidator.js +93 -0
- package/sdk/platform/models/ConfigurationValidator.d.ts +21 -0
- package/sdk/platform/models/ConfigurationValidator.js +134 -0
- package/sdk/platform/models/ContentValidator.d.ts +0 -0
- package/sdk/platform/models/ContentValidator.js +0 -0
- package/sdk/platform/models/DiscountValidator.d.ts +13 -0
- package/sdk/platform/models/DiscountValidator.js +75 -0
- package/sdk/platform/models/FileStorageValidator.d.ts +9 -0
- package/sdk/platform/models/FileStorageValidator.js +44 -0
- package/sdk/platform/models/InventoryValidator.d.ts +15 -0
- package/sdk/platform/models/InventoryValidator.js +81 -0
- package/sdk/platform/models/LeadValidator.d.ts +14 -0
- package/sdk/platform/models/LeadValidator.js +78 -0
- package/sdk/platform/models/OrderValidator.d.ts +14 -0
- package/sdk/platform/models/OrderValidator.js +110 -0
- package/sdk/platform/models/PartnerValidator.d.ts +0 -0
- package/sdk/platform/models/PartnerValidator.js +0 -0
- package/sdk/platform/models/PaymentValidator.d.ts +13 -0
- package/sdk/platform/models/PaymentValidator.js +65 -0
- package/sdk/platform/models/RewardsValidator.d.ts +0 -0
- package/sdk/platform/models/RewardsValidator.js +0 -0
- package/sdk/platform/models/ShareValidator.d.ts +0 -0
- package/sdk/platform/models/ShareValidator.js +0 -0
- package/sdk/platform/models/ThemeValidator.d.ts +0 -0
- package/sdk/platform/models/ThemeValidator.js +0 -0
- package/sdk/platform/models/UserValidator.d.ts +0 -0
- package/sdk/platform/models/UserValidator.js +0 -0
- package/sdk/platform/models/WebhookValidator.d.ts +9 -0
- package/sdk/platform/models/WebhookValidator.js +42 -0
- package/sdk/public/PublicAPIClient.d.ts +11 -0
- package/sdk/public/PublicAPIClient.js +38 -0
- package/sdk/public/PublicClient.d.ts +12 -0
- package/sdk/public/PublicClient.js +24 -0
- package/sdk/public/PublicConfig.d.ts +10 -0
- package/sdk/public/PublicConfig.js +12 -0
- package/sdk/public/PublicModels.d.ts +50 -0
- package/sdk/public/PublicModels.js +712 -0
- package/sdk/public/client/ConfigurationPublicClient.d.ts +38 -0
- package/sdk/public/client/ConfigurationPublicClient.js +102 -0
- package/sdk/public/client/InventoryPublicClient.d.ts +81 -0
- package/sdk/public/client/InventoryPublicClient.js +239 -0
- package/sdk/public/client/WebhookPublicClient.d.ts +28 -0
- package/sdk/public/client/WebhookPublicClient.js +92 -0
- package/sdk/public/constructUrl.d.ts +5 -0
- package/sdk/public/constructUrl.js +13 -0
- package/sdk/public/index.d.ts +2 -0
- package/sdk/public/index.js +4 -0
- package/sdk/public/models/ConfigurationValidator.d.ts +5 -0
- package/sdk/public/models/ConfigurationValidator.js +18 -0
- package/sdk/public/models/InventoryValidator.d.ts +9 -0
- package/sdk/public/models/InventoryValidator.js +43 -0
- package/sdk/public/models/WebhookValidator.d.ts +5 -0
- package/sdk/public/models/WebhookValidator.js +14 -0
- package/tests/application/catalog.spec.js +47 -0
- package/tests/common/action-url.spec.js +35 -0
- package/tests/common/schema/action-url.json +163 -0
- package/tests/common/schema/url-action.json +667 -0
- package/tests/common/url-action.spec.js +48 -0
- package/tests/helpers/cookie.helper.js +31 -0
- package/tests/helpers/oauth.helper.js +43 -0
- package/tests/platform/catalog.spec.js +49 -0
- package/tests/public/location.spec.js +39 -0
|
@@ -0,0 +1,1123 @@
|
|
|
1
|
+
const APIClient = require("../ApplicationAPIClient");
|
|
2
|
+
const Paginator = require("../../common/Paginator");
|
|
3
|
+
const constructUrl = require("../constructUrl");
|
|
4
|
+
const { FDKClientValidationError } = require("../../common/FDKError");
|
|
5
|
+
const PosCartValidator = require("../models/PosCartValidator");
|
|
6
|
+
|
|
7
|
+
class PosCart {
|
|
8
|
+
constructor(_conf) {
|
|
9
|
+
this._conf = _conf;
|
|
10
|
+
this._relativeUrls = {
|
|
11
|
+
getCart: "/service/application/pos/cart/v1.0/detail",
|
|
12
|
+
getCartLastModified: "/service/application/pos/cart/v1.0/detail",
|
|
13
|
+
addItems: "/service/application/pos/cart/v1.0/detail",
|
|
14
|
+
updateCart: "/service/application/pos/cart/v1.0/detail",
|
|
15
|
+
getItemCount: "/service/application/pos/cart/v1.0/basic",
|
|
16
|
+
getCoupons: "/service/application/pos/cart/v1.0/coupon",
|
|
17
|
+
applyCoupon: "/service/application/pos/cart/v1.0/coupon",
|
|
18
|
+
removeCoupon: "/service/application/pos/cart/v1.0/coupon",
|
|
19
|
+
getBulkDiscountOffers: "/service/application/pos/cart/v1.0/bulk-price",
|
|
20
|
+
applyRewardPoints: "/service/application/pos/cart/v1.0/redeem/points/",
|
|
21
|
+
getAddresses: "/service/application/pos/cart/v1.0/address",
|
|
22
|
+
addAddress: "/service/application/pos/cart/v1.0/address",
|
|
23
|
+
getAddressById: "/service/application/pos/cart/v1.0/address/{id}",
|
|
24
|
+
updateAddress: "/service/application/pos/cart/v1.0/address/{id}",
|
|
25
|
+
removeAddress: "/service/application/pos/cart/v1.0/address/{id}",
|
|
26
|
+
selectAddress: "/service/application/pos/cart/v1.0/select-address",
|
|
27
|
+
selectPaymentMode: "/service/application/pos/cart/v1.0/payment",
|
|
28
|
+
validateCouponForPayment:
|
|
29
|
+
"/service/application/pos/cart/v1.0/payment/validate/",
|
|
30
|
+
getShipments: "/service/application/pos/cart/v1.0/shipment",
|
|
31
|
+
updateShipments: "/service/application/pos/cart/v1.0/shipment",
|
|
32
|
+
checkoutCart: "/service/application/pos/cart/v1.0/checkout",
|
|
33
|
+
updateCartMeta: "/service/application/pos/cart/v1.0/meta",
|
|
34
|
+
getAvailableDeliveryModes:
|
|
35
|
+
"/service/application/pos/cart/v1.0/available-delivery-mode",
|
|
36
|
+
getStoreAddressByUid: "/service/application/pos/cart/v1.0/store-address",
|
|
37
|
+
getCartShareLink: "/service/application/pos/cart/v1.0/share-cart",
|
|
38
|
+
getCartSharedItems:
|
|
39
|
+
"/service/application/pos/cart/v1.0/share-cart/{token}",
|
|
40
|
+
updateCartWithSharedItems:
|
|
41
|
+
"/service/application/pos/cart/v1.0/share-cart/{token}/{action}",
|
|
42
|
+
};
|
|
43
|
+
this._urls = Object.entries(this._relativeUrls).reduce(
|
|
44
|
+
(urls, [method, relativeUrl]) => {
|
|
45
|
+
urls[method] = `${_conf.domain}${relativeUrl}`;
|
|
46
|
+
return urls;
|
|
47
|
+
},
|
|
48
|
+
{}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
updateUrls(urls) {
|
|
53
|
+
this._urls = {
|
|
54
|
+
...this._urls,
|
|
55
|
+
...urls,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @param {Object} arg - Arg object.
|
|
61
|
+
* @param {string} [arg.id] -
|
|
62
|
+
* @param {boolean} [arg.i] -
|
|
63
|
+
* @param {boolean} [arg.b] -
|
|
64
|
+
* @param {number} [arg.assignCardId] -
|
|
65
|
+
* @param {boolean} [arg.buyNow] -
|
|
66
|
+
* @returns {Promise<CartDetailResponse>} - Success response
|
|
67
|
+
* @summary: Fetch all items added to the cart
|
|
68
|
+
* @description: Use this API to get details of all the items added to a cart.
|
|
69
|
+
*/
|
|
70
|
+
getCart({ id, i, b, assignCardId, buyNow } = {}) {
|
|
71
|
+
const { error } = PosCartValidator.getCart().validate(
|
|
72
|
+
{ id, i, b, assignCardId, buyNow },
|
|
73
|
+
{ abortEarly: false, allowUnknown: true }
|
|
74
|
+
);
|
|
75
|
+
if (error) {
|
|
76
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
77
|
+
}
|
|
78
|
+
const query_params = {};
|
|
79
|
+
query_params["id"] = id;
|
|
80
|
+
query_params["i"] = i;
|
|
81
|
+
query_params["b"] = b;
|
|
82
|
+
query_params["assign_card_id"] = assignCardId;
|
|
83
|
+
query_params["buy_now"] = buyNow;
|
|
84
|
+
|
|
85
|
+
const xHeaders = {};
|
|
86
|
+
|
|
87
|
+
return APIClient.execute(
|
|
88
|
+
this._conf,
|
|
89
|
+
"get",
|
|
90
|
+
constructUrl({
|
|
91
|
+
url: this._urls["getCart"],
|
|
92
|
+
params: {},
|
|
93
|
+
}),
|
|
94
|
+
query_params,
|
|
95
|
+
undefined,
|
|
96
|
+
xHeaders
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param {Object} arg - Arg object.
|
|
102
|
+
* @param {string} [arg.id] -
|
|
103
|
+
* @returns {Promise<any>} - Success response
|
|
104
|
+
* @summary: Fetch last-modified timestamp
|
|
105
|
+
* @description: Use this API to fetch Last-Modified timestamp in header metadata.
|
|
106
|
+
*/
|
|
107
|
+
getCartLastModified({ id } = {}) {
|
|
108
|
+
const { error } = PosCartValidator.getCartLastModified().validate(
|
|
109
|
+
{ id },
|
|
110
|
+
{ abortEarly: false, allowUnknown: true }
|
|
111
|
+
);
|
|
112
|
+
if (error) {
|
|
113
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
114
|
+
}
|
|
115
|
+
const query_params = {};
|
|
116
|
+
query_params["id"] = id;
|
|
117
|
+
|
|
118
|
+
const xHeaders = {};
|
|
119
|
+
|
|
120
|
+
return APIClient.execute(
|
|
121
|
+
this._conf,
|
|
122
|
+
"head",
|
|
123
|
+
constructUrl({
|
|
124
|
+
url: this._urls["getCartLastModified"],
|
|
125
|
+
params: {},
|
|
126
|
+
}),
|
|
127
|
+
query_params,
|
|
128
|
+
undefined,
|
|
129
|
+
xHeaders
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @param {Object} arg - Arg object.
|
|
135
|
+
* @param {boolean} [arg.i] -
|
|
136
|
+
* @param {boolean} [arg.b] -
|
|
137
|
+
* @param {boolean} [arg.buyNow] -
|
|
138
|
+
* @param {AddCartRequest} arg.body
|
|
139
|
+
* @returns {Promise<AddCartDetailResponse>} - Success response
|
|
140
|
+
* @summary: Add items to cart
|
|
141
|
+
* @description: Use this API to add items to the cart.
|
|
142
|
+
*/
|
|
143
|
+
addItems({ body, i, b, buyNow } = {}) {
|
|
144
|
+
const { error } = PosCartValidator.addItems().validate(
|
|
145
|
+
{ body, i, b, buyNow },
|
|
146
|
+
{ abortEarly: false, allowUnknown: true }
|
|
147
|
+
);
|
|
148
|
+
if (error) {
|
|
149
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
150
|
+
}
|
|
151
|
+
const query_params = {};
|
|
152
|
+
query_params["i"] = i;
|
|
153
|
+
query_params["b"] = b;
|
|
154
|
+
query_params["buy_now"] = buyNow;
|
|
155
|
+
|
|
156
|
+
const xHeaders = {};
|
|
157
|
+
|
|
158
|
+
return APIClient.execute(
|
|
159
|
+
this._conf,
|
|
160
|
+
"post",
|
|
161
|
+
constructUrl({
|
|
162
|
+
url: this._urls["addItems"],
|
|
163
|
+
params: {},
|
|
164
|
+
}),
|
|
165
|
+
query_params,
|
|
166
|
+
body,
|
|
167
|
+
xHeaders
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @param {Object} arg - Arg object.
|
|
173
|
+
* @param {string} [arg.id] -
|
|
174
|
+
* @param {boolean} [arg.i] -
|
|
175
|
+
* @param {boolean} [arg.b] -
|
|
176
|
+
* @param {boolean} [arg.buyNow] -
|
|
177
|
+
* @param {UpdateCartRequest} arg.body
|
|
178
|
+
* @returns {Promise<UpdateCartDetailResponse>} - Success response
|
|
179
|
+
* @summary: Update items in the cart
|
|
180
|
+
* @description: <p>Use this API to update items added to the cart with the help of a request object containing attributes like item_quantity and item_size. These attributes will be fetched from the following APIs</p> <ul> <li><font color="monochrome">operation</font> Operation for current api call. <b>update_item</b> for update items. <b>remove_item</b> for removing items.</li> <li> <font color="monochrome">item_id</font> "/platform/content/v1/products/"</li> <li> <font color="monochrome">item_size</font> "/platform/content/v1/products/:slug/sizes/"</li> <li> <font color="monochrome">quantity</font> item quantity (must be greater than or equal to 1)</li> <li> <font color="monochrome">article_id</font> "/content/v1/products/:identifier/sizes/price/"</li> <li> <font color="monochrome">item_index</font> item position in the cart (must be greater than or equal to 0)</li> </ul>
|
|
181
|
+
*/
|
|
182
|
+
updateCart({ body, id, i, b, buyNow } = {}) {
|
|
183
|
+
const { error } = PosCartValidator.updateCart().validate(
|
|
184
|
+
{ body, id, i, b, buyNow },
|
|
185
|
+
{ abortEarly: false, allowUnknown: true }
|
|
186
|
+
);
|
|
187
|
+
if (error) {
|
|
188
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
189
|
+
}
|
|
190
|
+
const query_params = {};
|
|
191
|
+
query_params["id"] = id;
|
|
192
|
+
query_params["i"] = i;
|
|
193
|
+
query_params["b"] = b;
|
|
194
|
+
query_params["buy_now"] = buyNow;
|
|
195
|
+
|
|
196
|
+
const xHeaders = {};
|
|
197
|
+
|
|
198
|
+
return APIClient.execute(
|
|
199
|
+
this._conf,
|
|
200
|
+
"put",
|
|
201
|
+
constructUrl({
|
|
202
|
+
url: this._urls["updateCart"],
|
|
203
|
+
params: {},
|
|
204
|
+
}),
|
|
205
|
+
query_params,
|
|
206
|
+
body,
|
|
207
|
+
xHeaders
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* @param {Object} arg - Arg object.
|
|
213
|
+
* @param {string} [arg.id] - The unique identifier of the cart.
|
|
214
|
+
* @param {boolean} [arg.buyNow] -
|
|
215
|
+
* @returns {Promise<CartItemCountResponse>} - Success response
|
|
216
|
+
* @summary: Count items in the cart
|
|
217
|
+
* @description: Use this API to get the total number of items present in cart.
|
|
218
|
+
*/
|
|
219
|
+
getItemCount({ id, buyNow } = {}) {
|
|
220
|
+
const { error } = PosCartValidator.getItemCount().validate(
|
|
221
|
+
{ id, buyNow },
|
|
222
|
+
{ abortEarly: false, allowUnknown: true }
|
|
223
|
+
);
|
|
224
|
+
if (error) {
|
|
225
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
226
|
+
}
|
|
227
|
+
const query_params = {};
|
|
228
|
+
query_params["id"] = id;
|
|
229
|
+
query_params["buy_now"] = buyNow;
|
|
230
|
+
|
|
231
|
+
const xHeaders = {};
|
|
232
|
+
|
|
233
|
+
return APIClient.execute(
|
|
234
|
+
this._conf,
|
|
235
|
+
"get",
|
|
236
|
+
constructUrl({
|
|
237
|
+
url: this._urls["getItemCount"],
|
|
238
|
+
params: {},
|
|
239
|
+
}),
|
|
240
|
+
query_params,
|
|
241
|
+
undefined,
|
|
242
|
+
xHeaders
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* @param {Object} arg - Arg object.
|
|
248
|
+
* @param {string} [arg.id] -
|
|
249
|
+
* @param {boolean} [arg.buyNow] -
|
|
250
|
+
* @returns {Promise<GetCouponResponse>} - Success response
|
|
251
|
+
* @summary: Fetch Coupon
|
|
252
|
+
* @description: Use this API to get a list of available coupons along with their details.
|
|
253
|
+
*/
|
|
254
|
+
getCoupons({ id, buyNow } = {}) {
|
|
255
|
+
const { error } = PosCartValidator.getCoupons().validate(
|
|
256
|
+
{ id, buyNow },
|
|
257
|
+
{ abortEarly: false, allowUnknown: true }
|
|
258
|
+
);
|
|
259
|
+
if (error) {
|
|
260
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
261
|
+
}
|
|
262
|
+
const query_params = {};
|
|
263
|
+
query_params["id"] = id;
|
|
264
|
+
query_params["buy_now"] = buyNow;
|
|
265
|
+
|
|
266
|
+
const xHeaders = {};
|
|
267
|
+
|
|
268
|
+
return APIClient.execute(
|
|
269
|
+
this._conf,
|
|
270
|
+
"get",
|
|
271
|
+
constructUrl({
|
|
272
|
+
url: this._urls["getCoupons"],
|
|
273
|
+
params: {},
|
|
274
|
+
}),
|
|
275
|
+
query_params,
|
|
276
|
+
undefined,
|
|
277
|
+
xHeaders
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* @param {Object} arg - Arg object.
|
|
283
|
+
* @param {boolean} [arg.i] -
|
|
284
|
+
* @param {boolean} [arg.b] -
|
|
285
|
+
* @param {boolean} [arg.p] -
|
|
286
|
+
* @param {string} [arg.id] -
|
|
287
|
+
* @param {boolean} [arg.buyNow] -
|
|
288
|
+
* @param {ApplyCouponRequest} arg.body
|
|
289
|
+
* @returns {Promise<CartDetailResponse>} - Success response
|
|
290
|
+
* @summary: Apply Coupon
|
|
291
|
+
* @description: Use this API to apply coupons on items in the cart.
|
|
292
|
+
*/
|
|
293
|
+
applyCoupon({ body, i, b, p, id, buyNow } = {}) {
|
|
294
|
+
const { error } = PosCartValidator.applyCoupon().validate(
|
|
295
|
+
{ body, i, b, p, id, buyNow },
|
|
296
|
+
{ abortEarly: false, allowUnknown: true }
|
|
297
|
+
);
|
|
298
|
+
if (error) {
|
|
299
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
300
|
+
}
|
|
301
|
+
const query_params = {};
|
|
302
|
+
query_params["i"] = i;
|
|
303
|
+
query_params["b"] = b;
|
|
304
|
+
query_params["p"] = p;
|
|
305
|
+
query_params["id"] = id;
|
|
306
|
+
query_params["buy_now"] = buyNow;
|
|
307
|
+
|
|
308
|
+
const xHeaders = {};
|
|
309
|
+
|
|
310
|
+
return APIClient.execute(
|
|
311
|
+
this._conf,
|
|
312
|
+
"post",
|
|
313
|
+
constructUrl({
|
|
314
|
+
url: this._urls["applyCoupon"],
|
|
315
|
+
params: {},
|
|
316
|
+
}),
|
|
317
|
+
query_params,
|
|
318
|
+
body,
|
|
319
|
+
xHeaders
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* @param {Object} arg - Arg object.
|
|
325
|
+
* @param {string} [arg.id] -
|
|
326
|
+
* @param {boolean} [arg.buyNow] -
|
|
327
|
+
* @returns {Promise<CartDetailResponse>} - Success response
|
|
328
|
+
* @summary: Remove Coupon Applied
|
|
329
|
+
* @description: Remove Coupon applied on the cart by passing uid in request body.
|
|
330
|
+
*/
|
|
331
|
+
removeCoupon({ id, buyNow } = {}) {
|
|
332
|
+
const { error } = PosCartValidator.removeCoupon().validate(
|
|
333
|
+
{ id, buyNow },
|
|
334
|
+
{ abortEarly: false, allowUnknown: true }
|
|
335
|
+
);
|
|
336
|
+
if (error) {
|
|
337
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
338
|
+
}
|
|
339
|
+
const query_params = {};
|
|
340
|
+
query_params["id"] = id;
|
|
341
|
+
query_params["buy_now"] = buyNow;
|
|
342
|
+
|
|
343
|
+
const xHeaders = {};
|
|
344
|
+
|
|
345
|
+
return APIClient.execute(
|
|
346
|
+
this._conf,
|
|
347
|
+
"delete",
|
|
348
|
+
constructUrl({
|
|
349
|
+
url: this._urls["removeCoupon"],
|
|
350
|
+
params: {},
|
|
351
|
+
}),
|
|
352
|
+
query_params,
|
|
353
|
+
undefined,
|
|
354
|
+
xHeaders
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @param {Object} arg - Arg object.
|
|
360
|
+
* @param {number} [arg.itemId] - The Item ID of the product
|
|
361
|
+
* @param {string} [arg.articleId] - Article Mongo ID
|
|
362
|
+
* @param {number} [arg.uid] - UID of the product
|
|
363
|
+
* @param {string} [arg.slug] - A short, human-readable, URL-friendly
|
|
364
|
+
* identifier of a product. You can get slug value from the endpoint
|
|
365
|
+
* /service/application/catalog/v1.0/products/
|
|
366
|
+
* @returns {Promise<BulkPriceResponse>} - Success response
|
|
367
|
+
* @summary: Get discount offers based on quantity
|
|
368
|
+
* @description: Use this API to get a list of applicable offers along with current, next and best offer for given product. Either one of uid, item_id, slug should be present.
|
|
369
|
+
*/
|
|
370
|
+
getBulkDiscountOffers({ itemId, articleId, uid, slug } = {}) {
|
|
371
|
+
const { error } = PosCartValidator.getBulkDiscountOffers().validate(
|
|
372
|
+
{ itemId, articleId, uid, slug },
|
|
373
|
+
{ abortEarly: false, allowUnknown: true }
|
|
374
|
+
);
|
|
375
|
+
if (error) {
|
|
376
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
377
|
+
}
|
|
378
|
+
const query_params = {};
|
|
379
|
+
query_params["item_id"] = itemId;
|
|
380
|
+
query_params["article_id"] = articleId;
|
|
381
|
+
query_params["uid"] = uid;
|
|
382
|
+
query_params["slug"] = slug;
|
|
383
|
+
|
|
384
|
+
const xHeaders = {};
|
|
385
|
+
|
|
386
|
+
return APIClient.execute(
|
|
387
|
+
this._conf,
|
|
388
|
+
"get",
|
|
389
|
+
constructUrl({
|
|
390
|
+
url: this._urls["getBulkDiscountOffers"],
|
|
391
|
+
params: {},
|
|
392
|
+
}),
|
|
393
|
+
query_params,
|
|
394
|
+
undefined,
|
|
395
|
+
xHeaders
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* @param {Object} arg - Arg object.
|
|
401
|
+
* @param {string} [arg.id] -
|
|
402
|
+
* @param {boolean} [arg.i] -
|
|
403
|
+
* @param {boolean} [arg.b] -
|
|
404
|
+
* @param {boolean} [arg.buyNow] -
|
|
405
|
+
* @param {RewardPointRequest} arg.body
|
|
406
|
+
* @returns {Promise<CartDetailResponse>} - Success response
|
|
407
|
+
* @summary: Apply reward points at cart
|
|
408
|
+
* @description: Use this API to redeem a fixed no. of reward points by applying it to the cart.
|
|
409
|
+
*/
|
|
410
|
+
applyRewardPoints({ body, id, i, b, buyNow } = {}) {
|
|
411
|
+
const { error } = PosCartValidator.applyRewardPoints().validate(
|
|
412
|
+
{ body, id, i, b, buyNow },
|
|
413
|
+
{ abortEarly: false, allowUnknown: true }
|
|
414
|
+
);
|
|
415
|
+
if (error) {
|
|
416
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
417
|
+
}
|
|
418
|
+
const query_params = {};
|
|
419
|
+
query_params["id"] = id;
|
|
420
|
+
query_params["i"] = i;
|
|
421
|
+
query_params["b"] = b;
|
|
422
|
+
query_params["buy_now"] = buyNow;
|
|
423
|
+
|
|
424
|
+
const xHeaders = {};
|
|
425
|
+
|
|
426
|
+
return APIClient.execute(
|
|
427
|
+
this._conf,
|
|
428
|
+
"post",
|
|
429
|
+
constructUrl({
|
|
430
|
+
url: this._urls["applyRewardPoints"],
|
|
431
|
+
params: {},
|
|
432
|
+
}),
|
|
433
|
+
query_params,
|
|
434
|
+
body,
|
|
435
|
+
xHeaders
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* @param {Object} arg - Arg object.
|
|
441
|
+
* @param {string} [arg.cartId] -
|
|
442
|
+
* @param {boolean} [arg.buyNow] -
|
|
443
|
+
* @param {string} [arg.mobileNo] -
|
|
444
|
+
* @param {string} [arg.checkoutMode] -
|
|
445
|
+
* @param {string} [arg.tags] -
|
|
446
|
+
* @param {boolean} [arg.isDefault] -
|
|
447
|
+
* @returns {Promise<GetAddressesResponse>} - Success response
|
|
448
|
+
* @summary: Fetch address
|
|
449
|
+
* @description: Use this API to get all the addresses associated with an account. If successful, returns a Address resource in the response body specified in GetAddressesResponse.attibutes listed below are optional <ul> <li> <font color="monochrome">uid</font></li> <li> <font color="monochrome">address_id</font></li> <li> <font color="monochrome">mobile_no</font></li> <li> <font color="monochrome">checkout_mode</font></li> <li> <font color="monochrome">tags</font></li> <li> <font color="monochrome">default</font></li> </ul>
|
|
450
|
+
*/
|
|
451
|
+
getAddresses({
|
|
452
|
+
cartId,
|
|
453
|
+
buyNow,
|
|
454
|
+
mobileNo,
|
|
455
|
+
checkoutMode,
|
|
456
|
+
tags,
|
|
457
|
+
isDefault,
|
|
458
|
+
} = {}) {
|
|
459
|
+
const { error } = PosCartValidator.getAddresses().validate(
|
|
460
|
+
{ cartId, buyNow, mobileNo, checkoutMode, tags, isDefault },
|
|
461
|
+
{ abortEarly: false, allowUnknown: true }
|
|
462
|
+
);
|
|
463
|
+
if (error) {
|
|
464
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
465
|
+
}
|
|
466
|
+
const query_params = {};
|
|
467
|
+
query_params["cart_id"] = cartId;
|
|
468
|
+
query_params["buy_now"] = buyNow;
|
|
469
|
+
query_params["mobile_no"] = mobileNo;
|
|
470
|
+
query_params["checkout_mode"] = checkoutMode;
|
|
471
|
+
query_params["tags"] = tags;
|
|
472
|
+
query_params["is_default"] = isDefault;
|
|
473
|
+
|
|
474
|
+
const xHeaders = {};
|
|
475
|
+
|
|
476
|
+
return APIClient.execute(
|
|
477
|
+
this._conf,
|
|
478
|
+
"get",
|
|
479
|
+
constructUrl({
|
|
480
|
+
url: this._urls["getAddresses"],
|
|
481
|
+
params: {},
|
|
482
|
+
}),
|
|
483
|
+
query_params,
|
|
484
|
+
undefined,
|
|
485
|
+
xHeaders
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* @param {Object} arg - Arg object.
|
|
491
|
+
* @param {Address} arg.body
|
|
492
|
+
* @returns {Promise<SaveAddressResponse>} - Success response
|
|
493
|
+
* @summary: Add address to an account
|
|
494
|
+
* @description: Use this API to add an address to an account.
|
|
495
|
+
*/
|
|
496
|
+
addAddress({ body } = {}) {
|
|
497
|
+
const { error } = PosCartValidator.addAddress().validate(
|
|
498
|
+
{ body },
|
|
499
|
+
{ abortEarly: false, allowUnknown: true }
|
|
500
|
+
);
|
|
501
|
+
if (error) {
|
|
502
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
503
|
+
}
|
|
504
|
+
const query_params = {};
|
|
505
|
+
|
|
506
|
+
const xHeaders = {};
|
|
507
|
+
|
|
508
|
+
return APIClient.execute(
|
|
509
|
+
this._conf,
|
|
510
|
+
"post",
|
|
511
|
+
constructUrl({
|
|
512
|
+
url: this._urls["addAddress"],
|
|
513
|
+
params: {},
|
|
514
|
+
}),
|
|
515
|
+
query_params,
|
|
516
|
+
body,
|
|
517
|
+
xHeaders
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* @param {Object} arg - Arg object.
|
|
523
|
+
* @param {string} arg.id -
|
|
524
|
+
* @param {string} [arg.cartId] -
|
|
525
|
+
* @param {boolean} [arg.buyNow] -
|
|
526
|
+
* @param {string} [arg.mobileNo] -
|
|
527
|
+
* @param {string} [arg.checkoutMode] -
|
|
528
|
+
* @param {string} [arg.tags] -
|
|
529
|
+
* @param {boolean} [arg.isDefault] -
|
|
530
|
+
* @returns {Promise<Address>} - Success response
|
|
531
|
+
* @summary: Fetch a single address by its ID
|
|
532
|
+
* @description: Use this API to get an addresses using its ID. If successful, returns a Address resource in the response body specified in `Address`. Attibutes listed below are optional <ul> <li> <font color="monochrome">mobile_no</font></li> <li> <font color="monochrome">checkout_mode</font></li> <li> <font color="monochrome">tags</font></li> <li> <font color="monochrome">default</font></li> </ul>
|
|
533
|
+
*/
|
|
534
|
+
getAddressById({
|
|
535
|
+
id,
|
|
536
|
+
cartId,
|
|
537
|
+
buyNow,
|
|
538
|
+
mobileNo,
|
|
539
|
+
checkoutMode,
|
|
540
|
+
tags,
|
|
541
|
+
isDefault,
|
|
542
|
+
} = {}) {
|
|
543
|
+
const { error } = PosCartValidator.getAddressById().validate(
|
|
544
|
+
{ id, cartId, buyNow, mobileNo, checkoutMode, tags, isDefault },
|
|
545
|
+
{ abortEarly: false, allowUnknown: true }
|
|
546
|
+
);
|
|
547
|
+
if (error) {
|
|
548
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
549
|
+
}
|
|
550
|
+
const query_params = {};
|
|
551
|
+
query_params["cart_id"] = cartId;
|
|
552
|
+
query_params["buy_now"] = buyNow;
|
|
553
|
+
query_params["mobile_no"] = mobileNo;
|
|
554
|
+
query_params["checkout_mode"] = checkoutMode;
|
|
555
|
+
query_params["tags"] = tags;
|
|
556
|
+
query_params["is_default"] = isDefault;
|
|
557
|
+
|
|
558
|
+
const xHeaders = {};
|
|
559
|
+
|
|
560
|
+
return APIClient.execute(
|
|
561
|
+
this._conf,
|
|
562
|
+
"get",
|
|
563
|
+
constructUrl({
|
|
564
|
+
url: this._urls["getAddressById"],
|
|
565
|
+
params: { id },
|
|
566
|
+
}),
|
|
567
|
+
query_params,
|
|
568
|
+
undefined,
|
|
569
|
+
xHeaders
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* @param {Object} arg - Arg object.
|
|
575
|
+
* @param {string} arg.id - ID allotted to the selected address
|
|
576
|
+
* @param {Address} arg.body
|
|
577
|
+
* @returns {Promise<UpdateAddressResponse>} - Success response
|
|
578
|
+
* @summary: Update address added to an account
|
|
579
|
+
* @description: <p>Use this API to update an existing address in the account. Request object should contain attributes mentioned in <font color="blue">Address </font> can be updated. These attributes are:</p> <ul> <li> <font color="monochrome">is_default_address</font></li> <li> <font color="monochrome">landmark</font></li> <li> <font color="monochrome">area</font></li> <li> <font color="monochrome">pincode</font></li> <li> <font color="monochrome">email</font></li> <li> <font color="monochrome">address_type</font></li> <li> <font color="monochrome">name</font></li> <li> <font color="monochrome">address_id</font></li> <li> <font color="monochrome">address</font></li> </ul>
|
|
580
|
+
*/
|
|
581
|
+
updateAddress({ id, body } = {}) {
|
|
582
|
+
const { error } = PosCartValidator.updateAddress().validate(
|
|
583
|
+
{ id, body },
|
|
584
|
+
{ abortEarly: false, allowUnknown: true }
|
|
585
|
+
);
|
|
586
|
+
if (error) {
|
|
587
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
588
|
+
}
|
|
589
|
+
const query_params = {};
|
|
590
|
+
|
|
591
|
+
const xHeaders = {};
|
|
592
|
+
|
|
593
|
+
return APIClient.execute(
|
|
594
|
+
this._conf,
|
|
595
|
+
"put",
|
|
596
|
+
constructUrl({
|
|
597
|
+
url: this._urls["updateAddress"],
|
|
598
|
+
params: { id },
|
|
599
|
+
}),
|
|
600
|
+
query_params,
|
|
601
|
+
body,
|
|
602
|
+
xHeaders
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* @param {Object} arg - Arg object.
|
|
608
|
+
* @param {string} arg.id - ID allotted to the selected address
|
|
609
|
+
* @returns {Promise<DeleteAddressResponse>} - Success response
|
|
610
|
+
* @summary: Remove address associated with an account
|
|
611
|
+
* @description: Use this API to delete an address by its ID. This will returns an object that will indicate whether the address was deleted successfully or not.
|
|
612
|
+
*/
|
|
613
|
+
removeAddress({ id } = {}) {
|
|
614
|
+
const { error } = PosCartValidator.removeAddress().validate(
|
|
615
|
+
{ id },
|
|
616
|
+
{ abortEarly: false, allowUnknown: true }
|
|
617
|
+
);
|
|
618
|
+
if (error) {
|
|
619
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
620
|
+
}
|
|
621
|
+
const query_params = {};
|
|
622
|
+
|
|
623
|
+
const xHeaders = {};
|
|
624
|
+
|
|
625
|
+
return APIClient.execute(
|
|
626
|
+
this._conf,
|
|
627
|
+
"delete",
|
|
628
|
+
constructUrl({
|
|
629
|
+
url: this._urls["removeAddress"],
|
|
630
|
+
params: { id },
|
|
631
|
+
}),
|
|
632
|
+
query_params,
|
|
633
|
+
undefined,
|
|
634
|
+
xHeaders
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* @param {Object} arg - Arg object.
|
|
640
|
+
* @param {string} [arg.cartId] -
|
|
641
|
+
* @param {boolean} [arg.buyNow] -
|
|
642
|
+
* @param {boolean} [arg.i] -
|
|
643
|
+
* @param {boolean} [arg.b] -
|
|
644
|
+
* @param {SelectCartAddressRequest} arg.body
|
|
645
|
+
* @returns {Promise<CartDetailResponse>} - Success response
|
|
646
|
+
* @summary: Select an address from available addresses
|
|
647
|
+
* @description: <p>Select Address from all addresses associated with the account in order to ship the cart items to that address, otherwise default address will be selected implicitly. See `SelectCartAddressRequest` in schema of request body for the list of attributes needed to select Address from account. On successful request, this API returns a Cart object. Below address attributes are required. <ul> <li> <font color="monochrome">address_id</font></li> <li> <font color="monochrome">billing_address_id</font></li> <li> <font color="monochrome">uid</font></li> </ul></p>
|
|
648
|
+
*/
|
|
649
|
+
selectAddress({ body, cartId, buyNow, i, b } = {}) {
|
|
650
|
+
const { error } = PosCartValidator.selectAddress().validate(
|
|
651
|
+
{ body, cartId, buyNow, i, b },
|
|
652
|
+
{ abortEarly: false, allowUnknown: true }
|
|
653
|
+
);
|
|
654
|
+
if (error) {
|
|
655
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
656
|
+
}
|
|
657
|
+
const query_params = {};
|
|
658
|
+
query_params["cart_id"] = cartId;
|
|
659
|
+
query_params["buy_now"] = buyNow;
|
|
660
|
+
query_params["i"] = i;
|
|
661
|
+
query_params["b"] = b;
|
|
662
|
+
|
|
663
|
+
const xHeaders = {};
|
|
664
|
+
|
|
665
|
+
return APIClient.execute(
|
|
666
|
+
this._conf,
|
|
667
|
+
"post",
|
|
668
|
+
constructUrl({
|
|
669
|
+
url: this._urls["selectAddress"],
|
|
670
|
+
params: {},
|
|
671
|
+
}),
|
|
672
|
+
query_params,
|
|
673
|
+
body,
|
|
674
|
+
xHeaders
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* @param {Object} arg - Arg object.
|
|
680
|
+
* @param {string} [arg.id] -
|
|
681
|
+
* @param {boolean} [arg.buyNow] -
|
|
682
|
+
* @param {UpdateCartPaymentRequest} arg.body
|
|
683
|
+
* @returns {Promise<CartDetailResponse>} - Success response
|
|
684
|
+
* @summary: Update cart payment
|
|
685
|
+
* @description: Use this API to update cart payment.
|
|
686
|
+
*/
|
|
687
|
+
selectPaymentMode({ body, id, buyNow } = {}) {
|
|
688
|
+
const { error } = PosCartValidator.selectPaymentMode().validate(
|
|
689
|
+
{ body, id, buyNow },
|
|
690
|
+
{ abortEarly: false, allowUnknown: true }
|
|
691
|
+
);
|
|
692
|
+
if (error) {
|
|
693
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
694
|
+
}
|
|
695
|
+
const query_params = {};
|
|
696
|
+
query_params["id"] = id;
|
|
697
|
+
query_params["buy_now"] = buyNow;
|
|
698
|
+
|
|
699
|
+
const xHeaders = {};
|
|
700
|
+
|
|
701
|
+
return APIClient.execute(
|
|
702
|
+
this._conf,
|
|
703
|
+
"put",
|
|
704
|
+
constructUrl({
|
|
705
|
+
url: this._urls["selectPaymentMode"],
|
|
706
|
+
params: {},
|
|
707
|
+
}),
|
|
708
|
+
query_params,
|
|
709
|
+
body,
|
|
710
|
+
xHeaders
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* @param {Object} arg - Arg object.
|
|
716
|
+
* @param {string} [arg.id] -
|
|
717
|
+
* @param {boolean} [arg.buyNow] -
|
|
718
|
+
* @param {string} [arg.addressId] -
|
|
719
|
+
* @param {string} [arg.paymentMode] -
|
|
720
|
+
* @param {string} [arg.paymentIdentifier] -
|
|
721
|
+
* @param {string} [arg.aggregatorName] -
|
|
722
|
+
* @param {string} [arg.merchantCode] -
|
|
723
|
+
* @returns {Promise<PaymentCouponValidate>} - Success response
|
|
724
|
+
* @summary: Verify the coupon eligibility against the payment mode
|
|
725
|
+
* @description: Use this API to validate a coupon against the payment mode such as NetBanking, Wallet, UPI etc.
|
|
726
|
+
*/
|
|
727
|
+
validateCouponForPayment({
|
|
728
|
+
id,
|
|
729
|
+
buyNow,
|
|
730
|
+
addressId,
|
|
731
|
+
paymentMode,
|
|
732
|
+
paymentIdentifier,
|
|
733
|
+
aggregatorName,
|
|
734
|
+
merchantCode,
|
|
735
|
+
} = {}) {
|
|
736
|
+
const { error } = PosCartValidator.validateCouponForPayment().validate(
|
|
737
|
+
{
|
|
738
|
+
id,
|
|
739
|
+
buyNow,
|
|
740
|
+
addressId,
|
|
741
|
+
paymentMode,
|
|
742
|
+
paymentIdentifier,
|
|
743
|
+
aggregatorName,
|
|
744
|
+
merchantCode,
|
|
745
|
+
},
|
|
746
|
+
{ abortEarly: false, allowUnknown: true }
|
|
747
|
+
);
|
|
748
|
+
if (error) {
|
|
749
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
750
|
+
}
|
|
751
|
+
const query_params = {};
|
|
752
|
+
query_params["id"] = id;
|
|
753
|
+
query_params["buy_now"] = buyNow;
|
|
754
|
+
query_params["address_id"] = addressId;
|
|
755
|
+
query_params["payment_mode"] = paymentMode;
|
|
756
|
+
query_params["payment_identifier"] = paymentIdentifier;
|
|
757
|
+
query_params["aggregator_name"] = aggregatorName;
|
|
758
|
+
query_params["merchant_code"] = merchantCode;
|
|
759
|
+
|
|
760
|
+
const xHeaders = {};
|
|
761
|
+
|
|
762
|
+
return APIClient.execute(
|
|
763
|
+
this._conf,
|
|
764
|
+
"get",
|
|
765
|
+
constructUrl({
|
|
766
|
+
url: this._urls["validateCouponForPayment"],
|
|
767
|
+
params: {},
|
|
768
|
+
}),
|
|
769
|
+
query_params,
|
|
770
|
+
undefined,
|
|
771
|
+
xHeaders
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* @param {Object} arg - Arg object.
|
|
777
|
+
* @param {number} [arg.pickAtStoreUid] -
|
|
778
|
+
* @param {number} [arg.orderingStoreId] -
|
|
779
|
+
* @param {boolean} [arg.p] - This is a boolean value. Select `true` for
|
|
780
|
+
* getting a payment option in response.
|
|
781
|
+
* @param {string} [arg.id] - The unique identifier of the cart
|
|
782
|
+
* @param {string} [arg.addressId] - ID allotted to the selected address
|
|
783
|
+
* @param {string} [arg.areaCode] - The PIN Code of the destination address,
|
|
784
|
+
* e.g. 400059
|
|
785
|
+
* @param {string} [arg.orderType] - The order type of shipment HomeDelivery
|
|
786
|
+
* - If the customer wants the order home-delivered PickAtStore - If the
|
|
787
|
+
* customer wants the handover of an order at the store itself.
|
|
788
|
+
* @returns {Promise<CartShipmentsResponse>} - Success response
|
|
789
|
+
* @summary: Get delivery date and options before checkout
|
|
790
|
+
* @description: Use this API to get shipment details, expected delivery date, items and price breakup of the shipment.
|
|
791
|
+
*/
|
|
792
|
+
getShipments({
|
|
793
|
+
pickAtStoreUid,
|
|
794
|
+
orderingStoreId,
|
|
795
|
+
p,
|
|
796
|
+
id,
|
|
797
|
+
addressId,
|
|
798
|
+
areaCode,
|
|
799
|
+
orderType,
|
|
800
|
+
} = {}) {
|
|
801
|
+
const { error } = PosCartValidator.getShipments().validate(
|
|
802
|
+
{
|
|
803
|
+
pickAtStoreUid,
|
|
804
|
+
orderingStoreId,
|
|
805
|
+
p,
|
|
806
|
+
id,
|
|
807
|
+
addressId,
|
|
808
|
+
areaCode,
|
|
809
|
+
orderType,
|
|
810
|
+
},
|
|
811
|
+
{ abortEarly: false, allowUnknown: true }
|
|
812
|
+
);
|
|
813
|
+
if (error) {
|
|
814
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
815
|
+
}
|
|
816
|
+
const query_params = {};
|
|
817
|
+
query_params["pick_at_store_uid"] = pickAtStoreUid;
|
|
818
|
+
query_params["ordering_store_id"] = orderingStoreId;
|
|
819
|
+
query_params["p"] = p;
|
|
820
|
+
query_params["id"] = id;
|
|
821
|
+
query_params["address_id"] = addressId;
|
|
822
|
+
query_params["area_code"] = areaCode;
|
|
823
|
+
query_params["order_type"] = orderType;
|
|
824
|
+
|
|
825
|
+
const xHeaders = {};
|
|
826
|
+
|
|
827
|
+
return APIClient.execute(
|
|
828
|
+
this._conf,
|
|
829
|
+
"get",
|
|
830
|
+
constructUrl({
|
|
831
|
+
url: this._urls["getShipments"],
|
|
832
|
+
params: {},
|
|
833
|
+
}),
|
|
834
|
+
query_params,
|
|
835
|
+
undefined,
|
|
836
|
+
xHeaders
|
|
837
|
+
);
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* @param {Object} arg - Arg object.
|
|
842
|
+
* @param {boolean} [arg.i] - This is a boolean value. Select `true` to
|
|
843
|
+
* retrieve all the items added in the cart.
|
|
844
|
+
* @param {boolean} [arg.p] - This is a boolean value. Select `true` for
|
|
845
|
+
* getting a payment option in response.
|
|
846
|
+
* @param {string} [arg.id] - The unique identifier of the cart
|
|
847
|
+
* @param {string} [arg.addressId] - ID allotted to an address
|
|
848
|
+
* @param {string} [arg.orderType] - The order type of shipment HomeDelivery
|
|
849
|
+
* - If the customer wants the order home-delivered PickAtStore - If the
|
|
850
|
+
* customer wants the handover of an order at the store itself.
|
|
851
|
+
* @param {UpdateCartShipmentRequest} arg.body
|
|
852
|
+
* @returns {Promise<CartShipmentsResponse>} - Success response
|
|
853
|
+
* @summary: Update shipment delivery type and quantity before checkout
|
|
854
|
+
* @description: Use this API to update the delivery type and quantity as per customer's preference for either store pick-up or home-delivery.
|
|
855
|
+
*/
|
|
856
|
+
updateShipments({ body, i, p, id, addressId, orderType } = {}) {
|
|
857
|
+
const { error } = PosCartValidator.updateShipments().validate(
|
|
858
|
+
{ body, i, p, id, addressId, orderType },
|
|
859
|
+
{ abortEarly: false, allowUnknown: true }
|
|
860
|
+
);
|
|
861
|
+
if (error) {
|
|
862
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
863
|
+
}
|
|
864
|
+
const query_params = {};
|
|
865
|
+
query_params["i"] = i;
|
|
866
|
+
query_params["p"] = p;
|
|
867
|
+
query_params["id"] = id;
|
|
868
|
+
query_params["address_id"] = addressId;
|
|
869
|
+
query_params["order_type"] = orderType;
|
|
870
|
+
|
|
871
|
+
const xHeaders = {};
|
|
872
|
+
|
|
873
|
+
return APIClient.execute(
|
|
874
|
+
this._conf,
|
|
875
|
+
"put",
|
|
876
|
+
constructUrl({
|
|
877
|
+
url: this._urls["updateShipments"],
|
|
878
|
+
params: {},
|
|
879
|
+
}),
|
|
880
|
+
query_params,
|
|
881
|
+
body,
|
|
882
|
+
xHeaders
|
|
883
|
+
);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* @param {Object} arg - Arg object.
|
|
888
|
+
* @param {string} [arg.id] -
|
|
889
|
+
* @param {CartPosCheckoutDetailRequest} arg.body
|
|
890
|
+
* @returns {Promise<CartCheckoutResponse>} - Success response
|
|
891
|
+
* @summary: Checkout all items in the cart
|
|
892
|
+
* @description: Use this API to checkout all items in the cart for payment and order generation. For COD, order will be generated directly, whereas for other checkout modes, user will be redirected to a payment gateway.
|
|
893
|
+
*/
|
|
894
|
+
checkoutCart({ body, id } = {}) {
|
|
895
|
+
const { error } = PosCartValidator.checkoutCart().validate(
|
|
896
|
+
{ body, id },
|
|
897
|
+
{ abortEarly: false, allowUnknown: true }
|
|
898
|
+
);
|
|
899
|
+
if (error) {
|
|
900
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
901
|
+
}
|
|
902
|
+
const query_params = {};
|
|
903
|
+
query_params["id"] = id;
|
|
904
|
+
|
|
905
|
+
const xHeaders = {};
|
|
906
|
+
|
|
907
|
+
return APIClient.execute(
|
|
908
|
+
this._conf,
|
|
909
|
+
"post",
|
|
910
|
+
constructUrl({
|
|
911
|
+
url: this._urls["checkoutCart"],
|
|
912
|
+
params: {},
|
|
913
|
+
}),
|
|
914
|
+
query_params,
|
|
915
|
+
body,
|
|
916
|
+
xHeaders
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* @param {Object} arg - Arg object.
|
|
922
|
+
* @param {string} [arg.id] -
|
|
923
|
+
* @param {boolean} [arg.buyNow] -
|
|
924
|
+
* @param {CartMetaRequest} arg.body
|
|
925
|
+
* @returns {Promise<CartMetaResponse>} - Success response
|
|
926
|
+
* @summary: Update the cart meta
|
|
927
|
+
* @description: Use this API to update cart meta like checkout_mode and gstin.
|
|
928
|
+
*/
|
|
929
|
+
updateCartMeta({ body, id, buyNow } = {}) {
|
|
930
|
+
const { error } = PosCartValidator.updateCartMeta().validate(
|
|
931
|
+
{ body, id, buyNow },
|
|
932
|
+
{ abortEarly: false, allowUnknown: true }
|
|
933
|
+
);
|
|
934
|
+
if (error) {
|
|
935
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
936
|
+
}
|
|
937
|
+
const query_params = {};
|
|
938
|
+
query_params["id"] = id;
|
|
939
|
+
query_params["buy_now"] = buyNow;
|
|
940
|
+
|
|
941
|
+
const xHeaders = {};
|
|
942
|
+
|
|
943
|
+
return APIClient.execute(
|
|
944
|
+
this._conf,
|
|
945
|
+
"put",
|
|
946
|
+
constructUrl({
|
|
947
|
+
url: this._urls["updateCartMeta"],
|
|
948
|
+
params: {},
|
|
949
|
+
}),
|
|
950
|
+
query_params,
|
|
951
|
+
body,
|
|
952
|
+
xHeaders
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* @param {Object} arg - Arg object.
|
|
958
|
+
* @param {string} arg.areaCode -
|
|
959
|
+
* @param {string} [arg.id] -
|
|
960
|
+
* @returns {Promise<CartDeliveryModesResponse>} - Success response
|
|
961
|
+
* @summary: Get available delivery modes for cart
|
|
962
|
+
* @description: Use this API to get the delivery modes (home-delivery/store-pickup) along with a list of pickup stores available for a given cart at a given PIN Code. User can then view the address of a pickup store with the help of store-address API.
|
|
963
|
+
*/
|
|
964
|
+
getAvailableDeliveryModes({ areaCode, id } = {}) {
|
|
965
|
+
const { error } = PosCartValidator.getAvailableDeliveryModes().validate(
|
|
966
|
+
{ areaCode, id },
|
|
967
|
+
{ abortEarly: false, allowUnknown: true }
|
|
968
|
+
);
|
|
969
|
+
if (error) {
|
|
970
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
971
|
+
}
|
|
972
|
+
const query_params = {};
|
|
973
|
+
query_params["area_code"] = areaCode;
|
|
974
|
+
query_params["id"] = id;
|
|
975
|
+
|
|
976
|
+
const xHeaders = {};
|
|
977
|
+
|
|
978
|
+
return APIClient.execute(
|
|
979
|
+
this._conf,
|
|
980
|
+
"get",
|
|
981
|
+
constructUrl({
|
|
982
|
+
url: this._urls["getAvailableDeliveryModes"],
|
|
983
|
+
params: {},
|
|
984
|
+
}),
|
|
985
|
+
query_params,
|
|
986
|
+
undefined,
|
|
987
|
+
xHeaders
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* @param {Object} arg - Arg object.
|
|
993
|
+
* @param {number} arg.storeUid -
|
|
994
|
+
* @returns {Promise<StoreDetailsResponse>} - Success response
|
|
995
|
+
* @summary: Get list of stores for give uids
|
|
996
|
+
* @description: Use this API to get the store details by entering the unique identifier of the pickup stores shown in the response of available-delivery-mode API.
|
|
997
|
+
*/
|
|
998
|
+
getStoreAddressByUid({ storeUid } = {}) {
|
|
999
|
+
const { error } = PosCartValidator.getStoreAddressByUid().validate(
|
|
1000
|
+
{ storeUid },
|
|
1001
|
+
{ abortEarly: false, allowUnknown: true }
|
|
1002
|
+
);
|
|
1003
|
+
if (error) {
|
|
1004
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
1005
|
+
}
|
|
1006
|
+
const query_params = {};
|
|
1007
|
+
query_params["store_uid"] = storeUid;
|
|
1008
|
+
|
|
1009
|
+
const xHeaders = {};
|
|
1010
|
+
|
|
1011
|
+
return APIClient.execute(
|
|
1012
|
+
this._conf,
|
|
1013
|
+
"get",
|
|
1014
|
+
constructUrl({
|
|
1015
|
+
url: this._urls["getStoreAddressByUid"],
|
|
1016
|
+
params: {},
|
|
1017
|
+
}),
|
|
1018
|
+
query_params,
|
|
1019
|
+
undefined,
|
|
1020
|
+
xHeaders
|
|
1021
|
+
);
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* @param {Object} arg - Arg object.
|
|
1026
|
+
* @param {GetShareCartLinkRequest} arg.body
|
|
1027
|
+
* @returns {Promise<GetShareCartLinkResponse>} - Success response
|
|
1028
|
+
* @summary: Generate token for sharing the cart
|
|
1029
|
+
* @description: Use this API to generate a shared cart snapshot and return a shortlink token. The link can be shared with other users for getting the same items in their cart.
|
|
1030
|
+
*/
|
|
1031
|
+
getCartShareLink({ body } = {}) {
|
|
1032
|
+
const { error } = PosCartValidator.getCartShareLink().validate(
|
|
1033
|
+
{ body },
|
|
1034
|
+
{ abortEarly: false, allowUnknown: true }
|
|
1035
|
+
);
|
|
1036
|
+
if (error) {
|
|
1037
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
1038
|
+
}
|
|
1039
|
+
const query_params = {};
|
|
1040
|
+
|
|
1041
|
+
const xHeaders = {};
|
|
1042
|
+
|
|
1043
|
+
return APIClient.execute(
|
|
1044
|
+
this._conf,
|
|
1045
|
+
"post",
|
|
1046
|
+
constructUrl({
|
|
1047
|
+
url: this._urls["getCartShareLink"],
|
|
1048
|
+
params: {},
|
|
1049
|
+
}),
|
|
1050
|
+
query_params,
|
|
1051
|
+
body,
|
|
1052
|
+
xHeaders
|
|
1053
|
+
);
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* @param {Object} arg - Arg object.
|
|
1058
|
+
* @param {string} arg.token - Token of the shared short link
|
|
1059
|
+
* @returns {Promise<SharedCartResponse>} - Success response
|
|
1060
|
+
* @summary: Get details of a shared cart
|
|
1061
|
+
* @description: Use this API to get the shared cart details as per the token generated using the share-cart API.
|
|
1062
|
+
*/
|
|
1063
|
+
getCartSharedItems({ token } = {}) {
|
|
1064
|
+
const { error } = PosCartValidator.getCartSharedItems().validate(
|
|
1065
|
+
{ token },
|
|
1066
|
+
{ abortEarly: false, allowUnknown: true }
|
|
1067
|
+
);
|
|
1068
|
+
if (error) {
|
|
1069
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
1070
|
+
}
|
|
1071
|
+
const query_params = {};
|
|
1072
|
+
|
|
1073
|
+
const xHeaders = {};
|
|
1074
|
+
|
|
1075
|
+
return APIClient.execute(
|
|
1076
|
+
this._conf,
|
|
1077
|
+
"get",
|
|
1078
|
+
constructUrl({
|
|
1079
|
+
url: this._urls["getCartSharedItems"],
|
|
1080
|
+
params: { token },
|
|
1081
|
+
}),
|
|
1082
|
+
query_params,
|
|
1083
|
+
undefined,
|
|
1084
|
+
xHeaders
|
|
1085
|
+
);
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* @param {Object} arg - Arg object.
|
|
1090
|
+
* @param {string} arg.token - Token of the shared short link
|
|
1091
|
+
* @param {string} arg.action - Operation to perform on the existing cart
|
|
1092
|
+
* merge or replace.
|
|
1093
|
+
* @returns {Promise<SharedCartResponse>} - Success response
|
|
1094
|
+
* @summary: Merge or replace existing cart
|
|
1095
|
+
* @description: Use this API to merge the shared cart with existing cart, or replace the existing cart with the shared cart. The `action` parameter is used to indicate the operation Merge or Replace.
|
|
1096
|
+
*/
|
|
1097
|
+
updateCartWithSharedItems({ token, action } = {}) {
|
|
1098
|
+
const { error } = PosCartValidator.updateCartWithSharedItems().validate(
|
|
1099
|
+
{ token, action },
|
|
1100
|
+
{ abortEarly: false, allowUnknown: true }
|
|
1101
|
+
);
|
|
1102
|
+
if (error) {
|
|
1103
|
+
return Promise.reject(new FDKClientValidationError(error));
|
|
1104
|
+
}
|
|
1105
|
+
const query_params = {};
|
|
1106
|
+
|
|
1107
|
+
const xHeaders = {};
|
|
1108
|
+
|
|
1109
|
+
return APIClient.execute(
|
|
1110
|
+
this._conf,
|
|
1111
|
+
"post",
|
|
1112
|
+
constructUrl({
|
|
1113
|
+
url: this._urls["updateCartWithSharedItems"],
|
|
1114
|
+
params: { token, action },
|
|
1115
|
+
}),
|
|
1116
|
+
query_params,
|
|
1117
|
+
undefined,
|
|
1118
|
+
xHeaders
|
|
1119
|
+
);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
module.exports = PosCart;
|