@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.iife.js
CHANGED
|
@@ -2291,6 +2291,130 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2291
2291
|
}));
|
|
2292
2292
|
}
|
|
2293
2293
|
/**
|
|
2294
|
+
* Get all available coupons
|
|
2295
|
+
*
|
|
2296
|
+
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2297
|
+
* @returns Promise with all available coupons
|
|
2298
|
+
* @example
|
|
2299
|
+
* ```typescript
|
|
2300
|
+
* // Get all available coupons
|
|
2301
|
+
* const { data, error } = await sdk.cart.getAvailableCoupons();
|
|
2302
|
+
*
|
|
2303
|
+
* if (error) {
|
|
2304
|
+
* console.error("Failed to get available coupons:", error.message);
|
|
2305
|
+
* } else {
|
|
2306
|
+
* const coupons = data.coupons || [];
|
|
2307
|
+
* console.log("Available coupons:", coupons.length);
|
|
2308
|
+
* coupons.forEach(coupon => {
|
|
2309
|
+
* console.log("Coupon:", coupon.code, "Discount:", coupon.discount_amount);
|
|
2310
|
+
* });
|
|
2311
|
+
* }
|
|
2312
|
+
*
|
|
2313
|
+
* // Override customer group ID for this specific request
|
|
2314
|
+
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailableCoupons({
|
|
2315
|
+
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2316
|
+
* });
|
|
2317
|
+
* ```
|
|
2318
|
+
*/
|
|
2319
|
+
async getAvailableCoupons(headers) {
|
|
2320
|
+
const mergedHeaders = this.mergeHeaders(headers);
|
|
2321
|
+
return this.executeRequest(() => this.client.GET("/carts/available-coupons", { params: { header: mergedHeaders } }));
|
|
2322
|
+
}
|
|
2323
|
+
/**
|
|
2324
|
+
* Get all available promotions
|
|
2325
|
+
*
|
|
2326
|
+
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2327
|
+
* @returns Promise with all available promotions
|
|
2328
|
+
* @example
|
|
2329
|
+
* ```typescript
|
|
2330
|
+
* // Get all available promotions
|
|
2331
|
+
* const { data, error } = await sdk.cart.getAvailablePromotions();
|
|
2332
|
+
*
|
|
2333
|
+
* if (error) {
|
|
2334
|
+
* console.error("Failed to get available promotions:", error.message);
|
|
2335
|
+
* } else {
|
|
2336
|
+
* const promotions = data.promotions || [];
|
|
2337
|
+
* console.log("Available promotions:", promotions.length);
|
|
2338
|
+
* promotions.forEach(promotion => {
|
|
2339
|
+
* console.log("Promotion:", promotion.name, "Type:", promotion.promotion_type);
|
|
2340
|
+
* });
|
|
2341
|
+
* }
|
|
2342
|
+
*
|
|
2343
|
+
* // Override customer group ID for this specific request
|
|
2344
|
+
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailablePromotions({
|
|
2345
|
+
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2346
|
+
* });
|
|
2347
|
+
* ```
|
|
2348
|
+
*/
|
|
2349
|
+
async getAvailablePromotions(headers) {
|
|
2350
|
+
const mergedHeaders = this.mergeHeaders(headers);
|
|
2351
|
+
return this.executeRequest(() => this.client.GET("/carts/available-promotions", { params: { header: mergedHeaders } }));
|
|
2352
|
+
}
|
|
2353
|
+
/**
|
|
2354
|
+
* Evaluate promotions
|
|
2355
|
+
*
|
|
2356
|
+
* @param cartId - The ID of the cart
|
|
2357
|
+
* @returns Promise with evaluated promotions
|
|
2358
|
+
* @example
|
|
2359
|
+
* ```typescript
|
|
2360
|
+
* const { data, error } = await sdk.cart.evaluatePromotions({
|
|
2361
|
+
* id: "01H9CART12345ABCDE"
|
|
2362
|
+
* });
|
|
2363
|
+
*
|
|
2364
|
+
* if (error) {
|
|
2365
|
+
* console.error("Failed to evaluate promotions:", error.message);
|
|
2366
|
+
* } else {
|
|
2367
|
+
* const applicable = data.applicable_promotions || [];
|
|
2368
|
+
* const inapplicable = data.inapplicable_promotions || [];
|
|
2369
|
+
*
|
|
2370
|
+
* console.log("Applicable promotions:", applicable.length);
|
|
2371
|
+
* applicable.forEach(promo => {
|
|
2372
|
+
* console.log(`- ${promo.name}: ${promo.savings_message}`);
|
|
2373
|
+
* });
|
|
2374
|
+
*
|
|
2375
|
+
* console.log("Inapplicable promotions:", inapplicable.length);
|
|
2376
|
+
* inapplicable.forEach(promo => {
|
|
2377
|
+
* console.log(`- ${promo.name}: ${promo.reason}`);
|
|
2378
|
+
* });
|
|
2379
|
+
* }
|
|
2380
|
+
* ```
|
|
2381
|
+
*/
|
|
2382
|
+
async evaluatePromotions(cartId) {
|
|
2383
|
+
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-promotions", { params: { path: cartId } }));
|
|
2384
|
+
}
|
|
2385
|
+
/**
|
|
2386
|
+
* Evaluate coupons
|
|
2387
|
+
*
|
|
2388
|
+
* @param cartId - The ID of the cart
|
|
2389
|
+
* @returns Promise with evaluated coupons
|
|
2390
|
+
* @example
|
|
2391
|
+
* ```typescript
|
|
2392
|
+
* const { data, error } = await sdk.cart.evaluateCoupons({
|
|
2393
|
+
* id: "01H9CART12345ABCDE"
|
|
2394
|
+
* });
|
|
2395
|
+
*
|
|
2396
|
+
* if (error) {
|
|
2397
|
+
* console.error("Failed to evaluate coupons:", error.message);
|
|
2398
|
+
* } else {
|
|
2399
|
+
* const applicable = data.applicable_coupons || [];
|
|
2400
|
+
* const inapplicable = data.inapplicable_coupons || [];
|
|
2401
|
+
*
|
|
2402
|
+
* console.log("Applicable coupons:", applicable.length);
|
|
2403
|
+
* applicable.forEach(coupon => {
|
|
2404
|
+
* console.log(`- ${coupon.code}: Save $${coupon.estimated_discount}`);
|
|
2405
|
+
* });
|
|
2406
|
+
*
|
|
2407
|
+
* console.log("Inapplicable coupons:", inapplicable.length);
|
|
2408
|
+
* inapplicable.forEach(coupon => {
|
|
2409
|
+
* console.log(`- ${coupon.code}: ${coupon.reason}`);
|
|
2410
|
+
* });
|
|
2411
|
+
* }
|
|
2412
|
+
* ```
|
|
2413
|
+
*/
|
|
2414
|
+
async evaluateCoupons(cartId) {
|
|
2415
|
+
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-coupons", { params: { path: cartId } }));
|
|
2416
|
+
}
|
|
2417
|
+
/**
|
|
2294
2418
|
* Redeem loyalty points
|
|
2295
2419
|
*
|
|
2296
2420
|
* @param cartId - The ID of the cart
|
|
@@ -2349,12 +2473,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2349
2473
|
* @returns Promise with updated cart
|
|
2350
2474
|
* @example
|
|
2351
2475
|
* ```typescript
|
|
2476
|
+
* // For delivery fulfillment with shipments
|
|
2352
2477
|
* const { data, error } = await sdk.cart.updateFulfillmentPreference(
|
|
2353
2478
|
* { id: "01H9CART12345ABCDE" },
|
|
2354
2479
|
* {
|
|
2355
2480
|
* fulfillment_type: "delivery",
|
|
2356
|
-
*
|
|
2357
|
-
*
|
|
2481
|
+
* shipments: [
|
|
2482
|
+
* {
|
|
2483
|
+
* id: "01H9SHIP12345ABCDE",
|
|
2484
|
+
* shipping_provider_id: "01H9PROV12345FAST",
|
|
2485
|
+
* courier_company_id: "01H9COY12345FAST" // Optional
|
|
2486
|
+
* }
|
|
2487
|
+
* ]
|
|
2358
2488
|
* }
|
|
2359
2489
|
* );
|
|
2360
2490
|
*
|
|
@@ -2364,6 +2494,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2364
2494
|
* console.log("Fulfillment preference updated:", data.cart.fulfillment_preference?.fulfillment_type);
|
|
2365
2495
|
* console.log("Shipping cost:", data.cart.shipping_amount);
|
|
2366
2496
|
* }
|
|
2497
|
+
*
|
|
2498
|
+
* // For collect-in-store fulfillment
|
|
2499
|
+
* const { data: collectData, error: collectError } = await sdk.cart.updateFulfillmentPreference(
|
|
2500
|
+
* { id: "01H9CART12345ABCDE" },
|
|
2501
|
+
* {
|
|
2502
|
+
* fulfillment_type: "collect-in-store",
|
|
2503
|
+
* pickup_location_id: "01H9STORE12345ABC"
|
|
2504
|
+
* }
|
|
2505
|
+
* );
|
|
2367
2506
|
* ```
|
|
2368
2507
|
*/
|
|
2369
2508
|
async updateFulfillmentPreference(cartId, body) {
|
|
@@ -2373,6 +2512,103 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2373
2512
|
}));
|
|
2374
2513
|
}
|
|
2375
2514
|
/**
|
|
2515
|
+
* Check fulfillment serviceability
|
|
2516
|
+
*
|
|
2517
|
+
* Checks if fulfillment (delivery or collect-in-store) is available to the specified pincode
|
|
2518
|
+
* based on shipping zones and inventories.
|
|
2519
|
+
*
|
|
2520
|
+
* @param body - Fulfillment check body (cart-based or items-based)
|
|
2521
|
+
* @returns Promise with fulfillment serviceability result
|
|
2522
|
+
* @example
|
|
2523
|
+
* ```typescript
|
|
2524
|
+
* // Cart-based fulfillment check
|
|
2525
|
+
* const { data, error } = await sdk.cart.checkPincodeDeliverability({
|
|
2526
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2527
|
+
* delivery_pincode: "400001",
|
|
2528
|
+
* fulfillment_type: "delivery" // optional: "delivery" | "collect-in-store"
|
|
2529
|
+
* });
|
|
2530
|
+
*
|
|
2531
|
+
* // Items-based fulfillment check
|
|
2532
|
+
* const { data, error } = await sdk.cart.checkPincodeDeliverability({
|
|
2533
|
+
* delivery_pincode: "400001",
|
|
2534
|
+
* items: [
|
|
2535
|
+
* { product_id: "prod_123", variant_id: "var_456" },
|
|
2536
|
+
* { product_id: "prod_789", variant_id: null }
|
|
2537
|
+
* ]
|
|
2538
|
+
* // fulfillment_type is optional
|
|
2539
|
+
* });
|
|
2540
|
+
*
|
|
2541
|
+
* if (error) {
|
|
2542
|
+
* console.error("Failed to check fulfillment serviceability:", error.message);
|
|
2543
|
+
* } else {
|
|
2544
|
+
* console.log("Serviceable:", data.is_serviceable);
|
|
2545
|
+
*
|
|
2546
|
+
* if (!data.is_serviceable && data.unserviceable_items) {
|
|
2547
|
+
* data.unserviceable_items.forEach(item => {
|
|
2548
|
+
* console.log(`Unserviceable: ${item.product_name}, max available: ${item.max_available_quantity}`);
|
|
2549
|
+
* });
|
|
2550
|
+
* }
|
|
2551
|
+
* }
|
|
2552
|
+
* ```
|
|
2553
|
+
*/
|
|
2554
|
+
async checkPincodeDeliverability(body) {
|
|
2555
|
+
return this.executeRequest(() => this.client.POST("/fulfillment/serviceability", { body }));
|
|
2556
|
+
}
|
|
2557
|
+
/**
|
|
2558
|
+
* Get fulfillment options for an order
|
|
2559
|
+
*
|
|
2560
|
+
* @param body - Fulfillment options body containing cart_id and optional fulfillment_type
|
|
2561
|
+
* @returns Promise with fulfillment options including collect and delivery methods. The response contains:
|
|
2562
|
+
* - `summary`: Object with `collect_available`, `deliver_available`, `recommended_fulfillment_type`, and optional `recommended_store`
|
|
2563
|
+
* - `collect`: Optional array of `CollectInStore` objects for collect-in-store options
|
|
2564
|
+
* - `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.
|
|
2565
|
+
* @example
|
|
2566
|
+
* ```typescript
|
|
2567
|
+
* const { data, error } = await sdk.cart.getFulfillmentOptions({
|
|
2568
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2569
|
+
* fulfillment_type: "delivery" // optional: "delivery" | "collect-in-store"
|
|
2570
|
+
* });
|
|
2571
|
+
*
|
|
2572
|
+
* if (error) {
|
|
2573
|
+
* console.error("Failed to get fulfillment options:", error.message);
|
|
2574
|
+
* } else {
|
|
2575
|
+
* // Check summary information
|
|
2576
|
+
* console.log("Collect available:", data.summary.collect_available);
|
|
2577
|
+
* console.log("Deliver available:", data.summary.deliver_available);
|
|
2578
|
+
* console.log("Recommended fulfillment type:", data.summary.recommended_fulfillment_type);
|
|
2579
|
+
*
|
|
2580
|
+
* // Access collect options
|
|
2581
|
+
* if (data.collect && data.collect.length > 0) {
|
|
2582
|
+
* console.log("Available stores for collection:");
|
|
2583
|
+
* data.collect.forEach(store => {
|
|
2584
|
+
* console.log(`${store.name} - ${store.distance_km}km away, ETA: ${store.collect_eta_minutes} minutes`);
|
|
2585
|
+
* });
|
|
2586
|
+
* }
|
|
2587
|
+
*
|
|
2588
|
+
* // Access delivery options (with shipments)
|
|
2589
|
+
* if (data.deliver && data.deliver.is_serviceable) {
|
|
2590
|
+
* console.log("Available shipments and shipping methods:");
|
|
2591
|
+
* data.deliver.shipments.forEach(shipment => {
|
|
2592
|
+
* console.log(`Shipment ${shipment.id}:`);
|
|
2593
|
+
* console.log(` Items: ${shipment.items.length}`);
|
|
2594
|
+
* shipment.shipping_methods.forEach(method => {
|
|
2595
|
+
* console.log(` - ${method.name}: ${method.shipping_amount}, ${method.estimated_delivery_days} days`);
|
|
2596
|
+
* // Access courier companies for auto shipping methods
|
|
2597
|
+
* if (method.courier_companies) {
|
|
2598
|
+
* method.courier_companies.forEach(courier => {
|
|
2599
|
+
* console.log(` Courier: ${courier.name} - ${courier.shipping_amount}, ${courier.estimated_delivery_days} days`);
|
|
2600
|
+
* });
|
|
2601
|
+
* }
|
|
2602
|
+
* });
|
|
2603
|
+
* });
|
|
2604
|
+
* }
|
|
2605
|
+
* }
|
|
2606
|
+
* ```
|
|
2607
|
+
*/
|
|
2608
|
+
async getFulfillmentOptions(body) {
|
|
2609
|
+
return this.executeRequest(() => this.client.POST("/carts/fulfillment-options", { body }));
|
|
2610
|
+
}
|
|
2611
|
+
/**
|
|
2376
2612
|
* Use credit balance
|
|
2377
2613
|
*
|
|
2378
2614
|
* @param cartId - The ID of the cart
|
|
@@ -2508,130 +2744,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2508
2744
|
body
|
|
2509
2745
|
}));
|
|
2510
2746
|
}
|
|
2511
|
-
/**
|
|
2512
|
-
* Get all available coupons
|
|
2513
|
-
*
|
|
2514
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2515
|
-
* @returns Promise with all available coupons
|
|
2516
|
-
* @example
|
|
2517
|
-
* ```typescript
|
|
2518
|
-
* // Get all available coupons
|
|
2519
|
-
* const { data, error } = await sdk.cart.getAvailableCoupons();
|
|
2520
|
-
*
|
|
2521
|
-
* if (error) {
|
|
2522
|
-
* console.error("Failed to get available coupons:", error.message);
|
|
2523
|
-
* } else {
|
|
2524
|
-
* const coupons = data.coupons || [];
|
|
2525
|
-
* console.log("Available coupons:", coupons.length);
|
|
2526
|
-
* coupons.forEach(coupon => {
|
|
2527
|
-
* console.log("Coupon:", coupon.code, "Discount:", coupon.discount_amount);
|
|
2528
|
-
* });
|
|
2529
|
-
* }
|
|
2530
|
-
*
|
|
2531
|
-
* // Override customer group ID for this specific request
|
|
2532
|
-
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailableCoupons({
|
|
2533
|
-
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2534
|
-
* });
|
|
2535
|
-
* ```
|
|
2536
|
-
*/
|
|
2537
|
-
async getAvailableCoupons(headers) {
|
|
2538
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
2539
|
-
return this.executeRequest(() => this.client.GET("/carts/available-coupons", { params: { header: mergedHeaders } }));
|
|
2540
|
-
}
|
|
2541
|
-
/**
|
|
2542
|
-
* Get all available promotions
|
|
2543
|
-
*
|
|
2544
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2545
|
-
* @returns Promise with all available promotions
|
|
2546
|
-
* @example
|
|
2547
|
-
* ```typescript
|
|
2548
|
-
* // Get all available promotions
|
|
2549
|
-
* const { data, error } = await sdk.cart.getAvailablePromotions();
|
|
2550
|
-
*
|
|
2551
|
-
* if (error) {
|
|
2552
|
-
* console.error("Failed to get available promotions:", error.message);
|
|
2553
|
-
* } else {
|
|
2554
|
-
* const promotions = data.promotions || [];
|
|
2555
|
-
* console.log("Available promotions:", promotions.length);
|
|
2556
|
-
* promotions.forEach(promotion => {
|
|
2557
|
-
* console.log("Promotion:", promotion.name, "Type:", promotion.promotion_type);
|
|
2558
|
-
* });
|
|
2559
|
-
* }
|
|
2560
|
-
*
|
|
2561
|
-
* // Override customer group ID for this specific request
|
|
2562
|
-
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailablePromotions({
|
|
2563
|
-
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2564
|
-
* });
|
|
2565
|
-
* ```
|
|
2566
|
-
*/
|
|
2567
|
-
async getAvailablePromotions(headers) {
|
|
2568
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
2569
|
-
return this.executeRequest(() => this.client.GET("/carts/available-promotions", { params: { header: mergedHeaders } }));
|
|
2570
|
-
}
|
|
2571
|
-
/**
|
|
2572
|
-
* Evaluate promotions
|
|
2573
|
-
*
|
|
2574
|
-
* @param cartId - The ID of the cart
|
|
2575
|
-
* @returns Promise with evaluated promotions
|
|
2576
|
-
* @example
|
|
2577
|
-
* ```typescript
|
|
2578
|
-
* const { data, error } = await sdk.cart.evaluatePromotions({
|
|
2579
|
-
* id: "01H9CART12345ABCDE"
|
|
2580
|
-
* });
|
|
2581
|
-
*
|
|
2582
|
-
* if (error) {
|
|
2583
|
-
* console.error("Failed to evaluate promotions:", error.message);
|
|
2584
|
-
* } else {
|
|
2585
|
-
* const applicable = data.applicable_promotions || [];
|
|
2586
|
-
* const inapplicable = data.inapplicable_promotions || [];
|
|
2587
|
-
*
|
|
2588
|
-
* console.log("Applicable promotions:", applicable.length);
|
|
2589
|
-
* applicable.forEach(promo => {
|
|
2590
|
-
* console.log(`- ${promo.name}: ${promo.savings_message}`);
|
|
2591
|
-
* });
|
|
2592
|
-
*
|
|
2593
|
-
* console.log("Inapplicable promotions:", inapplicable.length);
|
|
2594
|
-
* inapplicable.forEach(promo => {
|
|
2595
|
-
* console.log(`- ${promo.name}: ${promo.reason}`);
|
|
2596
|
-
* });
|
|
2597
|
-
* }
|
|
2598
|
-
* ```
|
|
2599
|
-
*/
|
|
2600
|
-
async evaluatePromotions(cartId) {
|
|
2601
|
-
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-promotions", { params: { path: cartId } }));
|
|
2602
|
-
}
|
|
2603
|
-
/**
|
|
2604
|
-
* Evaluate coupons
|
|
2605
|
-
*
|
|
2606
|
-
* @param cartId - The ID of the cart
|
|
2607
|
-
* @returns Promise with evaluated coupons
|
|
2608
|
-
* @example
|
|
2609
|
-
* ```typescript
|
|
2610
|
-
* const { data, error } = await sdk.cart.evaluateCoupons({
|
|
2611
|
-
* id: "01H9CART12345ABCDE"
|
|
2612
|
-
* });
|
|
2613
|
-
*
|
|
2614
|
-
* if (error) {
|
|
2615
|
-
* console.error("Failed to evaluate coupons:", error.message);
|
|
2616
|
-
* } else {
|
|
2617
|
-
* const applicable = data.applicable_coupons || [];
|
|
2618
|
-
* const inapplicable = data.inapplicable_coupons || [];
|
|
2619
|
-
*
|
|
2620
|
-
* console.log("Applicable coupons:", applicable.length);
|
|
2621
|
-
* applicable.forEach(coupon => {
|
|
2622
|
-
* console.log(`- ${coupon.code}: Save $${coupon.estimated_discount}`);
|
|
2623
|
-
* });
|
|
2624
|
-
*
|
|
2625
|
-
* console.log("Inapplicable coupons:", inapplicable.length);
|
|
2626
|
-
* inapplicable.forEach(coupon => {
|
|
2627
|
-
* console.log(`- ${coupon.code}: ${coupon.reason}`);
|
|
2628
|
-
* });
|
|
2629
|
-
* }
|
|
2630
|
-
* ```
|
|
2631
|
-
*/
|
|
2632
|
-
async evaluateCoupons(cartId) {
|
|
2633
|
-
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-coupons", { params: { path: cartId } }));
|
|
2634
|
-
}
|
|
2635
2747
|
};
|
|
2636
2748
|
|
|
2637
2749
|
//#endregion
|
|
@@ -3679,10 +3791,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3679
3791
|
/**
|
|
3680
3792
|
* List all available payment methods
|
|
3681
3793
|
*
|
|
3794
|
+
* @param queryParams - Query parameters containing the payment method type and payment provider slug
|
|
3682
3795
|
* @returns Promise with list of payment methods
|
|
3683
3796
|
* @example
|
|
3684
3797
|
* ```typescript
|
|
3685
|
-
* const { data, error } = await sdk.payments.listPaymentMethods(
|
|
3798
|
+
* const { data, error } = await sdk.payments.listPaymentMethods({
|
|
3799
|
+
* payment_method_type: "card",
|
|
3800
|
+
* payment_provider_slug: "payu"
|
|
3801
|
+
* });
|
|
3686
3802
|
*
|
|
3687
3803
|
* if (error) {
|
|
3688
3804
|
* console.error("Failed to list payment methods:", error.message);
|
|
@@ -3696,8 +3812,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3696
3812
|
* }
|
|
3697
3813
|
* ```
|
|
3698
3814
|
*/
|
|
3699
|
-
async listPaymentMethods() {
|
|
3700
|
-
return this.executeRequest(() => this.client.GET("/payments/payment-methods", {}));
|
|
3815
|
+
async listPaymentMethods(queryParams) {
|
|
3816
|
+
return this.executeRequest(() => this.client.GET("/payments/payment-methods", { params: { query: queryParams } }));
|
|
3701
3817
|
}
|
|
3702
3818
|
/**
|
|
3703
3819
|
* Verify a UPI Virtual Payment Address (VPA)
|
|
@@ -3732,6 +3848,29 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3732
3848
|
return this.executeRequest(() => this.client.GET("/payments/verify-vpa", { params: { query: queryParams } }));
|
|
3733
3849
|
}
|
|
3734
3850
|
/**
|
|
3851
|
+
* Get card information
|
|
3852
|
+
*
|
|
3853
|
+
* Retrieves card information based on the initial 9 digits (card BIN) of the card number.
|
|
3854
|
+
*
|
|
3855
|
+
* @param queryParams - Query parameters containing the card BIN
|
|
3856
|
+
* @returns Promise with card information
|
|
3857
|
+
* @example
|
|
3858
|
+
* ```typescript
|
|
3859
|
+
* const { data, error } = await sdk.payments.getCardInfo({
|
|
3860
|
+
* cardbin: "411111111"
|
|
3861
|
+
* });
|
|
3862
|
+
*
|
|
3863
|
+
* if (error) {
|
|
3864
|
+
* console.error("Failed to get card information:", error.message);
|
|
3865
|
+
* } else {
|
|
3866
|
+
* console.log("Card information:", data.card_info);
|
|
3867
|
+
* }
|
|
3868
|
+
* ```
|
|
3869
|
+
*/
|
|
3870
|
+
async getCardInfo(queryParams) {
|
|
3871
|
+
return this.executeRequest(() => this.client.GET("/payments/card-info", { params: { query: queryParams } }));
|
|
3872
|
+
}
|
|
3873
|
+
/**
|
|
3735
3874
|
* Authenticate a direct OTP for payment verification
|
|
3736
3875
|
*
|
|
3737
3876
|
* @description Used to authenticate OTP during payment flows that require 2FA verification.
|
|
@@ -3790,82 +3929,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3790
3929
|
}
|
|
3791
3930
|
};
|
|
3792
3931
|
|
|
3793
|
-
//#endregion
|
|
3794
|
-
//#region src/lib/shipping.ts
|
|
3795
|
-
/**
|
|
3796
|
-
* Client for interacting with shipping endpoints
|
|
3797
|
-
*/
|
|
3798
|
-
var ShippingClient = class extends StorefrontAPIClient {
|
|
3799
|
-
/**
|
|
3800
|
-
* Check pincode deliverability
|
|
3801
|
-
*
|
|
3802
|
-
* @param pathParams - Path parameters
|
|
3803
|
-
* @returns Promise with pincode deliverability result
|
|
3804
|
-
* @example
|
|
3805
|
-
* ```typescript
|
|
3806
|
-
* const { data, error } = await sdk.shipping.checkPincodeDeliverability({
|
|
3807
|
-
* pincode: "400001"
|
|
3808
|
-
* });
|
|
3809
|
-
*
|
|
3810
|
-
* if (error) {
|
|
3811
|
-
* console.error("Failed to check pincode serviceability:", error.message);
|
|
3812
|
-
* } else {
|
|
3813
|
-
* console.log("Pincode serviceable:", data.is_serviceable);
|
|
3814
|
-
*
|
|
3815
|
-
* if (data.is_serviceable) {
|
|
3816
|
-
* console.log("Delivery is available to this pincode");
|
|
3817
|
-
* } else {
|
|
3818
|
-
* console.log("Delivery is not available to this pincode");
|
|
3819
|
-
* }
|
|
3820
|
-
* }
|
|
3821
|
-
* ```
|
|
3822
|
-
*/
|
|
3823
|
-
async checkPincodeDeliverability(pathParams) {
|
|
3824
|
-
return this.executeRequest(() => this.client.GET("/shipping/serviceability/{pincode}", { params: { path: pathParams } }));
|
|
3825
|
-
}
|
|
3826
|
-
/**
|
|
3827
|
-
* Get fulfillment options for an order
|
|
3828
|
-
*
|
|
3829
|
-
* @param body - Fulfillment options body containing cart_id and delivery_pincode
|
|
3830
|
-
* @returns Promise with fulfillment options including collect and delivery methods
|
|
3831
|
-
* @example
|
|
3832
|
-
* ```typescript
|
|
3833
|
-
* const { data, error } = await sdk.shipping.getFulfillmentOptions({
|
|
3834
|
-
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
3835
|
-
* delivery_pincode: "400001"
|
|
3836
|
-
* });
|
|
3837
|
-
*
|
|
3838
|
-
* if (error) {
|
|
3839
|
-
* console.error("Failed to get fulfillment options:", error.message);
|
|
3840
|
-
* } else {
|
|
3841
|
-
* // Check summary information
|
|
3842
|
-
* console.log("Collect available:", data.summary.collect_available);
|
|
3843
|
-
* console.log("Deliver available:", data.summary.deliver_available);
|
|
3844
|
-
* console.log("Recommended fulfillment type:", data.summary.recommended_fulfillment_type);
|
|
3845
|
-
*
|
|
3846
|
-
* // Access collect options
|
|
3847
|
-
* if (data.collect && data.collect.length > 0) {
|
|
3848
|
-
* console.log("Available stores for collection:");
|
|
3849
|
-
* data.collect.forEach(store => {
|
|
3850
|
-
* console.log(`${store.name} - ${store.distance_km}km away, ETA: ${store.collect_eta_minutes} minutes`);
|
|
3851
|
-
* });
|
|
3852
|
-
* }
|
|
3853
|
-
*
|
|
3854
|
-
* // Access delivery options
|
|
3855
|
-
* if (data.deliver && data.deliver.is_serviceable) {
|
|
3856
|
-
* console.log("Available shipping methods:");
|
|
3857
|
-
* data.deliver.shipping_methods.forEach(method => {
|
|
3858
|
-
* console.log(`${method.name} - ${method.shipping_amount}, ${method.estimated_delivery_days} days`);
|
|
3859
|
-
* });
|
|
3860
|
-
* }
|
|
3861
|
-
* }
|
|
3862
|
-
* ```
|
|
3863
|
-
*/
|
|
3864
|
-
async getFulfillmentOptions(body) {
|
|
3865
|
-
return this.executeRequest(() => this.client.POST("/shipping/fulfillment-options", { body }));
|
|
3866
|
-
}
|
|
3867
|
-
};
|
|
3868
|
-
|
|
3869
3932
|
//#endregion
|
|
3870
3933
|
//#region src/lib/helper.ts
|
|
3871
3934
|
/**
|
|
@@ -3976,8 +4039,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3976
4039
|
* console.log("US Pincodes:", usPincodes.pincodes?.map(p => p.pincode).join(", "));
|
|
3977
4040
|
* ```
|
|
3978
4041
|
*/
|
|
3979
|
-
async listCountryPincodes(pathParams) {
|
|
3980
|
-
return this.executeRequest(() => this.client.GET("/common/countries/{country_iso_code}/pincodes", { params: {
|
|
4042
|
+
async listCountryPincodes(pathParams, queryParams) {
|
|
4043
|
+
return this.executeRequest(() => this.client.GET("/common/countries/{country_iso_code}/pincodes", { params: {
|
|
4044
|
+
path: pathParams,
|
|
4045
|
+
query: queryParams
|
|
4046
|
+
} }));
|
|
3981
4047
|
}
|
|
3982
4048
|
};
|
|
3983
4049
|
|
|
@@ -4097,8 +4163,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4097
4163
|
* });
|
|
4098
4164
|
* ```
|
|
4099
4165
|
*/
|
|
4100
|
-
async listAddresses(pathParams) {
|
|
4101
|
-
return this.executeRequest(() => this.client.GET("/customers/{user_id}/addresses", { params: {
|
|
4166
|
+
async listAddresses(pathParams, queryParams) {
|
|
4167
|
+
return this.executeRequest(() => this.client.GET("/customers/{user_id}/addresses", { params: {
|
|
4168
|
+
path: pathParams,
|
|
4169
|
+
query: queryParams
|
|
4170
|
+
} }));
|
|
4102
4171
|
}
|
|
4103
4172
|
/**
|
|
4104
4173
|
* Create a new address for a customer
|
|
@@ -4273,8 +4342,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4273
4342
|
* });
|
|
4274
4343
|
* ```
|
|
4275
4344
|
*/
|
|
4276
|
-
async listLoyaltyPointsActivity(pathParams) {
|
|
4277
|
-
return this.executeRequest(() => this.client.GET("/customers/{user_id}/loyalty-points-activity", { params: {
|
|
4345
|
+
async listLoyaltyPointsActivity(pathParams, queryParams) {
|
|
4346
|
+
return this.executeRequest(() => this.client.GET("/customers/{user_id}/loyalty-points-activity", { params: {
|
|
4347
|
+
path: pathParams,
|
|
4348
|
+
query: queryParams
|
|
4349
|
+
} }));
|
|
4278
4350
|
}
|
|
4279
4351
|
/**
|
|
4280
4352
|
* List all reviews left by a customer
|
|
@@ -4320,8 +4392,34 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4320
4392
|
* console.log("Saved payment methods:", data.saved_payment_methods);
|
|
4321
4393
|
* ```
|
|
4322
4394
|
*/
|
|
4323
|
-
async listSavedPaymentMethods(pathParams) {
|
|
4324
|
-
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/payment-methods", { params: {
|
|
4395
|
+
async listSavedPaymentMethods(pathParams, queryParams) {
|
|
4396
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/payment-methods", { params: {
|
|
4397
|
+
path: pathParams,
|
|
4398
|
+
query: queryParams
|
|
4399
|
+
} }));
|
|
4400
|
+
}
|
|
4401
|
+
/**
|
|
4402
|
+
* List all saved cards for a customer
|
|
4403
|
+
*
|
|
4404
|
+
* @param pathParams - Path parameters
|
|
4405
|
+
* @returns Promise with cards
|
|
4406
|
+
*
|
|
4407
|
+
* @example
|
|
4408
|
+
* ```typescript
|
|
4409
|
+
* const { data, error } = await sdk.customer.listCustomerCards({
|
|
4410
|
+
* customer_id: "customer_123"
|
|
4411
|
+
* });
|
|
4412
|
+
*
|
|
4413
|
+
* if (error) {
|
|
4414
|
+
* console.error("Failed to list customer cards:", error);
|
|
4415
|
+
* return;
|
|
4416
|
+
* }
|
|
4417
|
+
*
|
|
4418
|
+
* console.log("Customer cards:", data.cards);
|
|
4419
|
+
* ```
|
|
4420
|
+
*/
|
|
4421
|
+
async listCustomerCards(pathParams) {
|
|
4422
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/cards", { params: { path: pathParams } }));
|
|
4325
4423
|
}
|
|
4326
4424
|
};
|
|
4327
4425
|
|
|
@@ -4385,10 +4483,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4385
4483
|
*/
|
|
4386
4484
|
helpers;
|
|
4387
4485
|
/**
|
|
4388
|
-
* Client for shipping-related endpoints
|
|
4389
|
-
*/
|
|
4390
|
-
shipping;
|
|
4391
|
-
/**
|
|
4392
4486
|
* Client for order-related endpoints
|
|
4393
4487
|
*/
|
|
4394
4488
|
order;
|
|
@@ -4431,7 +4525,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4431
4525
|
this.auth = new AuthClient(config);
|
|
4432
4526
|
this.customer = new CustomerClient(config);
|
|
4433
4527
|
this.helpers = new HelpersClient(config);
|
|
4434
|
-
this.shipping = new ShippingClient(config);
|
|
4435
4528
|
this.order = new OrderClient(config);
|
|
4436
4529
|
this.payments = new PaymentsClient(config);
|
|
4437
4530
|
this.store = new StoreConfigClient(config);
|
|
@@ -4452,7 +4545,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4452
4545
|
await this.auth.setTokens(accessToken, refreshToken);
|
|
4453
4546
|
await this.customer.setTokens(accessToken, refreshToken);
|
|
4454
4547
|
await this.helpers.setTokens(accessToken, refreshToken);
|
|
4455
|
-
await this.shipping.setTokens(accessToken, refreshToken);
|
|
4456
4548
|
await this.order.setTokens(accessToken, refreshToken);
|
|
4457
4549
|
await this.payments.setTokens(accessToken, refreshToken);
|
|
4458
4550
|
await this.store.setTokens(accessToken, refreshToken);
|
|
@@ -4470,7 +4562,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4470
4562
|
await this.auth.clearTokens();
|
|
4471
4563
|
await this.customer.clearTokens();
|
|
4472
4564
|
await this.helpers.clearTokens();
|
|
4473
|
-
await this.shipping.clearTokens();
|
|
4474
4565
|
await this.order.clearTokens();
|
|
4475
4566
|
await this.payments.clearTokens();
|
|
4476
4567
|
await this.store.clearTokens();
|
|
@@ -4486,7 +4577,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4486
4577
|
this.auth.setApiKey(apiKey);
|
|
4487
4578
|
this.customer.setApiKey(apiKey);
|
|
4488
4579
|
this.helpers.setApiKey(apiKey);
|
|
4489
|
-
this.shipping.setApiKey(apiKey);
|
|
4490
4580
|
this.order.setApiKey(apiKey);
|
|
4491
4581
|
this.payments.setApiKey(apiKey);
|
|
4492
4582
|
this.store.setApiKey(apiKey);
|
|
@@ -4500,7 +4590,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4500
4590
|
this.auth.clearApiKey();
|
|
4501
4591
|
this.customer.clearApiKey();
|
|
4502
4592
|
this.helpers.clearApiKey();
|
|
4503
|
-
this.shipping.clearApiKey();
|
|
4504
4593
|
this.order.clearApiKey();
|
|
4505
4594
|
this.payments.clearApiKey();
|
|
4506
4595
|
this.store.clearApiKey();
|
|
@@ -4579,7 +4668,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4579
4668
|
this.auth.setDefaultHeaders(headers);
|
|
4580
4669
|
this.customer.setDefaultHeaders(headers);
|
|
4581
4670
|
this.helpers.setDefaultHeaders(headers);
|
|
4582
|
-
this.shipping.setDefaultHeaders(headers);
|
|
4583
4671
|
this.order.setDefaultHeaders(headers);
|
|
4584
4672
|
this.payments.setDefaultHeaders(headers);
|
|
4585
4673
|
this.store.setDefaultHeaders(headers);
|
|
@@ -4608,7 +4696,6 @@ exports.MemoryTokenStorage = MemoryTokenStorage;
|
|
|
4608
4696
|
exports.OrderClient = OrderClient;
|
|
4609
4697
|
exports.PaymentsClient = PaymentsClient;
|
|
4610
4698
|
exports.ResponseUtils = ResponseUtils;
|
|
4611
|
-
exports.ShippingClient = ShippingClient;
|
|
4612
4699
|
exports.StoreConfigClient = StoreConfigClient;
|
|
4613
4700
|
exports.StorefrontAPIClient = StorefrontAPIClient;
|
|
4614
4701
|
exports.StorefrontSDK = StorefrontSDK;
|