@commercengine/storefront-sdk 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-C8nXwxS6.d.ts → index.d.mts} +817 -437
- package/dist/index.iife.js +296 -220
- package/dist/index.iife.js.map +1 -1
- package/dist/{index.js → index.mjs} +295 -218
- package/dist/index.mjs.map +1 -0
- package/package.json +10 -10
- package/dist/index.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import createClient from "openapi-fetch";
|
|
2
2
|
import { decodeJwt } from "jose";
|
|
3
3
|
|
|
4
|
-
//#region ../sdk-core/dist/index.
|
|
4
|
+
//#region ../sdk-core/dist/index.mjs
|
|
5
5
|
/**
|
|
6
6
|
* Response utilities for debugging and working with Response objects
|
|
7
7
|
*/
|
|
@@ -308,6 +308,10 @@ async function executeRequest(apiCall) {
|
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
/**
|
|
311
|
+
* Base API client for Commerce Engine SDKs
|
|
312
|
+
* Provides common functionality without token management
|
|
313
|
+
*/
|
|
314
|
+
/**
|
|
311
315
|
* Generic base API client that all Commerce Engine SDKs can extend
|
|
312
316
|
* Handles common functionality like middleware setup, request execution, and header management
|
|
313
317
|
* Does NOT include token management - that's SDK-specific
|
|
@@ -1828,6 +1832,130 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1828
1832
|
}));
|
|
1829
1833
|
}
|
|
1830
1834
|
/**
|
|
1835
|
+
* Get all available coupons
|
|
1836
|
+
*
|
|
1837
|
+
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1838
|
+
* @returns Promise with all available coupons
|
|
1839
|
+
* @example
|
|
1840
|
+
* ```typescript
|
|
1841
|
+
* // Get all available coupons
|
|
1842
|
+
* const { data, error } = await sdk.cart.getAvailableCoupons();
|
|
1843
|
+
*
|
|
1844
|
+
* if (error) {
|
|
1845
|
+
* console.error("Failed to get available coupons:", error.message);
|
|
1846
|
+
* } else {
|
|
1847
|
+
* const coupons = data.coupons || [];
|
|
1848
|
+
* console.log("Available coupons:", coupons.length);
|
|
1849
|
+
* coupons.forEach(coupon => {
|
|
1850
|
+
* console.log("Coupon:", coupon.code, "Discount:", coupon.discount_amount);
|
|
1851
|
+
* });
|
|
1852
|
+
* }
|
|
1853
|
+
*
|
|
1854
|
+
* // Override customer group ID for this specific request
|
|
1855
|
+
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailableCoupons({
|
|
1856
|
+
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
1857
|
+
* });
|
|
1858
|
+
* ```
|
|
1859
|
+
*/
|
|
1860
|
+
async getAvailableCoupons(headers) {
|
|
1861
|
+
const mergedHeaders = this.mergeHeaders(headers);
|
|
1862
|
+
return this.executeRequest(() => this.client.GET("/carts/available-coupons", { params: { header: mergedHeaders } }));
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
* Get all available promotions
|
|
1866
|
+
*
|
|
1867
|
+
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
1868
|
+
* @returns Promise with all available promotions
|
|
1869
|
+
* @example
|
|
1870
|
+
* ```typescript
|
|
1871
|
+
* // Get all available promotions
|
|
1872
|
+
* const { data, error } = await sdk.cart.getAvailablePromotions();
|
|
1873
|
+
*
|
|
1874
|
+
* if (error) {
|
|
1875
|
+
* console.error("Failed to get available promotions:", error.message);
|
|
1876
|
+
* } else {
|
|
1877
|
+
* const promotions = data.promotions || [];
|
|
1878
|
+
* console.log("Available promotions:", promotions.length);
|
|
1879
|
+
* promotions.forEach(promotion => {
|
|
1880
|
+
* console.log("Promotion:", promotion.name, "Type:", promotion.promotion_type);
|
|
1881
|
+
* });
|
|
1882
|
+
* }
|
|
1883
|
+
*
|
|
1884
|
+
* // Override customer group ID for this specific request
|
|
1885
|
+
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailablePromotions({
|
|
1886
|
+
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
1887
|
+
* });
|
|
1888
|
+
* ```
|
|
1889
|
+
*/
|
|
1890
|
+
async getAvailablePromotions(headers) {
|
|
1891
|
+
const mergedHeaders = this.mergeHeaders(headers);
|
|
1892
|
+
return this.executeRequest(() => this.client.GET("/carts/available-promotions", { params: { header: mergedHeaders } }));
|
|
1893
|
+
}
|
|
1894
|
+
/**
|
|
1895
|
+
* Evaluate promotions
|
|
1896
|
+
*
|
|
1897
|
+
* @param cartId - The ID of the cart
|
|
1898
|
+
* @returns Promise with evaluated promotions
|
|
1899
|
+
* @example
|
|
1900
|
+
* ```typescript
|
|
1901
|
+
* const { data, error } = await sdk.cart.evaluatePromotions({
|
|
1902
|
+
* id: "01H9CART12345ABCDE"
|
|
1903
|
+
* });
|
|
1904
|
+
*
|
|
1905
|
+
* if (error) {
|
|
1906
|
+
* console.error("Failed to evaluate promotions:", error.message);
|
|
1907
|
+
* } else {
|
|
1908
|
+
* const applicable = data.applicable_promotions || [];
|
|
1909
|
+
* const inapplicable = data.inapplicable_promotions || [];
|
|
1910
|
+
*
|
|
1911
|
+
* console.log("Applicable promotions:", applicable.length);
|
|
1912
|
+
* applicable.forEach(promo => {
|
|
1913
|
+
* console.log(`- ${promo.name}: ${promo.savings_message}`);
|
|
1914
|
+
* });
|
|
1915
|
+
*
|
|
1916
|
+
* console.log("Inapplicable promotions:", inapplicable.length);
|
|
1917
|
+
* inapplicable.forEach(promo => {
|
|
1918
|
+
* console.log(`- ${promo.name}: ${promo.reason}`);
|
|
1919
|
+
* });
|
|
1920
|
+
* }
|
|
1921
|
+
* ```
|
|
1922
|
+
*/
|
|
1923
|
+
async evaluatePromotions(cartId) {
|
|
1924
|
+
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-promotions", { params: { path: cartId } }));
|
|
1925
|
+
}
|
|
1926
|
+
/**
|
|
1927
|
+
* Evaluate coupons
|
|
1928
|
+
*
|
|
1929
|
+
* @param cartId - The ID of the cart
|
|
1930
|
+
* @returns Promise with evaluated coupons
|
|
1931
|
+
* @example
|
|
1932
|
+
* ```typescript
|
|
1933
|
+
* const { data, error } = await sdk.cart.evaluateCoupons({
|
|
1934
|
+
* id: "01H9CART12345ABCDE"
|
|
1935
|
+
* });
|
|
1936
|
+
*
|
|
1937
|
+
* if (error) {
|
|
1938
|
+
* console.error("Failed to evaluate coupons:", error.message);
|
|
1939
|
+
* } else {
|
|
1940
|
+
* const applicable = data.applicable_coupons || [];
|
|
1941
|
+
* const inapplicable = data.inapplicable_coupons || [];
|
|
1942
|
+
*
|
|
1943
|
+
* console.log("Applicable coupons:", applicable.length);
|
|
1944
|
+
* applicable.forEach(coupon => {
|
|
1945
|
+
* console.log(`- ${coupon.code}: Save $${coupon.estimated_discount}`);
|
|
1946
|
+
* });
|
|
1947
|
+
*
|
|
1948
|
+
* console.log("Inapplicable coupons:", inapplicable.length);
|
|
1949
|
+
* inapplicable.forEach(coupon => {
|
|
1950
|
+
* console.log(`- ${coupon.code}: ${coupon.reason}`);
|
|
1951
|
+
* });
|
|
1952
|
+
* }
|
|
1953
|
+
* ```
|
|
1954
|
+
*/
|
|
1955
|
+
async evaluateCoupons(cartId) {
|
|
1956
|
+
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-coupons", { params: { path: cartId } }));
|
|
1957
|
+
}
|
|
1958
|
+
/**
|
|
1831
1959
|
* Redeem loyalty points
|
|
1832
1960
|
*
|
|
1833
1961
|
* @param cartId - The ID of the cart
|
|
@@ -1886,12 +2014,18 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1886
2014
|
* @returns Promise with updated cart
|
|
1887
2015
|
* @example
|
|
1888
2016
|
* ```typescript
|
|
2017
|
+
* // For delivery fulfillment with shipments
|
|
1889
2018
|
* const { data, error } = await sdk.cart.updateFulfillmentPreference(
|
|
1890
2019
|
* { id: "01H9CART12345ABCDE" },
|
|
1891
2020
|
* {
|
|
1892
2021
|
* fulfillment_type: "delivery",
|
|
1893
|
-
*
|
|
1894
|
-
*
|
|
2022
|
+
* shipments: [
|
|
2023
|
+
* {
|
|
2024
|
+
* id: "01H9SHIP12345ABCDE",
|
|
2025
|
+
* shipping_provider_id: "01H9PROV12345FAST",
|
|
2026
|
+
* courier_company_id: "01H9COY12345FAST" // Optional
|
|
2027
|
+
* }
|
|
2028
|
+
* ]
|
|
1895
2029
|
* }
|
|
1896
2030
|
* );
|
|
1897
2031
|
*
|
|
@@ -1901,6 +2035,15 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1901
2035
|
* console.log("Fulfillment preference updated:", data.cart.fulfillment_preference?.fulfillment_type);
|
|
1902
2036
|
* console.log("Shipping cost:", data.cart.shipping_amount);
|
|
1903
2037
|
* }
|
|
2038
|
+
*
|
|
2039
|
+
* // For collect-in-store fulfillment
|
|
2040
|
+
* const { data: collectData, error: collectError } = await sdk.cart.updateFulfillmentPreference(
|
|
2041
|
+
* { id: "01H9CART12345ABCDE" },
|
|
2042
|
+
* {
|
|
2043
|
+
* fulfillment_type: "collect-in-store",
|
|
2044
|
+
* pickup_location_id: "01H9STORE12345ABC"
|
|
2045
|
+
* }
|
|
2046
|
+
* );
|
|
1904
2047
|
* ```
|
|
1905
2048
|
*/
|
|
1906
2049
|
async updateFulfillmentPreference(cartId, body) {
|
|
@@ -1910,6 +2053,100 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1910
2053
|
}));
|
|
1911
2054
|
}
|
|
1912
2055
|
/**
|
|
2056
|
+
* Check fulfillment serviceability
|
|
2057
|
+
*
|
|
2058
|
+
* Checks if fulfillment (delivery or collect-in-store) is available to the specified pincode
|
|
2059
|
+
* based on shipping zones and inventories.
|
|
2060
|
+
*
|
|
2061
|
+
* @param body - Fulfillment check body (cart-based or items-based)
|
|
2062
|
+
* @returns Promise with fulfillment serviceability result
|
|
2063
|
+
* @example
|
|
2064
|
+
* ```typescript
|
|
2065
|
+
* // Cart-based fulfillment check
|
|
2066
|
+
* const { data, error } = await sdk.cart.checkPincodeDeliverability({
|
|
2067
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2068
|
+
* delivery_pincode: "400001",
|
|
2069
|
+
* fulfillment_type: "delivery" // optional: "delivery" | "collect-in-store"
|
|
2070
|
+
* });
|
|
2071
|
+
*
|
|
2072
|
+
* // Items-based fulfillment check
|
|
2073
|
+
* const { data, error } = await sdk.cart.checkPincodeDeliverability({
|
|
2074
|
+
* delivery_pincode: "400001",
|
|
2075
|
+
* items: [
|
|
2076
|
+
* { product_id: "prod_123", variant_id: "var_456" },
|
|
2077
|
+
* { product_id: "prod_789", variant_id: null }
|
|
2078
|
+
* ]
|
|
2079
|
+
* // fulfillment_type is optional
|
|
2080
|
+
* });
|
|
2081
|
+
*
|
|
2082
|
+
* if (error) {
|
|
2083
|
+
* console.error("Failed to check fulfillment serviceability:", error.message);
|
|
2084
|
+
* } else {
|
|
2085
|
+
* console.log("Serviceable:", data.is_serviceable);
|
|
2086
|
+
*
|
|
2087
|
+
* if (!data.is_serviceable && data.unserviceable_items) {
|
|
2088
|
+
* data.unserviceable_items.forEach(item => {
|
|
2089
|
+
* console.log(`Unserviceable: ${item.product_name}, max available: ${item.max_available_quantity}`);
|
|
2090
|
+
* });
|
|
2091
|
+
* }
|
|
2092
|
+
* }
|
|
2093
|
+
* ```
|
|
2094
|
+
*/
|
|
2095
|
+
async checkPincodeDeliverability(body) {
|
|
2096
|
+
return this.executeRequest(() => this.client.POST("/fulfillment/serviceability", { body }));
|
|
2097
|
+
}
|
|
2098
|
+
/**
|
|
2099
|
+
* Get fulfillment options for an order
|
|
2100
|
+
*
|
|
2101
|
+
* @param body - Fulfillment options body containing cart_id and delivery_pincode
|
|
2102
|
+
* @returns Promise with fulfillment options including collect and delivery methods
|
|
2103
|
+
* @example
|
|
2104
|
+
* ```typescript
|
|
2105
|
+
* const { data, error } = await sdk.cart.getFulfillmentOptions({
|
|
2106
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2107
|
+
* delivery_pincode: "400001"
|
|
2108
|
+
* });
|
|
2109
|
+
*
|
|
2110
|
+
* if (error) {
|
|
2111
|
+
* console.error("Failed to get fulfillment options:", error.message);
|
|
2112
|
+
* } else {
|
|
2113
|
+
* // Check summary information
|
|
2114
|
+
* console.log("Collect available:", data.summary.collect_available);
|
|
2115
|
+
* console.log("Deliver available:", data.summary.deliver_available);
|
|
2116
|
+
* console.log("Recommended fulfillment type:", data.summary.recommended_fulfillment_type);
|
|
2117
|
+
*
|
|
2118
|
+
* // Access collect options
|
|
2119
|
+
* if (data.collect && data.collect.length > 0) {
|
|
2120
|
+
* console.log("Available stores for collection:");
|
|
2121
|
+
* data.collect.forEach(store => {
|
|
2122
|
+
* console.log(`${store.name} - ${store.distance_km}km away, ETA: ${store.collect_eta_minutes} minutes`);
|
|
2123
|
+
* });
|
|
2124
|
+
* }
|
|
2125
|
+
*
|
|
2126
|
+
* // Access delivery options (with shipments)
|
|
2127
|
+
* if (data.deliver && data.deliver.is_serviceable) {
|
|
2128
|
+
* console.log("Available shipments and shipping methods:");
|
|
2129
|
+
* data.deliver.shipments.forEach(shipment => {
|
|
2130
|
+
* console.log(`Shipment ${shipment.id}:`);
|
|
2131
|
+
* console.log(` Items: ${shipment.items.length}`);
|
|
2132
|
+
* shipment.shipping_methods.forEach(method => {
|
|
2133
|
+
* console.log(` - ${method.name}: ${method.shipping_amount}, ${method.estimated_delivery_days} days`);
|
|
2134
|
+
* // Access courier companies for auto shipping methods
|
|
2135
|
+
* if (method.courier_companies) {
|
|
2136
|
+
* method.courier_companies.forEach(courier => {
|
|
2137
|
+
* console.log(` Courier: ${courier.name} - ${courier.shipping_amount}, ${courier.estimated_delivery_days} days`);
|
|
2138
|
+
* });
|
|
2139
|
+
* }
|
|
2140
|
+
* });
|
|
2141
|
+
* });
|
|
2142
|
+
* }
|
|
2143
|
+
* }
|
|
2144
|
+
* ```
|
|
2145
|
+
*/
|
|
2146
|
+
async getFulfillmentOptions(body) {
|
|
2147
|
+
return this.executeRequest(() => this.client.POST("/carts/fulfillment-options", { body }));
|
|
2148
|
+
}
|
|
2149
|
+
/**
|
|
1913
2150
|
* Use credit balance
|
|
1914
2151
|
*
|
|
1915
2152
|
* @param cartId - The ID of the cart
|
|
@@ -2045,130 +2282,6 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
2045
2282
|
body
|
|
2046
2283
|
}));
|
|
2047
2284
|
}
|
|
2048
|
-
/**
|
|
2049
|
-
* Get all available coupons
|
|
2050
|
-
*
|
|
2051
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2052
|
-
* @returns Promise with all available coupons
|
|
2053
|
-
* @example
|
|
2054
|
-
* ```typescript
|
|
2055
|
-
* // Get all available coupons
|
|
2056
|
-
* const { data, error } = await sdk.cart.getAvailableCoupons();
|
|
2057
|
-
*
|
|
2058
|
-
* if (error) {
|
|
2059
|
-
* console.error("Failed to get available coupons:", error.message);
|
|
2060
|
-
* } else {
|
|
2061
|
-
* const coupons = data.coupons || [];
|
|
2062
|
-
* console.log("Available coupons:", coupons.length);
|
|
2063
|
-
* coupons.forEach(coupon => {
|
|
2064
|
-
* console.log("Coupon:", coupon.code, "Discount:", coupon.discount_amount);
|
|
2065
|
-
* });
|
|
2066
|
-
* }
|
|
2067
|
-
*
|
|
2068
|
-
* // Override customer group ID for this specific request
|
|
2069
|
-
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailableCoupons({
|
|
2070
|
-
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2071
|
-
* });
|
|
2072
|
-
* ```
|
|
2073
|
-
*/
|
|
2074
|
-
async getAvailableCoupons(headers) {
|
|
2075
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
2076
|
-
return this.executeRequest(() => this.client.GET("/carts/available-coupons", { params: { header: mergedHeaders } }));
|
|
2077
|
-
}
|
|
2078
|
-
/**
|
|
2079
|
-
* Get all available promotions
|
|
2080
|
-
*
|
|
2081
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2082
|
-
* @returns Promise with all available promotions
|
|
2083
|
-
* @example
|
|
2084
|
-
* ```typescript
|
|
2085
|
-
* // Get all available promotions
|
|
2086
|
-
* const { data, error } = await sdk.cart.getAvailablePromotions();
|
|
2087
|
-
*
|
|
2088
|
-
* if (error) {
|
|
2089
|
-
* console.error("Failed to get available promotions:", error.message);
|
|
2090
|
-
* } else {
|
|
2091
|
-
* const promotions = data.promotions || [];
|
|
2092
|
-
* console.log("Available promotions:", promotions.length);
|
|
2093
|
-
* promotions.forEach(promotion => {
|
|
2094
|
-
* console.log("Promotion:", promotion.name, "Type:", promotion.promotion_type);
|
|
2095
|
-
* });
|
|
2096
|
-
* }
|
|
2097
|
-
*
|
|
2098
|
-
* // Override customer group ID for this specific request
|
|
2099
|
-
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailablePromotions({
|
|
2100
|
-
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2101
|
-
* });
|
|
2102
|
-
* ```
|
|
2103
|
-
*/
|
|
2104
|
-
async getAvailablePromotions(headers) {
|
|
2105
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
2106
|
-
return this.executeRequest(() => this.client.GET("/carts/available-promotions", { params: { header: mergedHeaders } }));
|
|
2107
|
-
}
|
|
2108
|
-
/**
|
|
2109
|
-
* Evaluate promotions
|
|
2110
|
-
*
|
|
2111
|
-
* @param cartId - The ID of the cart
|
|
2112
|
-
* @returns Promise with evaluated promotions
|
|
2113
|
-
* @example
|
|
2114
|
-
* ```typescript
|
|
2115
|
-
* const { data, error } = await sdk.cart.evaluatePromotions({
|
|
2116
|
-
* id: "01H9CART12345ABCDE"
|
|
2117
|
-
* });
|
|
2118
|
-
*
|
|
2119
|
-
* if (error) {
|
|
2120
|
-
* console.error("Failed to evaluate promotions:", error.message);
|
|
2121
|
-
* } else {
|
|
2122
|
-
* const applicable = data.applicable_promotions || [];
|
|
2123
|
-
* const inapplicable = data.inapplicable_promotions || [];
|
|
2124
|
-
*
|
|
2125
|
-
* console.log("Applicable promotions:", applicable.length);
|
|
2126
|
-
* applicable.forEach(promo => {
|
|
2127
|
-
* console.log(`- ${promo.name}: ${promo.savings_message}`);
|
|
2128
|
-
* });
|
|
2129
|
-
*
|
|
2130
|
-
* console.log("Inapplicable promotions:", inapplicable.length);
|
|
2131
|
-
* inapplicable.forEach(promo => {
|
|
2132
|
-
* console.log(`- ${promo.name}: ${promo.reason}`);
|
|
2133
|
-
* });
|
|
2134
|
-
* }
|
|
2135
|
-
* ```
|
|
2136
|
-
*/
|
|
2137
|
-
async evaluatePromotions(cartId) {
|
|
2138
|
-
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-promotions", { params: { path: cartId } }));
|
|
2139
|
-
}
|
|
2140
|
-
/**
|
|
2141
|
-
* Evaluate coupons
|
|
2142
|
-
*
|
|
2143
|
-
* @param cartId - The ID of the cart
|
|
2144
|
-
* @returns Promise with evaluated coupons
|
|
2145
|
-
* @example
|
|
2146
|
-
* ```typescript
|
|
2147
|
-
* const { data, error } = await sdk.cart.evaluateCoupons({
|
|
2148
|
-
* id: "01H9CART12345ABCDE"
|
|
2149
|
-
* });
|
|
2150
|
-
*
|
|
2151
|
-
* if (error) {
|
|
2152
|
-
* console.error("Failed to evaluate coupons:", error.message);
|
|
2153
|
-
* } else {
|
|
2154
|
-
* const applicable = data.applicable_coupons || [];
|
|
2155
|
-
* const inapplicable = data.inapplicable_coupons || [];
|
|
2156
|
-
*
|
|
2157
|
-
* console.log("Applicable coupons:", applicable.length);
|
|
2158
|
-
* applicable.forEach(coupon => {
|
|
2159
|
-
* console.log(`- ${coupon.code}: Save $${coupon.estimated_discount}`);
|
|
2160
|
-
* });
|
|
2161
|
-
*
|
|
2162
|
-
* console.log("Inapplicable coupons:", inapplicable.length);
|
|
2163
|
-
* inapplicable.forEach(coupon => {
|
|
2164
|
-
* console.log(`- ${coupon.code}: ${coupon.reason}`);
|
|
2165
|
-
* });
|
|
2166
|
-
* }
|
|
2167
|
-
* ```
|
|
2168
|
-
*/
|
|
2169
|
-
async evaluateCoupons(cartId) {
|
|
2170
|
-
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-coupons", { params: { path: cartId } }));
|
|
2171
|
-
}
|
|
2172
2285
|
};
|
|
2173
2286
|
|
|
2174
2287
|
//#endregion
|
|
@@ -3216,10 +3329,14 @@ var PaymentsClient = class extends StorefrontAPIClient {
|
|
|
3216
3329
|
/**
|
|
3217
3330
|
* List all available payment methods
|
|
3218
3331
|
*
|
|
3332
|
+
* @param queryParams - Query parameters containing the payment method type and payment provider slug
|
|
3219
3333
|
* @returns Promise with list of payment methods
|
|
3220
3334
|
* @example
|
|
3221
3335
|
* ```typescript
|
|
3222
|
-
* const { data, error } = await sdk.payments.listPaymentMethods(
|
|
3336
|
+
* const { data, error } = await sdk.payments.listPaymentMethods({
|
|
3337
|
+
* payment_method_type: "card",
|
|
3338
|
+
* payment_provider_slug: "payu"
|
|
3339
|
+
* });
|
|
3223
3340
|
*
|
|
3224
3341
|
* if (error) {
|
|
3225
3342
|
* console.error("Failed to list payment methods:", error.message);
|
|
@@ -3233,8 +3350,8 @@ var PaymentsClient = class extends StorefrontAPIClient {
|
|
|
3233
3350
|
* }
|
|
3234
3351
|
* ```
|
|
3235
3352
|
*/
|
|
3236
|
-
async listPaymentMethods() {
|
|
3237
|
-
return this.executeRequest(() => this.client.GET("/payments/payment-methods", {}));
|
|
3353
|
+
async listPaymentMethods(queryParams) {
|
|
3354
|
+
return this.executeRequest(() => this.client.GET("/payments/payment-methods", { params: { query: queryParams } }));
|
|
3238
3355
|
}
|
|
3239
3356
|
/**
|
|
3240
3357
|
* Verify a UPI Virtual Payment Address (VPA)
|
|
@@ -3269,6 +3386,29 @@ var PaymentsClient = class extends StorefrontAPIClient {
|
|
|
3269
3386
|
return this.executeRequest(() => this.client.GET("/payments/verify-vpa", { params: { query: queryParams } }));
|
|
3270
3387
|
}
|
|
3271
3388
|
/**
|
|
3389
|
+
* Get card information
|
|
3390
|
+
*
|
|
3391
|
+
* Retrieves card information based on the initial 9 digits (card BIN) of the card number.
|
|
3392
|
+
*
|
|
3393
|
+
* @param queryParams - Query parameters containing the card BIN
|
|
3394
|
+
* @returns Promise with card information
|
|
3395
|
+
* @example
|
|
3396
|
+
* ```typescript
|
|
3397
|
+
* const { data, error } = await sdk.payments.getCardInfo({
|
|
3398
|
+
* cardbin: "411111111"
|
|
3399
|
+
* });
|
|
3400
|
+
*
|
|
3401
|
+
* if (error) {
|
|
3402
|
+
* console.error("Failed to get card information:", error.message);
|
|
3403
|
+
* } else {
|
|
3404
|
+
* console.log("Card information:", data.card_info);
|
|
3405
|
+
* }
|
|
3406
|
+
* ```
|
|
3407
|
+
*/
|
|
3408
|
+
async getCardInfo(queryParams) {
|
|
3409
|
+
return this.executeRequest(() => this.client.GET("/payments/card-info", { params: { query: queryParams } }));
|
|
3410
|
+
}
|
|
3411
|
+
/**
|
|
3272
3412
|
* Authenticate a direct OTP for payment verification
|
|
3273
3413
|
*
|
|
3274
3414
|
* @description Used to authenticate OTP during payment flows that require 2FA verification.
|
|
@@ -3327,82 +3467,6 @@ var PaymentsClient = class extends StorefrontAPIClient {
|
|
|
3327
3467
|
}
|
|
3328
3468
|
};
|
|
3329
3469
|
|
|
3330
|
-
//#endregion
|
|
3331
|
-
//#region src/lib/shipping.ts
|
|
3332
|
-
/**
|
|
3333
|
-
* Client for interacting with shipping endpoints
|
|
3334
|
-
*/
|
|
3335
|
-
var ShippingClient = class extends StorefrontAPIClient {
|
|
3336
|
-
/**
|
|
3337
|
-
* Check pincode deliverability
|
|
3338
|
-
*
|
|
3339
|
-
* @param pathParams - Path parameters
|
|
3340
|
-
* @returns Promise with pincode deliverability result
|
|
3341
|
-
* @example
|
|
3342
|
-
* ```typescript
|
|
3343
|
-
* const { data, error } = await sdk.shipping.checkPincodeDeliverability({
|
|
3344
|
-
* pincode: "400001"
|
|
3345
|
-
* });
|
|
3346
|
-
*
|
|
3347
|
-
* if (error) {
|
|
3348
|
-
* console.error("Failed to check pincode serviceability:", error.message);
|
|
3349
|
-
* } else {
|
|
3350
|
-
* console.log("Pincode serviceable:", data.is_serviceable);
|
|
3351
|
-
*
|
|
3352
|
-
* if (data.is_serviceable) {
|
|
3353
|
-
* console.log("Delivery is available to this pincode");
|
|
3354
|
-
* } else {
|
|
3355
|
-
* console.log("Delivery is not available to this pincode");
|
|
3356
|
-
* }
|
|
3357
|
-
* }
|
|
3358
|
-
* ```
|
|
3359
|
-
*/
|
|
3360
|
-
async checkPincodeDeliverability(pathParams) {
|
|
3361
|
-
return this.executeRequest(() => this.client.GET("/shipping/serviceability/{pincode}", { params: { path: pathParams } }));
|
|
3362
|
-
}
|
|
3363
|
-
/**
|
|
3364
|
-
* Get fulfillment options for an order
|
|
3365
|
-
*
|
|
3366
|
-
* @param body - Fulfillment options body containing cart_id and delivery_pincode
|
|
3367
|
-
* @returns Promise with fulfillment options including collect and delivery methods
|
|
3368
|
-
* @example
|
|
3369
|
-
* ```typescript
|
|
3370
|
-
* const { data, error } = await sdk.shipping.getFulfillmentOptions({
|
|
3371
|
-
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
3372
|
-
* delivery_pincode: "400001"
|
|
3373
|
-
* });
|
|
3374
|
-
*
|
|
3375
|
-
* if (error) {
|
|
3376
|
-
* console.error("Failed to get fulfillment options:", error.message);
|
|
3377
|
-
* } else {
|
|
3378
|
-
* // Check summary information
|
|
3379
|
-
* console.log("Collect available:", data.summary.collect_available);
|
|
3380
|
-
* console.log("Deliver available:", data.summary.deliver_available);
|
|
3381
|
-
* console.log("Recommended fulfillment type:", data.summary.recommended_fulfillment_type);
|
|
3382
|
-
*
|
|
3383
|
-
* // Access collect options
|
|
3384
|
-
* if (data.collect && data.collect.length > 0) {
|
|
3385
|
-
* console.log("Available stores for collection:");
|
|
3386
|
-
* data.collect.forEach(store => {
|
|
3387
|
-
* console.log(`${store.name} - ${store.distance_km}km away, ETA: ${store.collect_eta_minutes} minutes`);
|
|
3388
|
-
* });
|
|
3389
|
-
* }
|
|
3390
|
-
*
|
|
3391
|
-
* // Access delivery options
|
|
3392
|
-
* if (data.deliver && data.deliver.is_serviceable) {
|
|
3393
|
-
* console.log("Available shipping methods:");
|
|
3394
|
-
* data.deliver.shipping_methods.forEach(method => {
|
|
3395
|
-
* console.log(`${method.name} - ${method.shipping_amount}, ${method.estimated_delivery_days} days`);
|
|
3396
|
-
* });
|
|
3397
|
-
* }
|
|
3398
|
-
* }
|
|
3399
|
-
* ```
|
|
3400
|
-
*/
|
|
3401
|
-
async getFulfillmentOptions(body) {
|
|
3402
|
-
return this.executeRequest(() => this.client.POST("/shipping/fulfillment-options", { body }));
|
|
3403
|
-
}
|
|
3404
|
-
};
|
|
3405
|
-
|
|
3406
3470
|
//#endregion
|
|
3407
3471
|
//#region src/lib/helper.ts
|
|
3408
3472
|
/**
|
|
@@ -3860,6 +3924,29 @@ var CustomerClient = class extends StorefrontAPIClient {
|
|
|
3860
3924
|
async listSavedPaymentMethods(pathParams) {
|
|
3861
3925
|
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/payment-methods", { params: { path: pathParams } }));
|
|
3862
3926
|
}
|
|
3927
|
+
/**
|
|
3928
|
+
* List all saved cards for a customer
|
|
3929
|
+
*
|
|
3930
|
+
* @param pathParams - Path parameters
|
|
3931
|
+
* @returns Promise with cards
|
|
3932
|
+
*
|
|
3933
|
+
* @example
|
|
3934
|
+
* ```typescript
|
|
3935
|
+
* const { data, error } = await sdk.customer.listCustomerCards({
|
|
3936
|
+
* customer_id: "customer_123"
|
|
3937
|
+
* });
|
|
3938
|
+
*
|
|
3939
|
+
* if (error) {
|
|
3940
|
+
* console.error("Failed to list customer cards:", error);
|
|
3941
|
+
* return;
|
|
3942
|
+
* }
|
|
3943
|
+
*
|
|
3944
|
+
* console.log("Customer cards:", data.cards);
|
|
3945
|
+
* ```
|
|
3946
|
+
*/
|
|
3947
|
+
async listCustomerCards(pathParams) {
|
|
3948
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/cards", { params: { path: pathParams } }));
|
|
3949
|
+
}
|
|
3863
3950
|
};
|
|
3864
3951
|
|
|
3865
3952
|
//#endregion
|
|
@@ -3922,10 +4009,6 @@ var StorefrontSDK = class {
|
|
|
3922
4009
|
*/
|
|
3923
4010
|
helpers;
|
|
3924
4011
|
/**
|
|
3925
|
-
* Client for shipping-related endpoints
|
|
3926
|
-
*/
|
|
3927
|
-
shipping;
|
|
3928
|
-
/**
|
|
3929
4012
|
* Client for order-related endpoints
|
|
3930
4013
|
*/
|
|
3931
4014
|
order;
|
|
@@ -3968,7 +4051,6 @@ var StorefrontSDK = class {
|
|
|
3968
4051
|
this.auth = new AuthClient(config);
|
|
3969
4052
|
this.customer = new CustomerClient(config);
|
|
3970
4053
|
this.helpers = new HelpersClient(config);
|
|
3971
|
-
this.shipping = new ShippingClient(config);
|
|
3972
4054
|
this.order = new OrderClient(config);
|
|
3973
4055
|
this.payments = new PaymentsClient(config);
|
|
3974
4056
|
this.store = new StoreConfigClient(config);
|
|
@@ -3989,7 +4071,6 @@ var StorefrontSDK = class {
|
|
|
3989
4071
|
await this.auth.setTokens(accessToken, refreshToken);
|
|
3990
4072
|
await this.customer.setTokens(accessToken, refreshToken);
|
|
3991
4073
|
await this.helpers.setTokens(accessToken, refreshToken);
|
|
3992
|
-
await this.shipping.setTokens(accessToken, refreshToken);
|
|
3993
4074
|
await this.order.setTokens(accessToken, refreshToken);
|
|
3994
4075
|
await this.payments.setTokens(accessToken, refreshToken);
|
|
3995
4076
|
await this.store.setTokens(accessToken, refreshToken);
|
|
@@ -4007,7 +4088,6 @@ var StorefrontSDK = class {
|
|
|
4007
4088
|
await this.auth.clearTokens();
|
|
4008
4089
|
await this.customer.clearTokens();
|
|
4009
4090
|
await this.helpers.clearTokens();
|
|
4010
|
-
await this.shipping.clearTokens();
|
|
4011
4091
|
await this.order.clearTokens();
|
|
4012
4092
|
await this.payments.clearTokens();
|
|
4013
4093
|
await this.store.clearTokens();
|
|
@@ -4023,7 +4103,6 @@ var StorefrontSDK = class {
|
|
|
4023
4103
|
this.auth.setApiKey(apiKey);
|
|
4024
4104
|
this.customer.setApiKey(apiKey);
|
|
4025
4105
|
this.helpers.setApiKey(apiKey);
|
|
4026
|
-
this.shipping.setApiKey(apiKey);
|
|
4027
4106
|
this.order.setApiKey(apiKey);
|
|
4028
4107
|
this.payments.setApiKey(apiKey);
|
|
4029
4108
|
this.store.setApiKey(apiKey);
|
|
@@ -4037,7 +4116,6 @@ var StorefrontSDK = class {
|
|
|
4037
4116
|
this.auth.clearApiKey();
|
|
4038
4117
|
this.customer.clearApiKey();
|
|
4039
4118
|
this.helpers.clearApiKey();
|
|
4040
|
-
this.shipping.clearApiKey();
|
|
4041
4119
|
this.order.clearApiKey();
|
|
4042
4120
|
this.payments.clearApiKey();
|
|
4043
4121
|
this.store.clearApiKey();
|
|
@@ -4116,7 +4194,6 @@ var StorefrontSDK = class {
|
|
|
4116
4194
|
this.auth.setDefaultHeaders(headers);
|
|
4117
4195
|
this.customer.setDefaultHeaders(headers);
|
|
4118
4196
|
this.helpers.setDefaultHeaders(headers);
|
|
4119
|
-
this.shipping.setDefaultHeaders(headers);
|
|
4120
4197
|
this.order.setDefaultHeaders(headers);
|
|
4121
4198
|
this.payments.setDefaultHeaders(headers);
|
|
4122
4199
|
this.store.setDefaultHeaders(headers);
|
|
@@ -4133,5 +4210,5 @@ var StorefrontSDK = class {
|
|
|
4133
4210
|
var src_default = StorefrontSDK;
|
|
4134
4211
|
|
|
4135
4212
|
//#endregion
|
|
4136
|
-
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, PaymentsClient, ResponseUtils,
|
|
4137
|
-
//# sourceMappingURL=index.
|
|
4213
|
+
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, PaymentsClient, ResponseUtils, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, src_default as default };
|
|
4214
|
+
//# sourceMappingURL=index.mjs.map
|