@commercengine/storefront-sdk 0.11.1 → 0.12.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/dist/index.d.mts +801 -396
- package/dist/index.iife.js +311 -224
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +312 -224
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1832,6 +1832,130 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1832
1832
|
}));
|
|
1833
1833
|
}
|
|
1834
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
|
+
/**
|
|
1835
1959
|
* Redeem loyalty points
|
|
1836
1960
|
*
|
|
1837
1961
|
* @param cartId - The ID of the cart
|
|
@@ -1890,12 +2014,18 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1890
2014
|
* @returns Promise with updated cart
|
|
1891
2015
|
* @example
|
|
1892
2016
|
* ```typescript
|
|
2017
|
+
* // For delivery fulfillment with shipments
|
|
1893
2018
|
* const { data, error } = await sdk.cart.updateFulfillmentPreference(
|
|
1894
2019
|
* { id: "01H9CART12345ABCDE" },
|
|
1895
2020
|
* {
|
|
1896
2021
|
* fulfillment_type: "delivery",
|
|
1897
|
-
*
|
|
1898
|
-
*
|
|
2022
|
+
* shipments: [
|
|
2023
|
+
* {
|
|
2024
|
+
* id: "01H9SHIP12345ABCDE",
|
|
2025
|
+
* shipping_provider_id: "01H9PROV12345FAST",
|
|
2026
|
+
* courier_company_id: "01H9COY12345FAST" // Optional
|
|
2027
|
+
* }
|
|
2028
|
+
* ]
|
|
1899
2029
|
* }
|
|
1900
2030
|
* );
|
|
1901
2031
|
*
|
|
@@ -1905,6 +2035,15 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1905
2035
|
* console.log("Fulfillment preference updated:", data.cart.fulfillment_preference?.fulfillment_type);
|
|
1906
2036
|
* console.log("Shipping cost:", data.cart.shipping_amount);
|
|
1907
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
|
+
* );
|
|
1908
2047
|
* ```
|
|
1909
2048
|
*/
|
|
1910
2049
|
async updateFulfillmentPreference(cartId, body) {
|
|
@@ -1914,6 +2053,103 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
1914
2053
|
}));
|
|
1915
2054
|
}
|
|
1916
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 optional fulfillment_type
|
|
2102
|
+
* @returns Promise with fulfillment options including collect and delivery methods. The response contains:
|
|
2103
|
+
* - `summary`: Object with `collect_available`, `deliver_available`, `recommended_fulfillment_type`, and optional `recommended_store`
|
|
2104
|
+
* - `collect`: Optional array of `CollectInStore` objects for collect-in-store options
|
|
2105
|
+
* - `deliver`: Optional `DeliveryOption` object with `is_serviceable` and `shipments` array. Each shipment contains `id`, `items`, and `shipping_methods` array. Shipping methods may have optional `courier_companies` for auto shipping types.
|
|
2106
|
+
* @example
|
|
2107
|
+
* ```typescript
|
|
2108
|
+
* const { data, error } = await sdk.cart.getFulfillmentOptions({
|
|
2109
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2110
|
+
* fulfillment_type: "delivery" // optional: "delivery" | "collect-in-store"
|
|
2111
|
+
* });
|
|
2112
|
+
*
|
|
2113
|
+
* if (error) {
|
|
2114
|
+
* console.error("Failed to get fulfillment options:", error.message);
|
|
2115
|
+
* } else {
|
|
2116
|
+
* // Check summary information
|
|
2117
|
+
* console.log("Collect available:", data.summary.collect_available);
|
|
2118
|
+
* console.log("Deliver available:", data.summary.deliver_available);
|
|
2119
|
+
* console.log("Recommended fulfillment type:", data.summary.recommended_fulfillment_type);
|
|
2120
|
+
*
|
|
2121
|
+
* // Access collect options
|
|
2122
|
+
* if (data.collect && data.collect.length > 0) {
|
|
2123
|
+
* console.log("Available stores for collection:");
|
|
2124
|
+
* data.collect.forEach(store => {
|
|
2125
|
+
* console.log(`${store.name} - ${store.distance_km}km away, ETA: ${store.collect_eta_minutes} minutes`);
|
|
2126
|
+
* });
|
|
2127
|
+
* }
|
|
2128
|
+
*
|
|
2129
|
+
* // Access delivery options (with shipments)
|
|
2130
|
+
* if (data.deliver && data.deliver.is_serviceable) {
|
|
2131
|
+
* console.log("Available shipments and shipping methods:");
|
|
2132
|
+
* data.deliver.shipments.forEach(shipment => {
|
|
2133
|
+
* console.log(`Shipment ${shipment.id}:`);
|
|
2134
|
+
* console.log(` Items: ${shipment.items.length}`);
|
|
2135
|
+
* shipment.shipping_methods.forEach(method => {
|
|
2136
|
+
* console.log(` - ${method.name}: ${method.shipping_amount}, ${method.estimated_delivery_days} days`);
|
|
2137
|
+
* // Access courier companies for auto shipping methods
|
|
2138
|
+
* if (method.courier_companies) {
|
|
2139
|
+
* method.courier_companies.forEach(courier => {
|
|
2140
|
+
* console.log(` Courier: ${courier.name} - ${courier.shipping_amount}, ${courier.estimated_delivery_days} days`);
|
|
2141
|
+
* });
|
|
2142
|
+
* }
|
|
2143
|
+
* });
|
|
2144
|
+
* });
|
|
2145
|
+
* }
|
|
2146
|
+
* }
|
|
2147
|
+
* ```
|
|
2148
|
+
*/
|
|
2149
|
+
async getFulfillmentOptions(body) {
|
|
2150
|
+
return this.executeRequest(() => this.client.POST("/carts/fulfillment-options", { body }));
|
|
2151
|
+
}
|
|
2152
|
+
/**
|
|
1917
2153
|
* Use credit balance
|
|
1918
2154
|
*
|
|
1919
2155
|
* @param cartId - The ID of the cart
|
|
@@ -2049,130 +2285,6 @@ var CartClient = class extends StorefrontAPIClient {
|
|
|
2049
2285
|
body
|
|
2050
2286
|
}));
|
|
2051
2287
|
}
|
|
2052
|
-
/**
|
|
2053
|
-
* Get all available coupons
|
|
2054
|
-
*
|
|
2055
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2056
|
-
* @returns Promise with all available coupons
|
|
2057
|
-
* @example
|
|
2058
|
-
* ```typescript
|
|
2059
|
-
* // Get all available coupons
|
|
2060
|
-
* const { data, error } = await sdk.cart.getAvailableCoupons();
|
|
2061
|
-
*
|
|
2062
|
-
* if (error) {
|
|
2063
|
-
* console.error("Failed to get available coupons:", error.message);
|
|
2064
|
-
* } else {
|
|
2065
|
-
* const coupons = data.coupons || [];
|
|
2066
|
-
* console.log("Available coupons:", coupons.length);
|
|
2067
|
-
* coupons.forEach(coupon => {
|
|
2068
|
-
* console.log("Coupon:", coupon.code, "Discount:", coupon.discount_amount);
|
|
2069
|
-
* });
|
|
2070
|
-
* }
|
|
2071
|
-
*
|
|
2072
|
-
* // Override customer group ID for this specific request
|
|
2073
|
-
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailableCoupons({
|
|
2074
|
-
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2075
|
-
* });
|
|
2076
|
-
* ```
|
|
2077
|
-
*/
|
|
2078
|
-
async getAvailableCoupons(headers) {
|
|
2079
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
2080
|
-
return this.executeRequest(() => this.client.GET("/carts/available-coupons", { params: { header: mergedHeaders } }));
|
|
2081
|
-
}
|
|
2082
|
-
/**
|
|
2083
|
-
* Get all available promotions
|
|
2084
|
-
*
|
|
2085
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2086
|
-
* @returns Promise with all available promotions
|
|
2087
|
-
* @example
|
|
2088
|
-
* ```typescript
|
|
2089
|
-
* // Get all available promotions
|
|
2090
|
-
* const { data, error } = await sdk.cart.getAvailablePromotions();
|
|
2091
|
-
*
|
|
2092
|
-
* if (error) {
|
|
2093
|
-
* console.error("Failed to get available promotions:", error.message);
|
|
2094
|
-
* } else {
|
|
2095
|
-
* const promotions = data.promotions || [];
|
|
2096
|
-
* console.log("Available promotions:", promotions.length);
|
|
2097
|
-
* promotions.forEach(promotion => {
|
|
2098
|
-
* console.log("Promotion:", promotion.name, "Type:", promotion.promotion_type);
|
|
2099
|
-
* });
|
|
2100
|
-
* }
|
|
2101
|
-
*
|
|
2102
|
-
* // Override customer group ID for this specific request
|
|
2103
|
-
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailablePromotions({
|
|
2104
|
-
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2105
|
-
* });
|
|
2106
|
-
* ```
|
|
2107
|
-
*/
|
|
2108
|
-
async getAvailablePromotions(headers) {
|
|
2109
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
2110
|
-
return this.executeRequest(() => this.client.GET("/carts/available-promotions", { params: { header: mergedHeaders } }));
|
|
2111
|
-
}
|
|
2112
|
-
/**
|
|
2113
|
-
* Evaluate promotions
|
|
2114
|
-
*
|
|
2115
|
-
* @param cartId - The ID of the cart
|
|
2116
|
-
* @returns Promise with evaluated promotions
|
|
2117
|
-
* @example
|
|
2118
|
-
* ```typescript
|
|
2119
|
-
* const { data, error } = await sdk.cart.evaluatePromotions({
|
|
2120
|
-
* id: "01H9CART12345ABCDE"
|
|
2121
|
-
* });
|
|
2122
|
-
*
|
|
2123
|
-
* if (error) {
|
|
2124
|
-
* console.error("Failed to evaluate promotions:", error.message);
|
|
2125
|
-
* } else {
|
|
2126
|
-
* const applicable = data.applicable_promotions || [];
|
|
2127
|
-
* const inapplicable = data.inapplicable_promotions || [];
|
|
2128
|
-
*
|
|
2129
|
-
* console.log("Applicable promotions:", applicable.length);
|
|
2130
|
-
* applicable.forEach(promo => {
|
|
2131
|
-
* console.log(`- ${promo.name}: ${promo.savings_message}`);
|
|
2132
|
-
* });
|
|
2133
|
-
*
|
|
2134
|
-
* console.log("Inapplicable promotions:", inapplicable.length);
|
|
2135
|
-
* inapplicable.forEach(promo => {
|
|
2136
|
-
* console.log(`- ${promo.name}: ${promo.reason}`);
|
|
2137
|
-
* });
|
|
2138
|
-
* }
|
|
2139
|
-
* ```
|
|
2140
|
-
*/
|
|
2141
|
-
async evaluatePromotions(cartId) {
|
|
2142
|
-
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-promotions", { params: { path: cartId } }));
|
|
2143
|
-
}
|
|
2144
|
-
/**
|
|
2145
|
-
* Evaluate coupons
|
|
2146
|
-
*
|
|
2147
|
-
* @param cartId - The ID of the cart
|
|
2148
|
-
* @returns Promise with evaluated coupons
|
|
2149
|
-
* @example
|
|
2150
|
-
* ```typescript
|
|
2151
|
-
* const { data, error } = await sdk.cart.evaluateCoupons({
|
|
2152
|
-
* id: "01H9CART12345ABCDE"
|
|
2153
|
-
* });
|
|
2154
|
-
*
|
|
2155
|
-
* if (error) {
|
|
2156
|
-
* console.error("Failed to evaluate coupons:", error.message);
|
|
2157
|
-
* } else {
|
|
2158
|
-
* const applicable = data.applicable_coupons || [];
|
|
2159
|
-
* const inapplicable = data.inapplicable_coupons || [];
|
|
2160
|
-
*
|
|
2161
|
-
* console.log("Applicable coupons:", applicable.length);
|
|
2162
|
-
* applicable.forEach(coupon => {
|
|
2163
|
-
* console.log(`- ${coupon.code}: Save $${coupon.estimated_discount}`);
|
|
2164
|
-
* });
|
|
2165
|
-
*
|
|
2166
|
-
* console.log("Inapplicable coupons:", inapplicable.length);
|
|
2167
|
-
* inapplicable.forEach(coupon => {
|
|
2168
|
-
* console.log(`- ${coupon.code}: ${coupon.reason}`);
|
|
2169
|
-
* });
|
|
2170
|
-
* }
|
|
2171
|
-
* ```
|
|
2172
|
-
*/
|
|
2173
|
-
async evaluateCoupons(cartId) {
|
|
2174
|
-
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-coupons", { params: { path: cartId } }));
|
|
2175
|
-
}
|
|
2176
2288
|
};
|
|
2177
2289
|
|
|
2178
2290
|
//#endregion
|
|
@@ -3220,10 +3332,14 @@ var PaymentsClient = class extends StorefrontAPIClient {
|
|
|
3220
3332
|
/**
|
|
3221
3333
|
* List all available payment methods
|
|
3222
3334
|
*
|
|
3335
|
+
* @param queryParams - Query parameters containing the payment method type and payment provider slug
|
|
3223
3336
|
* @returns Promise with list of payment methods
|
|
3224
3337
|
* @example
|
|
3225
3338
|
* ```typescript
|
|
3226
|
-
* const { data, error } = await sdk.payments.listPaymentMethods(
|
|
3339
|
+
* const { data, error } = await sdk.payments.listPaymentMethods({
|
|
3340
|
+
* payment_method_type: "card",
|
|
3341
|
+
* payment_provider_slug: "payu"
|
|
3342
|
+
* });
|
|
3227
3343
|
*
|
|
3228
3344
|
* if (error) {
|
|
3229
3345
|
* console.error("Failed to list payment methods:", error.message);
|
|
@@ -3237,8 +3353,8 @@ var PaymentsClient = class extends StorefrontAPIClient {
|
|
|
3237
3353
|
* }
|
|
3238
3354
|
* ```
|
|
3239
3355
|
*/
|
|
3240
|
-
async listPaymentMethods() {
|
|
3241
|
-
return this.executeRequest(() => this.client.GET("/payments/payment-methods", {}));
|
|
3356
|
+
async listPaymentMethods(queryParams) {
|
|
3357
|
+
return this.executeRequest(() => this.client.GET("/payments/payment-methods", { params: { query: queryParams } }));
|
|
3242
3358
|
}
|
|
3243
3359
|
/**
|
|
3244
3360
|
* Verify a UPI Virtual Payment Address (VPA)
|
|
@@ -3273,6 +3389,29 @@ var PaymentsClient = class extends StorefrontAPIClient {
|
|
|
3273
3389
|
return this.executeRequest(() => this.client.GET("/payments/verify-vpa", { params: { query: queryParams } }));
|
|
3274
3390
|
}
|
|
3275
3391
|
/**
|
|
3392
|
+
* Get card information
|
|
3393
|
+
*
|
|
3394
|
+
* Retrieves card information based on the initial 9 digits (card BIN) of the card number.
|
|
3395
|
+
*
|
|
3396
|
+
* @param queryParams - Query parameters containing the card BIN
|
|
3397
|
+
* @returns Promise with card information
|
|
3398
|
+
* @example
|
|
3399
|
+
* ```typescript
|
|
3400
|
+
* const { data, error } = await sdk.payments.getCardInfo({
|
|
3401
|
+
* cardbin: "411111111"
|
|
3402
|
+
* });
|
|
3403
|
+
*
|
|
3404
|
+
* if (error) {
|
|
3405
|
+
* console.error("Failed to get card information:", error.message);
|
|
3406
|
+
* } else {
|
|
3407
|
+
* console.log("Card information:", data.card_info);
|
|
3408
|
+
* }
|
|
3409
|
+
* ```
|
|
3410
|
+
*/
|
|
3411
|
+
async getCardInfo(queryParams) {
|
|
3412
|
+
return this.executeRequest(() => this.client.GET("/payments/card-info", { params: { query: queryParams } }));
|
|
3413
|
+
}
|
|
3414
|
+
/**
|
|
3276
3415
|
* Authenticate a direct OTP for payment verification
|
|
3277
3416
|
*
|
|
3278
3417
|
* @description Used to authenticate OTP during payment flows that require 2FA verification.
|
|
@@ -3331,82 +3470,6 @@ var PaymentsClient = class extends StorefrontAPIClient {
|
|
|
3331
3470
|
}
|
|
3332
3471
|
};
|
|
3333
3472
|
|
|
3334
|
-
//#endregion
|
|
3335
|
-
//#region src/lib/shipping.ts
|
|
3336
|
-
/**
|
|
3337
|
-
* Client for interacting with shipping endpoints
|
|
3338
|
-
*/
|
|
3339
|
-
var ShippingClient = class extends StorefrontAPIClient {
|
|
3340
|
-
/**
|
|
3341
|
-
* Check pincode deliverability
|
|
3342
|
-
*
|
|
3343
|
-
* @param pathParams - Path parameters
|
|
3344
|
-
* @returns Promise with pincode deliverability result
|
|
3345
|
-
* @example
|
|
3346
|
-
* ```typescript
|
|
3347
|
-
* const { data, error } = await sdk.shipping.checkPincodeDeliverability({
|
|
3348
|
-
* pincode: "400001"
|
|
3349
|
-
* });
|
|
3350
|
-
*
|
|
3351
|
-
* if (error) {
|
|
3352
|
-
* console.error("Failed to check pincode serviceability:", error.message);
|
|
3353
|
-
* } else {
|
|
3354
|
-
* console.log("Pincode serviceable:", data.is_serviceable);
|
|
3355
|
-
*
|
|
3356
|
-
* if (data.is_serviceable) {
|
|
3357
|
-
* console.log("Delivery is available to this pincode");
|
|
3358
|
-
* } else {
|
|
3359
|
-
* console.log("Delivery is not available to this pincode");
|
|
3360
|
-
* }
|
|
3361
|
-
* }
|
|
3362
|
-
* ```
|
|
3363
|
-
*/
|
|
3364
|
-
async checkPincodeDeliverability(pathParams) {
|
|
3365
|
-
return this.executeRequest(() => this.client.GET("/shipping/serviceability/{pincode}", { params: { path: pathParams } }));
|
|
3366
|
-
}
|
|
3367
|
-
/**
|
|
3368
|
-
* Get fulfillment options for an order
|
|
3369
|
-
*
|
|
3370
|
-
* @param body - Fulfillment options body containing cart_id and delivery_pincode
|
|
3371
|
-
* @returns Promise with fulfillment options including collect and delivery methods
|
|
3372
|
-
* @example
|
|
3373
|
-
* ```typescript
|
|
3374
|
-
* const { data, error } = await sdk.shipping.getFulfillmentOptions({
|
|
3375
|
-
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
3376
|
-
* delivery_pincode: "400001"
|
|
3377
|
-
* });
|
|
3378
|
-
*
|
|
3379
|
-
* if (error) {
|
|
3380
|
-
* console.error("Failed to get fulfillment options:", error.message);
|
|
3381
|
-
* } else {
|
|
3382
|
-
* // Check summary information
|
|
3383
|
-
* console.log("Collect available:", data.summary.collect_available);
|
|
3384
|
-
* console.log("Deliver available:", data.summary.deliver_available);
|
|
3385
|
-
* console.log("Recommended fulfillment type:", data.summary.recommended_fulfillment_type);
|
|
3386
|
-
*
|
|
3387
|
-
* // Access collect options
|
|
3388
|
-
* if (data.collect && data.collect.length > 0) {
|
|
3389
|
-
* console.log("Available stores for collection:");
|
|
3390
|
-
* data.collect.forEach(store => {
|
|
3391
|
-
* console.log(`${store.name} - ${store.distance_km}km away, ETA: ${store.collect_eta_minutes} minutes`);
|
|
3392
|
-
* });
|
|
3393
|
-
* }
|
|
3394
|
-
*
|
|
3395
|
-
* // Access delivery options
|
|
3396
|
-
* if (data.deliver && data.deliver.is_serviceable) {
|
|
3397
|
-
* console.log("Available shipping methods:");
|
|
3398
|
-
* data.deliver.shipping_methods.forEach(method => {
|
|
3399
|
-
* console.log(`${method.name} - ${method.shipping_amount}, ${method.estimated_delivery_days} days`);
|
|
3400
|
-
* });
|
|
3401
|
-
* }
|
|
3402
|
-
* }
|
|
3403
|
-
* ```
|
|
3404
|
-
*/
|
|
3405
|
-
async getFulfillmentOptions(body) {
|
|
3406
|
-
return this.executeRequest(() => this.client.POST("/shipping/fulfillment-options", { body }));
|
|
3407
|
-
}
|
|
3408
|
-
};
|
|
3409
|
-
|
|
3410
3473
|
//#endregion
|
|
3411
3474
|
//#region src/lib/helper.ts
|
|
3412
3475
|
/**
|
|
@@ -3517,8 +3580,11 @@ var HelpersClient = class extends StorefrontAPIClient {
|
|
|
3517
3580
|
* console.log("US Pincodes:", usPincodes.pincodes?.map(p => p.pincode).join(", "));
|
|
3518
3581
|
* ```
|
|
3519
3582
|
*/
|
|
3520
|
-
async listCountryPincodes(pathParams) {
|
|
3521
|
-
return this.executeRequest(() => this.client.GET("/common/countries/{country_iso_code}/pincodes", { params: {
|
|
3583
|
+
async listCountryPincodes(pathParams, queryParams) {
|
|
3584
|
+
return this.executeRequest(() => this.client.GET("/common/countries/{country_iso_code}/pincodes", { params: {
|
|
3585
|
+
path: pathParams,
|
|
3586
|
+
query: queryParams
|
|
3587
|
+
} }));
|
|
3522
3588
|
}
|
|
3523
3589
|
};
|
|
3524
3590
|
|
|
@@ -3638,8 +3704,11 @@ var CustomerClient = class extends StorefrontAPIClient {
|
|
|
3638
3704
|
* });
|
|
3639
3705
|
* ```
|
|
3640
3706
|
*/
|
|
3641
|
-
async listAddresses(pathParams) {
|
|
3642
|
-
return this.executeRequest(() => this.client.GET("/customers/{user_id}/addresses", { params: {
|
|
3707
|
+
async listAddresses(pathParams, queryParams) {
|
|
3708
|
+
return this.executeRequest(() => this.client.GET("/customers/{user_id}/addresses", { params: {
|
|
3709
|
+
path: pathParams,
|
|
3710
|
+
query: queryParams
|
|
3711
|
+
} }));
|
|
3643
3712
|
}
|
|
3644
3713
|
/**
|
|
3645
3714
|
* Create a new address for a customer
|
|
@@ -3814,8 +3883,11 @@ var CustomerClient = class extends StorefrontAPIClient {
|
|
|
3814
3883
|
* });
|
|
3815
3884
|
* ```
|
|
3816
3885
|
*/
|
|
3817
|
-
async listLoyaltyPointsActivity(pathParams) {
|
|
3818
|
-
return this.executeRequest(() => this.client.GET("/customers/{user_id}/loyalty-points-activity", { params: {
|
|
3886
|
+
async listLoyaltyPointsActivity(pathParams, queryParams) {
|
|
3887
|
+
return this.executeRequest(() => this.client.GET("/customers/{user_id}/loyalty-points-activity", { params: {
|
|
3888
|
+
path: pathParams,
|
|
3889
|
+
query: queryParams
|
|
3890
|
+
} }));
|
|
3819
3891
|
}
|
|
3820
3892
|
/**
|
|
3821
3893
|
* List all reviews left by a customer
|
|
@@ -3861,8 +3933,34 @@ var CustomerClient = class extends StorefrontAPIClient {
|
|
|
3861
3933
|
* console.log("Saved payment methods:", data.saved_payment_methods);
|
|
3862
3934
|
* ```
|
|
3863
3935
|
*/
|
|
3864
|
-
async listSavedPaymentMethods(pathParams) {
|
|
3865
|
-
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/payment-methods", { params: {
|
|
3936
|
+
async listSavedPaymentMethods(pathParams, queryParams) {
|
|
3937
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/payment-methods", { params: {
|
|
3938
|
+
path: pathParams,
|
|
3939
|
+
query: queryParams
|
|
3940
|
+
} }));
|
|
3941
|
+
}
|
|
3942
|
+
/**
|
|
3943
|
+
* List all saved cards for a customer
|
|
3944
|
+
*
|
|
3945
|
+
* @param pathParams - Path parameters
|
|
3946
|
+
* @returns Promise with cards
|
|
3947
|
+
*
|
|
3948
|
+
* @example
|
|
3949
|
+
* ```typescript
|
|
3950
|
+
* const { data, error } = await sdk.customer.listCustomerCards({
|
|
3951
|
+
* customer_id: "customer_123"
|
|
3952
|
+
* });
|
|
3953
|
+
*
|
|
3954
|
+
* if (error) {
|
|
3955
|
+
* console.error("Failed to list customer cards:", error);
|
|
3956
|
+
* return;
|
|
3957
|
+
* }
|
|
3958
|
+
*
|
|
3959
|
+
* console.log("Customer cards:", data.cards);
|
|
3960
|
+
* ```
|
|
3961
|
+
*/
|
|
3962
|
+
async listCustomerCards(pathParams) {
|
|
3963
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/cards", { params: { path: pathParams } }));
|
|
3866
3964
|
}
|
|
3867
3965
|
};
|
|
3868
3966
|
|
|
@@ -3926,10 +4024,6 @@ var StorefrontSDK = class {
|
|
|
3926
4024
|
*/
|
|
3927
4025
|
helpers;
|
|
3928
4026
|
/**
|
|
3929
|
-
* Client for shipping-related endpoints
|
|
3930
|
-
*/
|
|
3931
|
-
shipping;
|
|
3932
|
-
/**
|
|
3933
4027
|
* Client for order-related endpoints
|
|
3934
4028
|
*/
|
|
3935
4029
|
order;
|
|
@@ -3972,7 +4066,6 @@ var StorefrontSDK = class {
|
|
|
3972
4066
|
this.auth = new AuthClient(config);
|
|
3973
4067
|
this.customer = new CustomerClient(config);
|
|
3974
4068
|
this.helpers = new HelpersClient(config);
|
|
3975
|
-
this.shipping = new ShippingClient(config);
|
|
3976
4069
|
this.order = new OrderClient(config);
|
|
3977
4070
|
this.payments = new PaymentsClient(config);
|
|
3978
4071
|
this.store = new StoreConfigClient(config);
|
|
@@ -3993,7 +4086,6 @@ var StorefrontSDK = class {
|
|
|
3993
4086
|
await this.auth.setTokens(accessToken, refreshToken);
|
|
3994
4087
|
await this.customer.setTokens(accessToken, refreshToken);
|
|
3995
4088
|
await this.helpers.setTokens(accessToken, refreshToken);
|
|
3996
|
-
await this.shipping.setTokens(accessToken, refreshToken);
|
|
3997
4089
|
await this.order.setTokens(accessToken, refreshToken);
|
|
3998
4090
|
await this.payments.setTokens(accessToken, refreshToken);
|
|
3999
4091
|
await this.store.setTokens(accessToken, refreshToken);
|
|
@@ -4011,7 +4103,6 @@ var StorefrontSDK = class {
|
|
|
4011
4103
|
await this.auth.clearTokens();
|
|
4012
4104
|
await this.customer.clearTokens();
|
|
4013
4105
|
await this.helpers.clearTokens();
|
|
4014
|
-
await this.shipping.clearTokens();
|
|
4015
4106
|
await this.order.clearTokens();
|
|
4016
4107
|
await this.payments.clearTokens();
|
|
4017
4108
|
await this.store.clearTokens();
|
|
@@ -4027,7 +4118,6 @@ var StorefrontSDK = class {
|
|
|
4027
4118
|
this.auth.setApiKey(apiKey);
|
|
4028
4119
|
this.customer.setApiKey(apiKey);
|
|
4029
4120
|
this.helpers.setApiKey(apiKey);
|
|
4030
|
-
this.shipping.setApiKey(apiKey);
|
|
4031
4121
|
this.order.setApiKey(apiKey);
|
|
4032
4122
|
this.payments.setApiKey(apiKey);
|
|
4033
4123
|
this.store.setApiKey(apiKey);
|
|
@@ -4041,7 +4131,6 @@ var StorefrontSDK = class {
|
|
|
4041
4131
|
this.auth.clearApiKey();
|
|
4042
4132
|
this.customer.clearApiKey();
|
|
4043
4133
|
this.helpers.clearApiKey();
|
|
4044
|
-
this.shipping.clearApiKey();
|
|
4045
4134
|
this.order.clearApiKey();
|
|
4046
4135
|
this.payments.clearApiKey();
|
|
4047
4136
|
this.store.clearApiKey();
|
|
@@ -4120,7 +4209,6 @@ var StorefrontSDK = class {
|
|
|
4120
4209
|
this.auth.setDefaultHeaders(headers);
|
|
4121
4210
|
this.customer.setDefaultHeaders(headers);
|
|
4122
4211
|
this.helpers.setDefaultHeaders(headers);
|
|
4123
|
-
this.shipping.setDefaultHeaders(headers);
|
|
4124
4212
|
this.order.setDefaultHeaders(headers);
|
|
4125
4213
|
this.payments.setDefaultHeaders(headers);
|
|
4126
4214
|
this.store.setDefaultHeaders(headers);
|
|
@@ -4137,5 +4225,5 @@ var StorefrontSDK = class {
|
|
|
4137
4225
|
var src_default = StorefrontSDK;
|
|
4138
4226
|
|
|
4139
4227
|
//#endregion
|
|
4140
|
-
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, PaymentsClient, ResponseUtils,
|
|
4228
|
+
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, PaymentsClient, ResponseUtils, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, src_default as default };
|
|
4141
4229
|
//# sourceMappingURL=index.mjs.map
|