@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
package/dist/index.iife.js
CHANGED
|
@@ -2,7 +2,7 @@ var CE_SDK = (function(exports) {
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
//#region ../../node_modules/.pnpm/openapi-fetch@0.14.
|
|
5
|
+
//#region ../../node_modules/.pnpm/openapi-fetch@0.14.1/node_modules/openapi-fetch/dist/index.mjs
|
|
6
6
|
const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
7
7
|
const supportsRequestInitExt = () => {
|
|
8
8
|
return typeof process === "object" && Number.parseInt(process?.versions?.node?.substring(0, 2)) >= 18 && process.versions.undici;
|
|
@@ -35,7 +35,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
35
35
|
};
|
|
36
36
|
let id;
|
|
37
37
|
let options;
|
|
38
|
-
let request = new
|
|
38
|
+
let request = new Request$1(createFinalURL(schemaPath, {
|
|
39
39
|
baseUrl: finalBaseUrl,
|
|
40
40
|
params,
|
|
41
41
|
querySerializer
|
|
@@ -59,7 +59,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
59
59
|
options,
|
|
60
60
|
id
|
|
61
61
|
});
|
|
62
|
-
if (result) if (result instanceof
|
|
62
|
+
if (result) if (result instanceof Request$1) request = result;
|
|
63
63
|
else if (result instanceof Response) {
|
|
64
64
|
response = result;
|
|
65
65
|
break;
|
|
@@ -371,7 +371,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
371
371
|
}
|
|
372
372
|
|
|
373
373
|
//#endregion
|
|
374
|
-
//#region ../sdk-core/dist/index.
|
|
374
|
+
//#region ../sdk-core/dist/index.mjs
|
|
375
375
|
/**
|
|
376
376
|
* Response utilities for debugging and working with Response objects
|
|
377
377
|
*/
|
|
@@ -678,6 +678,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
678
678
|
}
|
|
679
679
|
}
|
|
680
680
|
/**
|
|
681
|
+
* Base API client for Commerce Engine SDKs
|
|
682
|
+
* Provides common functionality without token management
|
|
683
|
+
*/
|
|
684
|
+
/**
|
|
681
685
|
* Generic base API client that all Commerce Engine SDKs can extend
|
|
682
686
|
* Handles common functionality like middleware setup, request execution, and header management
|
|
683
687
|
* Does NOT include token management - that's SDK-specific
|
|
@@ -2287,6 +2291,130 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2287
2291
|
}));
|
|
2288
2292
|
}
|
|
2289
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
|
+
/**
|
|
2290
2418
|
* Redeem loyalty points
|
|
2291
2419
|
*
|
|
2292
2420
|
* @param cartId - The ID of the cart
|
|
@@ -2345,12 +2473,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2345
2473
|
* @returns Promise with updated cart
|
|
2346
2474
|
* @example
|
|
2347
2475
|
* ```typescript
|
|
2476
|
+
* // For delivery fulfillment with shipments
|
|
2348
2477
|
* const { data, error } = await sdk.cart.updateFulfillmentPreference(
|
|
2349
2478
|
* { id: "01H9CART12345ABCDE" },
|
|
2350
2479
|
* {
|
|
2351
2480
|
* fulfillment_type: "delivery",
|
|
2352
|
-
*
|
|
2353
|
-
*
|
|
2481
|
+
* shipments: [
|
|
2482
|
+
* {
|
|
2483
|
+
* id: "01H9SHIP12345ABCDE",
|
|
2484
|
+
* shipping_provider_id: "01H9PROV12345FAST",
|
|
2485
|
+
* courier_company_id: "01H9COY12345FAST" // Optional
|
|
2486
|
+
* }
|
|
2487
|
+
* ]
|
|
2354
2488
|
* }
|
|
2355
2489
|
* );
|
|
2356
2490
|
*
|
|
@@ -2360,6 +2494,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2360
2494
|
* console.log("Fulfillment preference updated:", data.cart.fulfillment_preference?.fulfillment_type);
|
|
2361
2495
|
* console.log("Shipping cost:", data.cart.shipping_amount);
|
|
2362
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
|
+
* );
|
|
2363
2506
|
* ```
|
|
2364
2507
|
*/
|
|
2365
2508
|
async updateFulfillmentPreference(cartId, body) {
|
|
@@ -2369,6 +2512,100 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2369
2512
|
}));
|
|
2370
2513
|
}
|
|
2371
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 delivery_pincode
|
|
2561
|
+
* @returns Promise with fulfillment options including collect and delivery methods
|
|
2562
|
+
* @example
|
|
2563
|
+
* ```typescript
|
|
2564
|
+
* const { data, error } = await sdk.cart.getFulfillmentOptions({
|
|
2565
|
+
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
2566
|
+
* delivery_pincode: "400001"
|
|
2567
|
+
* });
|
|
2568
|
+
*
|
|
2569
|
+
* if (error) {
|
|
2570
|
+
* console.error("Failed to get fulfillment options:", error.message);
|
|
2571
|
+
* } else {
|
|
2572
|
+
* // Check summary information
|
|
2573
|
+
* console.log("Collect available:", data.summary.collect_available);
|
|
2574
|
+
* console.log("Deliver available:", data.summary.deliver_available);
|
|
2575
|
+
* console.log("Recommended fulfillment type:", data.summary.recommended_fulfillment_type);
|
|
2576
|
+
*
|
|
2577
|
+
* // Access collect options
|
|
2578
|
+
* if (data.collect && data.collect.length > 0) {
|
|
2579
|
+
* console.log("Available stores for collection:");
|
|
2580
|
+
* data.collect.forEach(store => {
|
|
2581
|
+
* console.log(`${store.name} - ${store.distance_km}km away, ETA: ${store.collect_eta_minutes} minutes`);
|
|
2582
|
+
* });
|
|
2583
|
+
* }
|
|
2584
|
+
*
|
|
2585
|
+
* // Access delivery options (with shipments)
|
|
2586
|
+
* if (data.deliver && data.deliver.is_serviceable) {
|
|
2587
|
+
* console.log("Available shipments and shipping methods:");
|
|
2588
|
+
* data.deliver.shipments.forEach(shipment => {
|
|
2589
|
+
* console.log(`Shipment ${shipment.id}:`);
|
|
2590
|
+
* console.log(` Items: ${shipment.items.length}`);
|
|
2591
|
+
* shipment.shipping_methods.forEach(method => {
|
|
2592
|
+
* console.log(` - ${method.name}: ${method.shipping_amount}, ${method.estimated_delivery_days} days`);
|
|
2593
|
+
* // Access courier companies for auto shipping methods
|
|
2594
|
+
* if (method.courier_companies) {
|
|
2595
|
+
* method.courier_companies.forEach(courier => {
|
|
2596
|
+
* console.log(` Courier: ${courier.name} - ${courier.shipping_amount}, ${courier.estimated_delivery_days} days`);
|
|
2597
|
+
* });
|
|
2598
|
+
* }
|
|
2599
|
+
* });
|
|
2600
|
+
* });
|
|
2601
|
+
* }
|
|
2602
|
+
* }
|
|
2603
|
+
* ```
|
|
2604
|
+
*/
|
|
2605
|
+
async getFulfillmentOptions(body) {
|
|
2606
|
+
return this.executeRequest(() => this.client.POST("/carts/fulfillment-options", { body }));
|
|
2607
|
+
}
|
|
2608
|
+
/**
|
|
2372
2609
|
* Use credit balance
|
|
2373
2610
|
*
|
|
2374
2611
|
* @param cartId - The ID of the cart
|
|
@@ -2504,130 +2741,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2504
2741
|
body
|
|
2505
2742
|
}));
|
|
2506
2743
|
}
|
|
2507
|
-
/**
|
|
2508
|
-
* Get all available coupons
|
|
2509
|
-
*
|
|
2510
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2511
|
-
* @returns Promise with all available coupons
|
|
2512
|
-
* @example
|
|
2513
|
-
* ```typescript
|
|
2514
|
-
* // Get all available coupons
|
|
2515
|
-
* const { data, error } = await sdk.cart.getAvailableCoupons();
|
|
2516
|
-
*
|
|
2517
|
-
* if (error) {
|
|
2518
|
-
* console.error("Failed to get available coupons:", error.message);
|
|
2519
|
-
* } else {
|
|
2520
|
-
* const coupons = data.coupons || [];
|
|
2521
|
-
* console.log("Available coupons:", coupons.length);
|
|
2522
|
-
* coupons.forEach(coupon => {
|
|
2523
|
-
* console.log("Coupon:", coupon.code, "Discount:", coupon.discount_amount);
|
|
2524
|
-
* });
|
|
2525
|
-
* }
|
|
2526
|
-
*
|
|
2527
|
-
* // Override customer group ID for this specific request
|
|
2528
|
-
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailableCoupons({
|
|
2529
|
-
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2530
|
-
* });
|
|
2531
|
-
* ```
|
|
2532
|
-
*/
|
|
2533
|
-
async getAvailableCoupons(headers) {
|
|
2534
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
2535
|
-
return this.executeRequest(() => this.client.GET("/carts/available-coupons", { params: { header: mergedHeaders } }));
|
|
2536
|
-
}
|
|
2537
|
-
/**
|
|
2538
|
-
* Get all available promotions
|
|
2539
|
-
*
|
|
2540
|
-
* @param headers - Optional header parameters (customer_group_id, etc.)
|
|
2541
|
-
* @returns Promise with all available promotions
|
|
2542
|
-
* @example
|
|
2543
|
-
* ```typescript
|
|
2544
|
-
* // Get all available promotions
|
|
2545
|
-
* const { data, error } = await sdk.cart.getAvailablePromotions();
|
|
2546
|
-
*
|
|
2547
|
-
* if (error) {
|
|
2548
|
-
* console.error("Failed to get available promotions:", error.message);
|
|
2549
|
-
* } else {
|
|
2550
|
-
* const promotions = data.promotions || [];
|
|
2551
|
-
* console.log("Available promotions:", promotions.length);
|
|
2552
|
-
* promotions.forEach(promotion => {
|
|
2553
|
-
* console.log("Promotion:", promotion.name, "Type:", promotion.promotion_type);
|
|
2554
|
-
* });
|
|
2555
|
-
* }
|
|
2556
|
-
*
|
|
2557
|
-
* // Override customer group ID for this specific request
|
|
2558
|
-
* const { data: overrideData, error: overrideError } = await sdk.cart.getAvailablePromotions({
|
|
2559
|
-
* "x-customer-group-id": "01H9GROUP12345ABC" // Override default SDK config
|
|
2560
|
-
* });
|
|
2561
|
-
* ```
|
|
2562
|
-
*/
|
|
2563
|
-
async getAvailablePromotions(headers) {
|
|
2564
|
-
const mergedHeaders = this.mergeHeaders(headers);
|
|
2565
|
-
return this.executeRequest(() => this.client.GET("/carts/available-promotions", { params: { header: mergedHeaders } }));
|
|
2566
|
-
}
|
|
2567
|
-
/**
|
|
2568
|
-
* Evaluate promotions
|
|
2569
|
-
*
|
|
2570
|
-
* @param cartId - The ID of the cart
|
|
2571
|
-
* @returns Promise with evaluated promotions
|
|
2572
|
-
* @example
|
|
2573
|
-
* ```typescript
|
|
2574
|
-
* const { data, error } = await sdk.cart.evaluatePromotions({
|
|
2575
|
-
* id: "01H9CART12345ABCDE"
|
|
2576
|
-
* });
|
|
2577
|
-
*
|
|
2578
|
-
* if (error) {
|
|
2579
|
-
* console.error("Failed to evaluate promotions:", error.message);
|
|
2580
|
-
* } else {
|
|
2581
|
-
* const applicable = data.applicable_promotions || [];
|
|
2582
|
-
* const inapplicable = data.inapplicable_promotions || [];
|
|
2583
|
-
*
|
|
2584
|
-
* console.log("Applicable promotions:", applicable.length);
|
|
2585
|
-
* applicable.forEach(promo => {
|
|
2586
|
-
* console.log(`- ${promo.name}: ${promo.savings_message}`);
|
|
2587
|
-
* });
|
|
2588
|
-
*
|
|
2589
|
-
* console.log("Inapplicable promotions:", inapplicable.length);
|
|
2590
|
-
* inapplicable.forEach(promo => {
|
|
2591
|
-
* console.log(`- ${promo.name}: ${promo.reason}`);
|
|
2592
|
-
* });
|
|
2593
|
-
* }
|
|
2594
|
-
* ```
|
|
2595
|
-
*/
|
|
2596
|
-
async evaluatePromotions(cartId) {
|
|
2597
|
-
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-promotions", { params: { path: cartId } }));
|
|
2598
|
-
}
|
|
2599
|
-
/**
|
|
2600
|
-
* Evaluate coupons
|
|
2601
|
-
*
|
|
2602
|
-
* @param cartId - The ID of the cart
|
|
2603
|
-
* @returns Promise with evaluated coupons
|
|
2604
|
-
* @example
|
|
2605
|
-
* ```typescript
|
|
2606
|
-
* const { data, error } = await sdk.cart.evaluateCoupons({
|
|
2607
|
-
* id: "01H9CART12345ABCDE"
|
|
2608
|
-
* });
|
|
2609
|
-
*
|
|
2610
|
-
* if (error) {
|
|
2611
|
-
* console.error("Failed to evaluate coupons:", error.message);
|
|
2612
|
-
* } else {
|
|
2613
|
-
* const applicable = data.applicable_coupons || [];
|
|
2614
|
-
* const inapplicable = data.inapplicable_coupons || [];
|
|
2615
|
-
*
|
|
2616
|
-
* console.log("Applicable coupons:", applicable.length);
|
|
2617
|
-
* applicable.forEach(coupon => {
|
|
2618
|
-
* console.log(`- ${coupon.code}: Save $${coupon.estimated_discount}`);
|
|
2619
|
-
* });
|
|
2620
|
-
*
|
|
2621
|
-
* console.log("Inapplicable coupons:", inapplicable.length);
|
|
2622
|
-
* inapplicable.forEach(coupon => {
|
|
2623
|
-
* console.log(`- ${coupon.code}: ${coupon.reason}`);
|
|
2624
|
-
* });
|
|
2625
|
-
* }
|
|
2626
|
-
* ```
|
|
2627
|
-
*/
|
|
2628
|
-
async evaluateCoupons(cartId) {
|
|
2629
|
-
return this.executeRequest(() => this.client.GET("/carts/{id}/evaluate-coupons", { params: { path: cartId } }));
|
|
2630
|
-
}
|
|
2631
2744
|
};
|
|
2632
2745
|
|
|
2633
2746
|
//#endregion
|
|
@@ -3675,10 +3788,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3675
3788
|
/**
|
|
3676
3789
|
* List all available payment methods
|
|
3677
3790
|
*
|
|
3791
|
+
* @param queryParams - Query parameters containing the payment method type and payment provider slug
|
|
3678
3792
|
* @returns Promise with list of payment methods
|
|
3679
3793
|
* @example
|
|
3680
3794
|
* ```typescript
|
|
3681
|
-
* const { data, error } = await sdk.payments.listPaymentMethods(
|
|
3795
|
+
* const { data, error } = await sdk.payments.listPaymentMethods({
|
|
3796
|
+
* payment_method_type: "card",
|
|
3797
|
+
* payment_provider_slug: "payu"
|
|
3798
|
+
* });
|
|
3682
3799
|
*
|
|
3683
3800
|
* if (error) {
|
|
3684
3801
|
* console.error("Failed to list payment methods:", error.message);
|
|
@@ -3692,8 +3809,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3692
3809
|
* }
|
|
3693
3810
|
* ```
|
|
3694
3811
|
*/
|
|
3695
|
-
async listPaymentMethods() {
|
|
3696
|
-
return this.executeRequest(() => this.client.GET("/payments/payment-methods", {}));
|
|
3812
|
+
async listPaymentMethods(queryParams) {
|
|
3813
|
+
return this.executeRequest(() => this.client.GET("/payments/payment-methods", { params: { query: queryParams } }));
|
|
3697
3814
|
}
|
|
3698
3815
|
/**
|
|
3699
3816
|
* Verify a UPI Virtual Payment Address (VPA)
|
|
@@ -3728,6 +3845,29 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3728
3845
|
return this.executeRequest(() => this.client.GET("/payments/verify-vpa", { params: { query: queryParams } }));
|
|
3729
3846
|
}
|
|
3730
3847
|
/**
|
|
3848
|
+
* Get card information
|
|
3849
|
+
*
|
|
3850
|
+
* Retrieves card information based on the initial 9 digits (card BIN) of the card number.
|
|
3851
|
+
*
|
|
3852
|
+
* @param queryParams - Query parameters containing the card BIN
|
|
3853
|
+
* @returns Promise with card information
|
|
3854
|
+
* @example
|
|
3855
|
+
* ```typescript
|
|
3856
|
+
* const { data, error } = await sdk.payments.getCardInfo({
|
|
3857
|
+
* cardbin: "411111111"
|
|
3858
|
+
* });
|
|
3859
|
+
*
|
|
3860
|
+
* if (error) {
|
|
3861
|
+
* console.error("Failed to get card information:", error.message);
|
|
3862
|
+
* } else {
|
|
3863
|
+
* console.log("Card information:", data.card_info);
|
|
3864
|
+
* }
|
|
3865
|
+
* ```
|
|
3866
|
+
*/
|
|
3867
|
+
async getCardInfo(queryParams) {
|
|
3868
|
+
return this.executeRequest(() => this.client.GET("/payments/card-info", { params: { query: queryParams } }));
|
|
3869
|
+
}
|
|
3870
|
+
/**
|
|
3731
3871
|
* Authenticate a direct OTP for payment verification
|
|
3732
3872
|
*
|
|
3733
3873
|
* @description Used to authenticate OTP during payment flows that require 2FA verification.
|
|
@@ -3786,82 +3926,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3786
3926
|
}
|
|
3787
3927
|
};
|
|
3788
3928
|
|
|
3789
|
-
//#endregion
|
|
3790
|
-
//#region src/lib/shipping.ts
|
|
3791
|
-
/**
|
|
3792
|
-
* Client for interacting with shipping endpoints
|
|
3793
|
-
*/
|
|
3794
|
-
var ShippingClient = class extends StorefrontAPIClient {
|
|
3795
|
-
/**
|
|
3796
|
-
* Check pincode deliverability
|
|
3797
|
-
*
|
|
3798
|
-
* @param pathParams - Path parameters
|
|
3799
|
-
* @returns Promise with pincode deliverability result
|
|
3800
|
-
* @example
|
|
3801
|
-
* ```typescript
|
|
3802
|
-
* const { data, error } = await sdk.shipping.checkPincodeDeliverability({
|
|
3803
|
-
* pincode: "400001"
|
|
3804
|
-
* });
|
|
3805
|
-
*
|
|
3806
|
-
* if (error) {
|
|
3807
|
-
* console.error("Failed to check pincode serviceability:", error.message);
|
|
3808
|
-
* } else {
|
|
3809
|
-
* console.log("Pincode serviceable:", data.is_serviceable);
|
|
3810
|
-
*
|
|
3811
|
-
* if (data.is_serviceable) {
|
|
3812
|
-
* console.log("Delivery is available to this pincode");
|
|
3813
|
-
* } else {
|
|
3814
|
-
* console.log("Delivery is not available to this pincode");
|
|
3815
|
-
* }
|
|
3816
|
-
* }
|
|
3817
|
-
* ```
|
|
3818
|
-
*/
|
|
3819
|
-
async checkPincodeDeliverability(pathParams) {
|
|
3820
|
-
return this.executeRequest(() => this.client.GET("/shipping/serviceability/{pincode}", { params: { path: pathParams } }));
|
|
3821
|
-
}
|
|
3822
|
-
/**
|
|
3823
|
-
* Get fulfillment options for an order
|
|
3824
|
-
*
|
|
3825
|
-
* @param body - Fulfillment options body containing cart_id and delivery_pincode
|
|
3826
|
-
* @returns Promise with fulfillment options including collect and delivery methods
|
|
3827
|
-
* @example
|
|
3828
|
-
* ```typescript
|
|
3829
|
-
* const { data, error } = await sdk.shipping.getFulfillmentOptions({
|
|
3830
|
-
* cart_id: "cart_01H9XYZ12345ABCDE",
|
|
3831
|
-
* delivery_pincode: "400001"
|
|
3832
|
-
* });
|
|
3833
|
-
*
|
|
3834
|
-
* if (error) {
|
|
3835
|
-
* console.error("Failed to get fulfillment options:", error.message);
|
|
3836
|
-
* } else {
|
|
3837
|
-
* // Check summary information
|
|
3838
|
-
* console.log("Collect available:", data.summary.collect_available);
|
|
3839
|
-
* console.log("Deliver available:", data.summary.deliver_available);
|
|
3840
|
-
* console.log("Recommended fulfillment type:", data.summary.recommended_fulfillment_type);
|
|
3841
|
-
*
|
|
3842
|
-
* // Access collect options
|
|
3843
|
-
* if (data.collect && data.collect.length > 0) {
|
|
3844
|
-
* console.log("Available stores for collection:");
|
|
3845
|
-
* data.collect.forEach(store => {
|
|
3846
|
-
* console.log(`${store.name} - ${store.distance_km}km away, ETA: ${store.collect_eta_minutes} minutes`);
|
|
3847
|
-
* });
|
|
3848
|
-
* }
|
|
3849
|
-
*
|
|
3850
|
-
* // Access delivery options
|
|
3851
|
-
* if (data.deliver && data.deliver.is_serviceable) {
|
|
3852
|
-
* console.log("Available shipping methods:");
|
|
3853
|
-
* data.deliver.shipping_methods.forEach(method => {
|
|
3854
|
-
* console.log(`${method.name} - ${method.shipping_amount}, ${method.estimated_delivery_days} days`);
|
|
3855
|
-
* });
|
|
3856
|
-
* }
|
|
3857
|
-
* }
|
|
3858
|
-
* ```
|
|
3859
|
-
*/
|
|
3860
|
-
async getFulfillmentOptions(body) {
|
|
3861
|
-
return this.executeRequest(() => this.client.POST("/shipping/fulfillment-options", { body }));
|
|
3862
|
-
}
|
|
3863
|
-
};
|
|
3864
|
-
|
|
3865
3929
|
//#endregion
|
|
3866
3930
|
//#region src/lib/helper.ts
|
|
3867
3931
|
/**
|
|
@@ -4319,6 +4383,29 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4319
4383
|
async listSavedPaymentMethods(pathParams) {
|
|
4320
4384
|
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/payment-methods", { params: { path: pathParams } }));
|
|
4321
4385
|
}
|
|
4386
|
+
/**
|
|
4387
|
+
* List all saved cards for a customer
|
|
4388
|
+
*
|
|
4389
|
+
* @param pathParams - Path parameters
|
|
4390
|
+
* @returns Promise with cards
|
|
4391
|
+
*
|
|
4392
|
+
* @example
|
|
4393
|
+
* ```typescript
|
|
4394
|
+
* const { data, error } = await sdk.customer.listCustomerCards({
|
|
4395
|
+
* customer_id: "customer_123"
|
|
4396
|
+
* });
|
|
4397
|
+
*
|
|
4398
|
+
* if (error) {
|
|
4399
|
+
* console.error("Failed to list customer cards:", error);
|
|
4400
|
+
* return;
|
|
4401
|
+
* }
|
|
4402
|
+
*
|
|
4403
|
+
* console.log("Customer cards:", data.cards);
|
|
4404
|
+
* ```
|
|
4405
|
+
*/
|
|
4406
|
+
async listCustomerCards(pathParams) {
|
|
4407
|
+
return this.executeRequest(() => this.client.GET("/customers/{customer_id}/cards", { params: { path: pathParams } }));
|
|
4408
|
+
}
|
|
4322
4409
|
};
|
|
4323
4410
|
|
|
4324
4411
|
//#endregion
|
|
@@ -4381,10 +4468,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4381
4468
|
*/
|
|
4382
4469
|
helpers;
|
|
4383
4470
|
/**
|
|
4384
|
-
* Client for shipping-related endpoints
|
|
4385
|
-
*/
|
|
4386
|
-
shipping;
|
|
4387
|
-
/**
|
|
4388
4471
|
* Client for order-related endpoints
|
|
4389
4472
|
*/
|
|
4390
4473
|
order;
|
|
@@ -4427,7 +4510,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4427
4510
|
this.auth = new AuthClient(config);
|
|
4428
4511
|
this.customer = new CustomerClient(config);
|
|
4429
4512
|
this.helpers = new HelpersClient(config);
|
|
4430
|
-
this.shipping = new ShippingClient(config);
|
|
4431
4513
|
this.order = new OrderClient(config);
|
|
4432
4514
|
this.payments = new PaymentsClient(config);
|
|
4433
4515
|
this.store = new StoreConfigClient(config);
|
|
@@ -4448,7 +4530,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4448
4530
|
await this.auth.setTokens(accessToken, refreshToken);
|
|
4449
4531
|
await this.customer.setTokens(accessToken, refreshToken);
|
|
4450
4532
|
await this.helpers.setTokens(accessToken, refreshToken);
|
|
4451
|
-
await this.shipping.setTokens(accessToken, refreshToken);
|
|
4452
4533
|
await this.order.setTokens(accessToken, refreshToken);
|
|
4453
4534
|
await this.payments.setTokens(accessToken, refreshToken);
|
|
4454
4535
|
await this.store.setTokens(accessToken, refreshToken);
|
|
@@ -4466,7 +4547,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4466
4547
|
await this.auth.clearTokens();
|
|
4467
4548
|
await this.customer.clearTokens();
|
|
4468
4549
|
await this.helpers.clearTokens();
|
|
4469
|
-
await this.shipping.clearTokens();
|
|
4470
4550
|
await this.order.clearTokens();
|
|
4471
4551
|
await this.payments.clearTokens();
|
|
4472
4552
|
await this.store.clearTokens();
|
|
@@ -4482,7 +4562,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4482
4562
|
this.auth.setApiKey(apiKey);
|
|
4483
4563
|
this.customer.setApiKey(apiKey);
|
|
4484
4564
|
this.helpers.setApiKey(apiKey);
|
|
4485
|
-
this.shipping.setApiKey(apiKey);
|
|
4486
4565
|
this.order.setApiKey(apiKey);
|
|
4487
4566
|
this.payments.setApiKey(apiKey);
|
|
4488
4567
|
this.store.setApiKey(apiKey);
|
|
@@ -4496,7 +4575,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4496
4575
|
this.auth.clearApiKey();
|
|
4497
4576
|
this.customer.clearApiKey();
|
|
4498
4577
|
this.helpers.clearApiKey();
|
|
4499
|
-
this.shipping.clearApiKey();
|
|
4500
4578
|
this.order.clearApiKey();
|
|
4501
4579
|
this.payments.clearApiKey();
|
|
4502
4580
|
this.store.clearApiKey();
|
|
@@ -4575,7 +4653,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4575
4653
|
this.auth.setDefaultHeaders(headers);
|
|
4576
4654
|
this.customer.setDefaultHeaders(headers);
|
|
4577
4655
|
this.helpers.setDefaultHeaders(headers);
|
|
4578
|
-
this.shipping.setDefaultHeaders(headers);
|
|
4579
4656
|
this.order.setDefaultHeaders(headers);
|
|
4580
4657
|
this.payments.setDefaultHeaders(headers);
|
|
4581
4658
|
this.store.setDefaultHeaders(headers);
|
|
@@ -4604,7 +4681,6 @@ exports.MemoryTokenStorage = MemoryTokenStorage;
|
|
|
4604
4681
|
exports.OrderClient = OrderClient;
|
|
4605
4682
|
exports.PaymentsClient = PaymentsClient;
|
|
4606
4683
|
exports.ResponseUtils = ResponseUtils;
|
|
4607
|
-
exports.ShippingClient = ShippingClient;
|
|
4608
4684
|
exports.StoreConfigClient = StoreConfigClient;
|
|
4609
4685
|
exports.StorefrontAPIClient = StorefrontAPIClient;
|
|
4610
4686
|
exports.StorefrontSDK = StorefrontSDK;
|