@basedone/core 0.2.6 → 0.2.7
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/{chunk-CAU4QLVH.mjs → chunk-L63E7FZC.mjs} +159 -116
- package/dist/ecommerce.d.mts +55 -1
- package/dist/ecommerce.d.ts +55 -1
- package/dist/ecommerce.js +159 -116
- package/dist/ecommerce.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +159 -116
- package/dist/index.mjs +1 -1
- package/lib/ecommerce/client/customer.ts +261 -186
- package/lib/ecommerce/types/requests.ts +5 -0
- package/lib/ecommerce/types/responses.ts +90 -48
- package/package.json +10 -8
|
@@ -314,10 +314,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
314
314
|
// ============================================================================
|
|
315
315
|
/**
|
|
316
316
|
* List products with filtering and pagination
|
|
317
|
-
*
|
|
317
|
+
*
|
|
318
318
|
* @param params - Query parameters for filtering
|
|
319
319
|
* @returns Paginated list of products
|
|
320
|
-
*
|
|
320
|
+
*
|
|
321
321
|
* @example
|
|
322
322
|
* ```typescript
|
|
323
323
|
* const products = await client.listProducts({
|
|
@@ -337,10 +337,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
337
337
|
}
|
|
338
338
|
/**
|
|
339
339
|
* Get product details by ID
|
|
340
|
-
*
|
|
340
|
+
*
|
|
341
341
|
* @param productId - Product ID
|
|
342
342
|
* @returns Product details with merchant info, variants, and reviews
|
|
343
|
-
*
|
|
343
|
+
*
|
|
344
344
|
* @example
|
|
345
345
|
* ```typescript
|
|
346
346
|
* const product = await client.getProduct("prod_123");
|
|
@@ -352,10 +352,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
352
352
|
}
|
|
353
353
|
/**
|
|
354
354
|
* Track product view (increment view count)
|
|
355
|
-
*
|
|
355
|
+
*
|
|
356
356
|
* @param productId - Product ID
|
|
357
357
|
* @returns Success response
|
|
358
|
-
*
|
|
358
|
+
*
|
|
359
359
|
* @example
|
|
360
360
|
* ```typescript
|
|
361
361
|
* await client.trackProductView("prod_123");
|
|
@@ -366,10 +366,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
366
366
|
}
|
|
367
367
|
/**
|
|
368
368
|
* Get active automatic discounts for a product
|
|
369
|
-
*
|
|
369
|
+
*
|
|
370
370
|
* @param productId - Product ID
|
|
371
371
|
* @returns List of applicable discounts
|
|
372
|
-
*
|
|
372
|
+
*
|
|
373
373
|
* @example
|
|
374
374
|
* ```typescript
|
|
375
375
|
* const discounts = await client.getProductDiscounts("prod_123");
|
|
@@ -384,17 +384,17 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
384
384
|
// ============================================================================
|
|
385
385
|
/**
|
|
386
386
|
* Create order from cart checkout
|
|
387
|
-
*
|
|
387
|
+
*
|
|
388
388
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
389
|
-
*
|
|
389
|
+
*
|
|
390
390
|
* **IMPORTANT: Shipping Cost Security**
|
|
391
391
|
* - Use `shippingRateId` to specify the selected shipping rate
|
|
392
392
|
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
393
393
|
* - Get available rates from `calculateShippingOptions()` first
|
|
394
|
-
*
|
|
394
|
+
*
|
|
395
395
|
* @param request - Order creation request
|
|
396
396
|
* @returns Created order(s) with payment instructions
|
|
397
|
-
*
|
|
397
|
+
*
|
|
398
398
|
* @example
|
|
399
399
|
* ```typescript
|
|
400
400
|
* // Step 1: Calculate available shipping options
|
|
@@ -404,10 +404,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
404
404
|
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
405
405
|
* orderSubtotal: 59.98
|
|
406
406
|
* });
|
|
407
|
-
*
|
|
407
|
+
*
|
|
408
408
|
* // Step 2: Let user select a shipping option, get the rateId
|
|
409
409
|
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
410
|
-
*
|
|
410
|
+
*
|
|
411
411
|
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
412
412
|
* const result = await client.createOrder({
|
|
413
413
|
* items: [
|
|
@@ -427,7 +427,7 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
427
427
|
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
428
428
|
* couponCode: "SAVE10"
|
|
429
429
|
* });
|
|
430
|
-
*
|
|
430
|
+
*
|
|
431
431
|
* // For USDC escrow, deposit to the escrow address
|
|
432
432
|
* if (result.escrow) {
|
|
433
433
|
* console.log("Deposit", result.escrow.amountUSDC, "USDC to", result.escrow.address);
|
|
@@ -439,10 +439,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
439
439
|
}
|
|
440
440
|
/**
|
|
441
441
|
* List user's orders
|
|
442
|
-
*
|
|
442
|
+
*
|
|
443
443
|
* @param params - Query parameters for filtering
|
|
444
444
|
* @returns Paginated list of orders
|
|
445
|
-
*
|
|
445
|
+
*
|
|
446
446
|
* @example
|
|
447
447
|
* ```typescript
|
|
448
448
|
* const orders = await client.listOrders({
|
|
@@ -458,10 +458,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
458
458
|
}
|
|
459
459
|
/**
|
|
460
460
|
* Get order details by ID
|
|
461
|
-
*
|
|
461
|
+
*
|
|
462
462
|
* @param orderId - Order ID
|
|
463
463
|
* @returns Order details with items, payment, and shipment info
|
|
464
|
-
*
|
|
464
|
+
*
|
|
465
465
|
* @example
|
|
466
466
|
* ```typescript
|
|
467
467
|
* const order = await client.getOrder("ord_123");
|
|
@@ -473,12 +473,12 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
473
473
|
}
|
|
474
474
|
/**
|
|
475
475
|
* Confirm USDC escrow deposit for order payment
|
|
476
|
-
*
|
|
476
|
+
*
|
|
477
477
|
* Verifies the Hyperliquid transaction and updates order status.
|
|
478
|
-
*
|
|
478
|
+
*
|
|
479
479
|
* @param orderId - Order ID
|
|
480
480
|
* @returns Confirmation response with transaction hash
|
|
481
|
-
*
|
|
481
|
+
*
|
|
482
482
|
* @example
|
|
483
483
|
* ```typescript
|
|
484
484
|
* // After depositing USDC to escrow address
|
|
@@ -487,14 +487,16 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
487
487
|
* ```
|
|
488
488
|
*/
|
|
489
489
|
async confirmEscrowDeposit(orderId) {
|
|
490
|
-
return this.post(
|
|
490
|
+
return this.post(
|
|
491
|
+
`/api/marketplace/orders/${orderId}/confirm-escrow-deposit`
|
|
492
|
+
);
|
|
491
493
|
}
|
|
492
494
|
/**
|
|
493
495
|
* Get order receipt
|
|
494
|
-
*
|
|
496
|
+
*
|
|
495
497
|
* @param orderId - Order ID
|
|
496
498
|
* @returns Order receipt for download/display
|
|
497
|
-
*
|
|
499
|
+
*
|
|
498
500
|
* @example
|
|
499
501
|
* ```typescript
|
|
500
502
|
* const receipt = await client.getOrderReceipt("ord_123");
|
|
@@ -509,11 +511,11 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
509
511
|
// ============================================================================
|
|
510
512
|
/**
|
|
511
513
|
* List reviews for a product
|
|
512
|
-
*
|
|
514
|
+
*
|
|
513
515
|
* @param productId - Product ID
|
|
514
516
|
* @param params - Query parameters
|
|
515
517
|
* @returns Paginated list of reviews
|
|
516
|
-
*
|
|
518
|
+
*
|
|
517
519
|
* @example
|
|
518
520
|
* ```typescript
|
|
519
521
|
* const reviews = await client.listProductReviews("prod_123", {
|
|
@@ -524,17 +526,19 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
524
526
|
*/
|
|
525
527
|
async listProductReviews(productId, params) {
|
|
526
528
|
const queryString = params ? buildQueryString(params) : "";
|
|
527
|
-
return this.get(
|
|
529
|
+
return this.get(
|
|
530
|
+
`/api/marketplace/products/${productId}/reviews${queryString}`
|
|
531
|
+
);
|
|
528
532
|
}
|
|
529
533
|
/**
|
|
530
534
|
* Create a product review
|
|
531
|
-
*
|
|
535
|
+
*
|
|
532
536
|
* Requires authenticated user who has purchased the product.
|
|
533
|
-
*
|
|
537
|
+
*
|
|
534
538
|
* @param productId - Product ID
|
|
535
539
|
* @param request - Review creation request
|
|
536
540
|
* @returns Created review
|
|
537
|
-
*
|
|
541
|
+
*
|
|
538
542
|
* @example
|
|
539
543
|
* ```typescript
|
|
540
544
|
* const review = await client.createReview("prod_123", {
|
|
@@ -552,9 +556,9 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
552
556
|
// ============================================================================
|
|
553
557
|
/**
|
|
554
558
|
* List saved shipping addresses
|
|
555
|
-
*
|
|
559
|
+
*
|
|
556
560
|
* @returns List of user's saved shipping addresses
|
|
557
|
-
*
|
|
561
|
+
*
|
|
558
562
|
* @example
|
|
559
563
|
* ```typescript
|
|
560
564
|
* const addresses = await client.listShippingAddresses();
|
|
@@ -566,10 +570,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
566
570
|
}
|
|
567
571
|
/**
|
|
568
572
|
* Create a new shipping address
|
|
569
|
-
*
|
|
573
|
+
*
|
|
570
574
|
* @param request - Shipping address data
|
|
571
575
|
* @returns Created address
|
|
572
|
-
*
|
|
576
|
+
*
|
|
573
577
|
* @example
|
|
574
578
|
* ```typescript
|
|
575
579
|
* const address = await client.createShippingAddress({
|
|
@@ -590,11 +594,11 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
590
594
|
}
|
|
591
595
|
/**
|
|
592
596
|
* Update a shipping address
|
|
593
|
-
*
|
|
597
|
+
*
|
|
594
598
|
* @param addressId - Address ID
|
|
595
599
|
* @param request - Updated address data
|
|
596
600
|
* @returns Updated address
|
|
597
|
-
*
|
|
601
|
+
*
|
|
598
602
|
* @example
|
|
599
603
|
* ```typescript
|
|
600
604
|
* const address = await client.updateShippingAddress("addr_123", {
|
|
@@ -607,10 +611,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
607
611
|
}
|
|
608
612
|
/**
|
|
609
613
|
* Delete a shipping address
|
|
610
|
-
*
|
|
614
|
+
*
|
|
611
615
|
* @param addressId - Address ID
|
|
612
616
|
* @returns Success response
|
|
613
|
-
*
|
|
617
|
+
*
|
|
614
618
|
* @example
|
|
615
619
|
* ```typescript
|
|
616
620
|
* await client.deleteShippingAddress("addr_123");
|
|
@@ -624,10 +628,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
624
628
|
// ============================================================================
|
|
625
629
|
/**
|
|
626
630
|
* Calculate automatic discounts for cart items
|
|
627
|
-
*
|
|
631
|
+
*
|
|
628
632
|
* @param request - Cart items
|
|
629
633
|
* @returns Calculated discounts and totals
|
|
630
|
-
*
|
|
634
|
+
*
|
|
631
635
|
* @example
|
|
632
636
|
* ```typescript
|
|
633
637
|
* const result = await client.calculateCartDiscounts({
|
|
@@ -646,10 +650,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
646
650
|
}
|
|
647
651
|
/**
|
|
648
652
|
* Validate a discount code for cart items
|
|
649
|
-
*
|
|
653
|
+
*
|
|
650
654
|
* @param request - Discount code and cart items
|
|
651
655
|
* @returns Validation result with discount details
|
|
652
|
-
*
|
|
656
|
+
*
|
|
653
657
|
* @example
|
|
654
658
|
* ```typescript
|
|
655
659
|
* const result = await client.validateDiscountCode({
|
|
@@ -658,7 +662,7 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
658
662
|
* { productId: "prod_123", quantity: 2 }
|
|
659
663
|
* ]
|
|
660
664
|
* });
|
|
661
|
-
*
|
|
665
|
+
*
|
|
662
666
|
* if (result.valid) {
|
|
663
667
|
* console.log("Discount:", result.discount?.discountAmount);
|
|
664
668
|
* } else {
|
|
@@ -674,10 +678,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
674
678
|
// ============================================================================
|
|
675
679
|
/**
|
|
676
680
|
* Calculate tax for cart items based on shipping address
|
|
677
|
-
*
|
|
681
|
+
*
|
|
678
682
|
* @param request - Cart items and shipping address
|
|
679
683
|
* @returns Tax calculation with breakdown
|
|
680
|
-
*
|
|
684
|
+
*
|
|
681
685
|
* @example
|
|
682
686
|
* ```typescript
|
|
683
687
|
* const result = await client.calculateTax({
|
|
@@ -702,10 +706,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
702
706
|
// ============================================================================
|
|
703
707
|
/**
|
|
704
708
|
* Calculate shipping options for cart items
|
|
705
|
-
*
|
|
709
|
+
*
|
|
706
710
|
* @param request - Cart items, merchant, and destination
|
|
707
711
|
* @returns Available shipping options with costs
|
|
708
|
-
*
|
|
712
|
+
*
|
|
709
713
|
* @example
|
|
710
714
|
* ```typescript
|
|
711
715
|
* const result = await client.calculateShippingOptions({
|
|
@@ -716,7 +720,7 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
716
720
|
* destinationCountry: "US",
|
|
717
721
|
* orderSubtotal: 99.99
|
|
718
722
|
* });
|
|
719
|
-
*
|
|
723
|
+
*
|
|
720
724
|
* result.shippingOptions.forEach(opt => {
|
|
721
725
|
* console.log(opt.name, opt.cost, opt.estimatedDelivery);
|
|
722
726
|
* });
|
|
@@ -730,10 +734,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
730
734
|
// ============================================================================
|
|
731
735
|
/**
|
|
732
736
|
* Get active promotional banners
|
|
733
|
-
*
|
|
737
|
+
*
|
|
734
738
|
* @param params - Query parameters
|
|
735
739
|
* @returns List of active banners
|
|
736
|
-
*
|
|
740
|
+
*
|
|
737
741
|
* @example
|
|
738
742
|
* ```typescript
|
|
739
743
|
* const banners = await client.getActiveBanners({
|
|
@@ -748,16 +752,16 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
748
752
|
}
|
|
749
753
|
/**
|
|
750
754
|
* Track banner impression or click
|
|
751
|
-
*
|
|
755
|
+
*
|
|
752
756
|
* @param bannerId - Banner ID
|
|
753
757
|
* @param request - Track action (impression or click)
|
|
754
758
|
* @returns Success response
|
|
755
|
-
*
|
|
759
|
+
*
|
|
756
760
|
* @example
|
|
757
761
|
* ```typescript
|
|
758
762
|
* // Track impression
|
|
759
763
|
* await client.trackBanner("banner_123", { action: "impression" });
|
|
760
|
-
*
|
|
764
|
+
*
|
|
761
765
|
* // Track click
|
|
762
766
|
* await client.trackBanner("banner_123", { action: "click" });
|
|
763
767
|
* ```
|
|
@@ -770,12 +774,12 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
770
774
|
// ============================================================================
|
|
771
775
|
/**
|
|
772
776
|
* List messages for customer
|
|
773
|
-
*
|
|
777
|
+
*
|
|
774
778
|
* Returns all conversations grouped by order, where each order represents
|
|
775
779
|
* a conversation with a merchant.
|
|
776
|
-
*
|
|
780
|
+
*
|
|
777
781
|
* @returns List of conversations with messages and stats
|
|
778
|
-
*
|
|
782
|
+
*
|
|
779
783
|
* @example
|
|
780
784
|
* ```typescript
|
|
781
785
|
* const result = await client.listMessages();
|
|
@@ -790,11 +794,11 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
790
794
|
}
|
|
791
795
|
/**
|
|
792
796
|
* Get message stats (unread count)
|
|
793
|
-
*
|
|
797
|
+
*
|
|
794
798
|
* Lightweight endpoint for notification badges.
|
|
795
|
-
*
|
|
799
|
+
*
|
|
796
800
|
* @returns Unread message count
|
|
797
|
-
*
|
|
801
|
+
*
|
|
798
802
|
* @example
|
|
799
803
|
* ```typescript
|
|
800
804
|
* const stats = await client.getMessageStats();
|
|
@@ -806,10 +810,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
806
810
|
}
|
|
807
811
|
/**
|
|
808
812
|
* Send a message to a merchant about an order
|
|
809
|
-
*
|
|
813
|
+
*
|
|
810
814
|
* @param request - Message data including orderId, recipientId (merchant user ID), and message
|
|
811
815
|
* @returns Sent message
|
|
812
|
-
*
|
|
816
|
+
*
|
|
813
817
|
* @example
|
|
814
818
|
* ```typescript
|
|
815
819
|
* await client.sendMessage({
|
|
@@ -824,10 +828,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
824
828
|
}
|
|
825
829
|
/**
|
|
826
830
|
* Mark a message as read
|
|
827
|
-
*
|
|
831
|
+
*
|
|
828
832
|
* @param messageId - Message ID
|
|
829
833
|
* @returns Updated message
|
|
830
|
-
*
|
|
834
|
+
*
|
|
831
835
|
* @example
|
|
832
836
|
* ```typescript
|
|
833
837
|
* await client.markMessageAsRead("msg_123");
|
|
@@ -841,24 +845,24 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
841
845
|
// ============================================================================
|
|
842
846
|
/**
|
|
843
847
|
* Get active flash sales
|
|
844
|
-
*
|
|
848
|
+
*
|
|
845
849
|
* Returns currently running flash sales with their discounted products.
|
|
846
850
|
* Includes countdown timer information for UI display.
|
|
847
|
-
*
|
|
851
|
+
*
|
|
848
852
|
* @param params - Query parameters
|
|
849
853
|
* @returns List of active flash sales with time remaining
|
|
850
|
-
*
|
|
854
|
+
*
|
|
851
855
|
* @example
|
|
852
856
|
* ```typescript
|
|
853
857
|
* const result = await client.getActiveFlashSales({ limit: 5 });
|
|
854
|
-
*
|
|
858
|
+
*
|
|
855
859
|
* result.flashSales.forEach(sale => {
|
|
856
860
|
* console.log(`${sale.name} - ends at ${sale.endsAt}`);
|
|
857
861
|
* sale.items.forEach(item => {
|
|
858
862
|
* console.log(` ${item.product.title}: $${item.salePrice} (${item.discountPercent}% off)`);
|
|
859
863
|
* });
|
|
860
864
|
* });
|
|
861
|
-
*
|
|
865
|
+
*
|
|
862
866
|
* // Use timeRemaining for countdown UI
|
|
863
867
|
* if (result.timeRemaining) {
|
|
864
868
|
* console.log(`Featured sale ends in ${result.timeRemaining.remainingSeconds} seconds`);
|
|
@@ -871,19 +875,19 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
871
875
|
}
|
|
872
876
|
/**
|
|
873
877
|
* Get flash sale allowance
|
|
874
|
-
*
|
|
878
|
+
*
|
|
875
879
|
* Fetches user's remaining purchase allowance for flash sale items.
|
|
876
880
|
* Used to enforce per-customer purchase limits.
|
|
877
|
-
*
|
|
881
|
+
*
|
|
878
882
|
* @param params - Request params with product IDs
|
|
879
883
|
* @returns Allowance info for each product
|
|
880
|
-
*
|
|
884
|
+
*
|
|
881
885
|
* @example
|
|
882
886
|
* ```typescript
|
|
883
887
|
* const result = await client.getFlashSaleAllowance({
|
|
884
888
|
* productIds: ["prod_123", "prod_456"]
|
|
885
889
|
* });
|
|
886
|
-
*
|
|
890
|
+
*
|
|
887
891
|
* Object.entries(result.allowances).forEach(([productId, info]) => {
|
|
888
892
|
* if (info.limitPerCustomer !== null) {
|
|
889
893
|
* console.log(`Product ${productId}:`);
|
|
@@ -895,7 +899,9 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
895
899
|
* ```
|
|
896
900
|
*/
|
|
897
901
|
async getFlashSaleAllowance(params) {
|
|
898
|
-
const queryString = buildQueryString({
|
|
902
|
+
const queryString = buildQueryString({
|
|
903
|
+
productIds: params.productIds.join(",")
|
|
904
|
+
});
|
|
899
905
|
return this.get(`/api/marketplace/flash-sales/allowance${queryString}`);
|
|
900
906
|
}
|
|
901
907
|
// ============================================================================
|
|
@@ -903,12 +909,12 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
903
909
|
// ============================================================================
|
|
904
910
|
/**
|
|
905
911
|
* Get public merchant profile
|
|
906
|
-
*
|
|
912
|
+
*
|
|
907
913
|
* Fetches public information about a merchant for the storefront page.
|
|
908
|
-
*
|
|
914
|
+
*
|
|
909
915
|
* @param merchantId - Merchant ID
|
|
910
916
|
* @returns Public merchant profile with stats
|
|
911
|
-
*
|
|
917
|
+
*
|
|
912
918
|
* @example
|
|
913
919
|
* ```typescript
|
|
914
920
|
* const result = await client.getMerchantProfile("merchant_123");
|
|
@@ -920,13 +926,13 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
920
926
|
}
|
|
921
927
|
/**
|
|
922
928
|
* List merchant products
|
|
923
|
-
*
|
|
929
|
+
*
|
|
924
930
|
* Fetches products for a specific merchant with search, filter, and sort options.
|
|
925
|
-
*
|
|
931
|
+
*
|
|
926
932
|
* @param merchantId - Merchant ID
|
|
927
933
|
* @param params - Query parameters for filtering and pagination
|
|
928
934
|
* @returns Paginated list of products
|
|
929
|
-
*
|
|
935
|
+
*
|
|
930
936
|
* @example
|
|
931
937
|
* ```typescript
|
|
932
938
|
* const result = await client.getMerchantProducts("merchant_123", {
|
|
@@ -934,7 +940,7 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
934
940
|
* sortBy: "popular",
|
|
935
941
|
* limit: 20,
|
|
936
942
|
* });
|
|
937
|
-
*
|
|
943
|
+
*
|
|
938
944
|
* result.items.forEach(product => {
|
|
939
945
|
* console.log(product.title, product.priceUSDC);
|
|
940
946
|
* });
|
|
@@ -942,17 +948,19 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
942
948
|
*/
|
|
943
949
|
async getMerchantProducts(merchantId, params) {
|
|
944
950
|
const queryString = params ? buildQueryString(params) : "";
|
|
945
|
-
return this.get(
|
|
951
|
+
return this.get(
|
|
952
|
+
`/api/marketplace/merchants/${merchantId}/products${queryString}`
|
|
953
|
+
);
|
|
946
954
|
}
|
|
947
955
|
// ============================================================================
|
|
948
956
|
// Shop Following API
|
|
949
957
|
// ============================================================================
|
|
950
958
|
/**
|
|
951
959
|
* Check if following a merchant
|
|
952
|
-
*
|
|
960
|
+
*
|
|
953
961
|
* @param merchantId - Merchant ID
|
|
954
962
|
* @returns Follow status with follow date if applicable
|
|
955
|
-
*
|
|
963
|
+
*
|
|
956
964
|
* @example
|
|
957
965
|
* ```typescript
|
|
958
966
|
* const status = await client.isFollowingMerchant("merchant_123");
|
|
@@ -966,10 +974,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
966
974
|
}
|
|
967
975
|
/**
|
|
968
976
|
* Follow a merchant
|
|
969
|
-
*
|
|
977
|
+
*
|
|
970
978
|
* @param merchantId - Merchant ID to follow
|
|
971
979
|
* @returns Follow action result
|
|
972
|
-
*
|
|
980
|
+
*
|
|
973
981
|
* @example
|
|
974
982
|
* ```typescript
|
|
975
983
|
* const result = await client.followMerchant("merchant_123");
|
|
@@ -981,10 +989,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
981
989
|
}
|
|
982
990
|
/**
|
|
983
991
|
* Unfollow a merchant
|
|
984
|
-
*
|
|
992
|
+
*
|
|
985
993
|
* @param merchantId - Merchant ID to unfollow
|
|
986
994
|
* @returns Unfollow action result
|
|
987
|
-
*
|
|
995
|
+
*
|
|
988
996
|
* @example
|
|
989
997
|
* ```typescript
|
|
990
998
|
* const result = await client.unfollowMerchant("merchant_123");
|
|
@@ -996,10 +1004,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
996
1004
|
}
|
|
997
1005
|
/**
|
|
998
1006
|
* Get list of followed merchants
|
|
999
|
-
*
|
|
1007
|
+
*
|
|
1000
1008
|
* @param params - Query parameters for pagination and sorting
|
|
1001
1009
|
* @returns Paginated list of followed merchants with their info
|
|
1002
|
-
*
|
|
1010
|
+
*
|
|
1003
1011
|
* @example
|
|
1004
1012
|
* ```typescript
|
|
1005
1013
|
* const result = await client.getFollowedMerchants({ limit: 20, sortBy: "recent" });
|
|
@@ -1017,11 +1025,11 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
1017
1025
|
// ============================================================================
|
|
1018
1026
|
/**
|
|
1019
1027
|
* Get available payment methods
|
|
1020
|
-
*
|
|
1028
|
+
*
|
|
1021
1029
|
* Returns the list of enabled payment methods that can be used during checkout.
|
|
1022
|
-
*
|
|
1030
|
+
*
|
|
1023
1031
|
* @returns List of available payment methods with display info
|
|
1024
|
-
*
|
|
1032
|
+
*
|
|
1025
1033
|
* @example
|
|
1026
1034
|
* ```typescript
|
|
1027
1035
|
* const result = await client.getPaymentMethods();
|
|
@@ -1040,12 +1048,12 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
1040
1048
|
// ============================================================================
|
|
1041
1049
|
/**
|
|
1042
1050
|
* Get user's gem balance
|
|
1043
|
-
*
|
|
1051
|
+
*
|
|
1044
1052
|
* Returns the current gem balance including total gems, available gems,
|
|
1045
1053
|
* and gems expiring soon. Gems are earned at 100 per $1 of revenue.
|
|
1046
|
-
*
|
|
1054
|
+
*
|
|
1047
1055
|
* @returns Current gem balance with USD equivalent
|
|
1048
|
-
*
|
|
1056
|
+
*
|
|
1049
1057
|
* @example
|
|
1050
1058
|
* ```typescript
|
|
1051
1059
|
* const balance = await client.getGemBalance();
|
|
@@ -1058,24 +1066,24 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
1058
1066
|
}
|
|
1059
1067
|
/**
|
|
1060
1068
|
* Get gem transaction history
|
|
1061
|
-
*
|
|
1069
|
+
*
|
|
1062
1070
|
* Returns paginated history of gem transactions including earning,
|
|
1063
1071
|
* spending, and expiration events.
|
|
1064
|
-
*
|
|
1072
|
+
*
|
|
1065
1073
|
* @param params - Query parameters for filtering and pagination
|
|
1066
1074
|
* @returns Paginated gem history
|
|
1067
|
-
*
|
|
1075
|
+
*
|
|
1068
1076
|
* @example
|
|
1069
1077
|
* ```typescript
|
|
1070
1078
|
* // Get all history
|
|
1071
1079
|
* const history = await client.getGemHistory({ limit: 20, offset: 0 });
|
|
1072
|
-
*
|
|
1080
|
+
*
|
|
1073
1081
|
* // Get only earned gems
|
|
1074
1082
|
* const earned = await client.getGemHistory({ type: "earn", limit: 10 });
|
|
1075
|
-
*
|
|
1083
|
+
*
|
|
1076
1084
|
* // Get only spent gems
|
|
1077
1085
|
* const spent = await client.getGemHistory({ type: "spend", limit: 10 });
|
|
1078
|
-
*
|
|
1086
|
+
*
|
|
1079
1087
|
* history.items.forEach(item => {
|
|
1080
1088
|
* console.log(`${item.type}: ${item.amount} gems - ${item.createdAt}`);
|
|
1081
1089
|
* });
|
|
@@ -1087,21 +1095,21 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
1087
1095
|
}
|
|
1088
1096
|
/**
|
|
1089
1097
|
* Get gems that are expiring soon
|
|
1090
|
-
*
|
|
1098
|
+
*
|
|
1091
1099
|
* Returns gem batches that will expire within the specified number of days.
|
|
1092
1100
|
* Useful for prompting users to spend gems before they expire.
|
|
1093
|
-
*
|
|
1101
|
+
*
|
|
1094
1102
|
* @param params - Query parameters (days: default 30, max 180)
|
|
1095
1103
|
* @returns Expiring gem batches with countdown info
|
|
1096
|
-
*
|
|
1104
|
+
*
|
|
1097
1105
|
* @example
|
|
1098
1106
|
* ```typescript
|
|
1099
1107
|
* // Get gems expiring in next 30 days (default)
|
|
1100
1108
|
* const expiring = await client.getExpiringGems();
|
|
1101
|
-
*
|
|
1109
|
+
*
|
|
1102
1110
|
* // Get gems expiring in next 7 days
|
|
1103
1111
|
* const urgent = await client.getExpiringGems({ days: 7 });
|
|
1104
|
-
*
|
|
1112
|
+
*
|
|
1105
1113
|
* if (expiring.totalExpiring > 0) {
|
|
1106
1114
|
* console.log(`${expiring.totalExpiring} gems expiring soon!`);
|
|
1107
1115
|
* expiring.batches.forEach(batch => {
|
|
@@ -1119,12 +1127,12 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
1119
1127
|
// ============================================================================
|
|
1120
1128
|
/**
|
|
1121
1129
|
* Get user's browsing location
|
|
1122
|
-
*
|
|
1130
|
+
*
|
|
1123
1131
|
* Returns the user's saved delivery location for geo-based product filtering.
|
|
1124
1132
|
* This location is used to show products from merchants that ship to the area.
|
|
1125
|
-
*
|
|
1133
|
+
*
|
|
1126
1134
|
* @returns Current browsing location or null if not set
|
|
1127
|
-
*
|
|
1135
|
+
*
|
|
1128
1136
|
* @example
|
|
1129
1137
|
* ```typescript
|
|
1130
1138
|
* const result = await client.getBrowsingLocation();
|
|
@@ -1138,13 +1146,13 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
1138
1146
|
}
|
|
1139
1147
|
/**
|
|
1140
1148
|
* Save user's browsing location
|
|
1141
|
-
*
|
|
1149
|
+
*
|
|
1142
1150
|
* Sets the user's delivery location for geo-based product filtering.
|
|
1143
1151
|
* Products will be filtered to show only items from merchants that ship to this location.
|
|
1144
|
-
*
|
|
1152
|
+
*
|
|
1145
1153
|
* @param request - Location data from Google Places or manual input
|
|
1146
1154
|
* @returns The saved location
|
|
1147
|
-
*
|
|
1155
|
+
*
|
|
1148
1156
|
* @example
|
|
1149
1157
|
* ```typescript
|
|
1150
1158
|
* const result = await client.saveBrowsingLocation({
|
|
@@ -1162,12 +1170,12 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
1162
1170
|
}
|
|
1163
1171
|
/**
|
|
1164
1172
|
* Clear user's browsing location
|
|
1165
|
-
*
|
|
1173
|
+
*
|
|
1166
1174
|
* Removes the user's saved delivery location. Products will no longer
|
|
1167
1175
|
* be filtered by shipping destination.
|
|
1168
|
-
*
|
|
1176
|
+
*
|
|
1169
1177
|
* @returns Success response
|
|
1170
|
-
*
|
|
1178
|
+
*
|
|
1171
1179
|
* @example
|
|
1172
1180
|
* ```typescript
|
|
1173
1181
|
* await client.clearBrowsingLocation();
|
|
@@ -1177,6 +1185,41 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
1177
1185
|
async clearBrowsingLocation() {
|
|
1178
1186
|
return this.delete("/api/user/browsing-location");
|
|
1179
1187
|
}
|
|
1188
|
+
// ============================================================================
|
|
1189
|
+
// BasedPay Cash Account API
|
|
1190
|
+
// ============================================================================
|
|
1191
|
+
/**
|
|
1192
|
+
* Get user's cash account balance for BASEDPAY
|
|
1193
|
+
*
|
|
1194
|
+
* Returns the current balance in the user's BasedPay cash account.
|
|
1195
|
+
*
|
|
1196
|
+
* @returns Cash account balance with currency
|
|
1197
|
+
*
|
|
1198
|
+
* @example
|
|
1199
|
+
* ```typescript
|
|
1200
|
+
* const balance = await client.getCashAccountBalance();
|
|
1201
|
+
* console.log(`Balance: ${balance.balance} ${balance.currency}`);
|
|
1202
|
+
* ```
|
|
1203
|
+
*/
|
|
1204
|
+
async getCashAccountBalance() {
|
|
1205
|
+
return this.get("/api/basedpay/balance");
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* Get user's delivery address for BASEDPAY
|
|
1209
|
+
*
|
|
1210
|
+
* Returns the user's delivery address for BASEDPAY.
|
|
1211
|
+
*
|
|
1212
|
+
* @returns Delivery address
|
|
1213
|
+
*
|
|
1214
|
+
* @example
|
|
1215
|
+
* ```typescript
|
|
1216
|
+
* const address = await client.getDeliveryAddress();
|
|
1217
|
+
* console.log(`Address: ${address.address}`);
|
|
1218
|
+
* ```
|
|
1219
|
+
*/
|
|
1220
|
+
async getDeliveryAddress() {
|
|
1221
|
+
return this.get("/api/basedpay/delivery-address");
|
|
1222
|
+
}
|
|
1180
1223
|
};
|
|
1181
1224
|
|
|
1182
1225
|
// lib/ecommerce/client/merchant.ts
|