@basedone/core 0.2.5 → 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-P5C65GIG.mjs → chunk-L63E7FZC.mjs} +174 -113
- package/dist/ecommerce.d.mts +103 -13
- package/dist/ecommerce.d.ts +103 -13
- package/dist/ecommerce.js +174 -113
- package/dist/ecommerce.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +174 -113
- package/dist/index.mjs +1 -1
- package/lib/ecommerce/client/customer.ts +276 -183
- package/lib/ecommerce/types/entities.ts +20 -8
- package/lib/ecommerce/types/requests.ts +22 -4
- package/lib/ecommerce/types/responses.ts +90 -48
- package/package.json +10 -8
package/dist/index.js
CHANGED
|
@@ -42650,10 +42650,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42650
42650
|
// ============================================================================
|
|
42651
42651
|
/**
|
|
42652
42652
|
* List products with filtering and pagination
|
|
42653
|
-
*
|
|
42653
|
+
*
|
|
42654
42654
|
* @param params - Query parameters for filtering
|
|
42655
42655
|
* @returns Paginated list of products
|
|
42656
|
-
*
|
|
42656
|
+
*
|
|
42657
42657
|
* @example
|
|
42658
42658
|
* ```typescript
|
|
42659
42659
|
* const products = await client.listProducts({
|
|
@@ -42673,10 +42673,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42673
42673
|
}
|
|
42674
42674
|
/**
|
|
42675
42675
|
* Get product details by ID
|
|
42676
|
-
*
|
|
42676
|
+
*
|
|
42677
42677
|
* @param productId - Product ID
|
|
42678
42678
|
* @returns Product details with merchant info, variants, and reviews
|
|
42679
|
-
*
|
|
42679
|
+
*
|
|
42680
42680
|
* @example
|
|
42681
42681
|
* ```typescript
|
|
42682
42682
|
* const product = await client.getProduct("prod_123");
|
|
@@ -42688,10 +42688,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42688
42688
|
}
|
|
42689
42689
|
/**
|
|
42690
42690
|
* Track product view (increment view count)
|
|
42691
|
-
*
|
|
42691
|
+
*
|
|
42692
42692
|
* @param productId - Product ID
|
|
42693
42693
|
* @returns Success response
|
|
42694
|
-
*
|
|
42694
|
+
*
|
|
42695
42695
|
* @example
|
|
42696
42696
|
* ```typescript
|
|
42697
42697
|
* await client.trackProductView("prod_123");
|
|
@@ -42702,10 +42702,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42702
42702
|
}
|
|
42703
42703
|
/**
|
|
42704
42704
|
* Get active automatic discounts for a product
|
|
42705
|
-
*
|
|
42705
|
+
*
|
|
42706
42706
|
* @param productId - Product ID
|
|
42707
42707
|
* @returns List of applicable discounts
|
|
42708
|
-
*
|
|
42708
|
+
*
|
|
42709
42709
|
* @example
|
|
42710
42710
|
* ```typescript
|
|
42711
42711
|
* const discounts = await client.getProductDiscounts("prod_123");
|
|
@@ -42720,14 +42720,31 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42720
42720
|
// ============================================================================
|
|
42721
42721
|
/**
|
|
42722
42722
|
* Create order from cart checkout
|
|
42723
|
-
*
|
|
42723
|
+
*
|
|
42724
42724
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
42725
|
-
*
|
|
42725
|
+
*
|
|
42726
|
+
* **IMPORTANT: Shipping Cost Security**
|
|
42727
|
+
* - Use `shippingRateId` to specify the selected shipping rate
|
|
42728
|
+
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
42729
|
+
* - Get available rates from `calculateShippingOptions()` first
|
|
42730
|
+
*
|
|
42726
42731
|
* @param request - Order creation request
|
|
42727
42732
|
* @returns Created order(s) with payment instructions
|
|
42728
|
-
*
|
|
42733
|
+
*
|
|
42729
42734
|
* @example
|
|
42730
42735
|
* ```typescript
|
|
42736
|
+
* // Step 1: Calculate available shipping options
|
|
42737
|
+
* const shippingOptions = await client.calculateShippingOptions({
|
|
42738
|
+
* merchantId: "merchant_123",
|
|
42739
|
+
* destinationCountry: "US",
|
|
42740
|
+
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
42741
|
+
* orderSubtotal: 59.98
|
|
42742
|
+
* });
|
|
42743
|
+
*
|
|
42744
|
+
* // Step 2: Let user select a shipping option, get the rateId
|
|
42745
|
+
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
42746
|
+
*
|
|
42747
|
+
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
42731
42748
|
* const result = await client.createOrder({
|
|
42732
42749
|
* items: [
|
|
42733
42750
|
* { productId: "prod_123", quantity: 2 },
|
|
@@ -42743,9 +42760,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42743
42760
|
* postalCode: "10001",
|
|
42744
42761
|
* country: "US"
|
|
42745
42762
|
* },
|
|
42763
|
+
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
42746
42764
|
* couponCode: "SAVE10"
|
|
42747
42765
|
* });
|
|
42748
|
-
*
|
|
42766
|
+
*
|
|
42749
42767
|
* // For USDC escrow, deposit to the escrow address
|
|
42750
42768
|
* if (result.escrow) {
|
|
42751
42769
|
* console.log("Deposit", result.escrow.amountUSDC, "USDC to", result.escrow.address);
|
|
@@ -42757,10 +42775,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42757
42775
|
}
|
|
42758
42776
|
/**
|
|
42759
42777
|
* List user's orders
|
|
42760
|
-
*
|
|
42778
|
+
*
|
|
42761
42779
|
* @param params - Query parameters for filtering
|
|
42762
42780
|
* @returns Paginated list of orders
|
|
42763
|
-
*
|
|
42781
|
+
*
|
|
42764
42782
|
* @example
|
|
42765
42783
|
* ```typescript
|
|
42766
42784
|
* const orders = await client.listOrders({
|
|
@@ -42776,10 +42794,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42776
42794
|
}
|
|
42777
42795
|
/**
|
|
42778
42796
|
* Get order details by ID
|
|
42779
|
-
*
|
|
42797
|
+
*
|
|
42780
42798
|
* @param orderId - Order ID
|
|
42781
42799
|
* @returns Order details with items, payment, and shipment info
|
|
42782
|
-
*
|
|
42800
|
+
*
|
|
42783
42801
|
* @example
|
|
42784
42802
|
* ```typescript
|
|
42785
42803
|
* const order = await client.getOrder("ord_123");
|
|
@@ -42791,12 +42809,12 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42791
42809
|
}
|
|
42792
42810
|
/**
|
|
42793
42811
|
* Confirm USDC escrow deposit for order payment
|
|
42794
|
-
*
|
|
42812
|
+
*
|
|
42795
42813
|
* Verifies the Hyperliquid transaction and updates order status.
|
|
42796
|
-
*
|
|
42814
|
+
*
|
|
42797
42815
|
* @param orderId - Order ID
|
|
42798
42816
|
* @returns Confirmation response with transaction hash
|
|
42799
|
-
*
|
|
42817
|
+
*
|
|
42800
42818
|
* @example
|
|
42801
42819
|
* ```typescript
|
|
42802
42820
|
* // After depositing USDC to escrow address
|
|
@@ -42805,14 +42823,16 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42805
42823
|
* ```
|
|
42806
42824
|
*/
|
|
42807
42825
|
async confirmEscrowDeposit(orderId) {
|
|
42808
|
-
return this.post(
|
|
42826
|
+
return this.post(
|
|
42827
|
+
`/api/marketplace/orders/${orderId}/confirm-escrow-deposit`
|
|
42828
|
+
);
|
|
42809
42829
|
}
|
|
42810
42830
|
/**
|
|
42811
42831
|
* Get order receipt
|
|
42812
|
-
*
|
|
42832
|
+
*
|
|
42813
42833
|
* @param orderId - Order ID
|
|
42814
42834
|
* @returns Order receipt for download/display
|
|
42815
|
-
*
|
|
42835
|
+
*
|
|
42816
42836
|
* @example
|
|
42817
42837
|
* ```typescript
|
|
42818
42838
|
* const receipt = await client.getOrderReceipt("ord_123");
|
|
@@ -42827,11 +42847,11 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42827
42847
|
// ============================================================================
|
|
42828
42848
|
/**
|
|
42829
42849
|
* List reviews for a product
|
|
42830
|
-
*
|
|
42850
|
+
*
|
|
42831
42851
|
* @param productId - Product ID
|
|
42832
42852
|
* @param params - Query parameters
|
|
42833
42853
|
* @returns Paginated list of reviews
|
|
42834
|
-
*
|
|
42854
|
+
*
|
|
42835
42855
|
* @example
|
|
42836
42856
|
* ```typescript
|
|
42837
42857
|
* const reviews = await client.listProductReviews("prod_123", {
|
|
@@ -42842,17 +42862,19 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42842
42862
|
*/
|
|
42843
42863
|
async listProductReviews(productId, params) {
|
|
42844
42864
|
const queryString = params ? buildQueryString(params) : "";
|
|
42845
|
-
return this.get(
|
|
42865
|
+
return this.get(
|
|
42866
|
+
`/api/marketplace/products/${productId}/reviews${queryString}`
|
|
42867
|
+
);
|
|
42846
42868
|
}
|
|
42847
42869
|
/**
|
|
42848
42870
|
* Create a product review
|
|
42849
|
-
*
|
|
42871
|
+
*
|
|
42850
42872
|
* Requires authenticated user who has purchased the product.
|
|
42851
|
-
*
|
|
42873
|
+
*
|
|
42852
42874
|
* @param productId - Product ID
|
|
42853
42875
|
* @param request - Review creation request
|
|
42854
42876
|
* @returns Created review
|
|
42855
|
-
*
|
|
42877
|
+
*
|
|
42856
42878
|
* @example
|
|
42857
42879
|
* ```typescript
|
|
42858
42880
|
* const review = await client.createReview("prod_123", {
|
|
@@ -42870,9 +42892,9 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42870
42892
|
// ============================================================================
|
|
42871
42893
|
/**
|
|
42872
42894
|
* List saved shipping addresses
|
|
42873
|
-
*
|
|
42895
|
+
*
|
|
42874
42896
|
* @returns List of user's saved shipping addresses
|
|
42875
|
-
*
|
|
42897
|
+
*
|
|
42876
42898
|
* @example
|
|
42877
42899
|
* ```typescript
|
|
42878
42900
|
* const addresses = await client.listShippingAddresses();
|
|
@@ -42884,10 +42906,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42884
42906
|
}
|
|
42885
42907
|
/**
|
|
42886
42908
|
* Create a new shipping address
|
|
42887
|
-
*
|
|
42909
|
+
*
|
|
42888
42910
|
* @param request - Shipping address data
|
|
42889
42911
|
* @returns Created address
|
|
42890
|
-
*
|
|
42912
|
+
*
|
|
42891
42913
|
* @example
|
|
42892
42914
|
* ```typescript
|
|
42893
42915
|
* const address = await client.createShippingAddress({
|
|
@@ -42908,11 +42930,11 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42908
42930
|
}
|
|
42909
42931
|
/**
|
|
42910
42932
|
* Update a shipping address
|
|
42911
|
-
*
|
|
42933
|
+
*
|
|
42912
42934
|
* @param addressId - Address ID
|
|
42913
42935
|
* @param request - Updated address data
|
|
42914
42936
|
* @returns Updated address
|
|
42915
|
-
*
|
|
42937
|
+
*
|
|
42916
42938
|
* @example
|
|
42917
42939
|
* ```typescript
|
|
42918
42940
|
* const address = await client.updateShippingAddress("addr_123", {
|
|
@@ -42925,10 +42947,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42925
42947
|
}
|
|
42926
42948
|
/**
|
|
42927
42949
|
* Delete a shipping address
|
|
42928
|
-
*
|
|
42950
|
+
*
|
|
42929
42951
|
* @param addressId - Address ID
|
|
42930
42952
|
* @returns Success response
|
|
42931
|
-
*
|
|
42953
|
+
*
|
|
42932
42954
|
* @example
|
|
42933
42955
|
* ```typescript
|
|
42934
42956
|
* await client.deleteShippingAddress("addr_123");
|
|
@@ -42942,10 +42964,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42942
42964
|
// ============================================================================
|
|
42943
42965
|
/**
|
|
42944
42966
|
* Calculate automatic discounts for cart items
|
|
42945
|
-
*
|
|
42967
|
+
*
|
|
42946
42968
|
* @param request - Cart items
|
|
42947
42969
|
* @returns Calculated discounts and totals
|
|
42948
|
-
*
|
|
42970
|
+
*
|
|
42949
42971
|
* @example
|
|
42950
42972
|
* ```typescript
|
|
42951
42973
|
* const result = await client.calculateCartDiscounts({
|
|
@@ -42964,10 +42986,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42964
42986
|
}
|
|
42965
42987
|
/**
|
|
42966
42988
|
* Validate a discount code for cart items
|
|
42967
|
-
*
|
|
42989
|
+
*
|
|
42968
42990
|
* @param request - Discount code and cart items
|
|
42969
42991
|
* @returns Validation result with discount details
|
|
42970
|
-
*
|
|
42992
|
+
*
|
|
42971
42993
|
* @example
|
|
42972
42994
|
* ```typescript
|
|
42973
42995
|
* const result = await client.validateDiscountCode({
|
|
@@ -42976,7 +42998,7 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42976
42998
|
* { productId: "prod_123", quantity: 2 }
|
|
42977
42999
|
* ]
|
|
42978
43000
|
* });
|
|
42979
|
-
*
|
|
43001
|
+
*
|
|
42980
43002
|
* if (result.valid) {
|
|
42981
43003
|
* console.log("Discount:", result.discount?.discountAmount);
|
|
42982
43004
|
* } else {
|
|
@@ -42992,10 +43014,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
42992
43014
|
// ============================================================================
|
|
42993
43015
|
/**
|
|
42994
43016
|
* Calculate tax for cart items based on shipping address
|
|
42995
|
-
*
|
|
43017
|
+
*
|
|
42996
43018
|
* @param request - Cart items and shipping address
|
|
42997
43019
|
* @returns Tax calculation with breakdown
|
|
42998
|
-
*
|
|
43020
|
+
*
|
|
42999
43021
|
* @example
|
|
43000
43022
|
* ```typescript
|
|
43001
43023
|
* const result = await client.calculateTax({
|
|
@@ -43020,10 +43042,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43020
43042
|
// ============================================================================
|
|
43021
43043
|
/**
|
|
43022
43044
|
* Calculate shipping options for cart items
|
|
43023
|
-
*
|
|
43045
|
+
*
|
|
43024
43046
|
* @param request - Cart items, merchant, and destination
|
|
43025
43047
|
* @returns Available shipping options with costs
|
|
43026
|
-
*
|
|
43048
|
+
*
|
|
43027
43049
|
* @example
|
|
43028
43050
|
* ```typescript
|
|
43029
43051
|
* const result = await client.calculateShippingOptions({
|
|
@@ -43034,7 +43056,7 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43034
43056
|
* destinationCountry: "US",
|
|
43035
43057
|
* orderSubtotal: 99.99
|
|
43036
43058
|
* });
|
|
43037
|
-
*
|
|
43059
|
+
*
|
|
43038
43060
|
* result.shippingOptions.forEach(opt => {
|
|
43039
43061
|
* console.log(opt.name, opt.cost, opt.estimatedDelivery);
|
|
43040
43062
|
* });
|
|
@@ -43048,10 +43070,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43048
43070
|
// ============================================================================
|
|
43049
43071
|
/**
|
|
43050
43072
|
* Get active promotional banners
|
|
43051
|
-
*
|
|
43073
|
+
*
|
|
43052
43074
|
* @param params - Query parameters
|
|
43053
43075
|
* @returns List of active banners
|
|
43054
|
-
*
|
|
43076
|
+
*
|
|
43055
43077
|
* @example
|
|
43056
43078
|
* ```typescript
|
|
43057
43079
|
* const banners = await client.getActiveBanners({
|
|
@@ -43066,16 +43088,16 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43066
43088
|
}
|
|
43067
43089
|
/**
|
|
43068
43090
|
* Track banner impression or click
|
|
43069
|
-
*
|
|
43091
|
+
*
|
|
43070
43092
|
* @param bannerId - Banner ID
|
|
43071
43093
|
* @param request - Track action (impression or click)
|
|
43072
43094
|
* @returns Success response
|
|
43073
|
-
*
|
|
43095
|
+
*
|
|
43074
43096
|
* @example
|
|
43075
43097
|
* ```typescript
|
|
43076
43098
|
* // Track impression
|
|
43077
43099
|
* await client.trackBanner("banner_123", { action: "impression" });
|
|
43078
|
-
*
|
|
43100
|
+
*
|
|
43079
43101
|
* // Track click
|
|
43080
43102
|
* await client.trackBanner("banner_123", { action: "click" });
|
|
43081
43103
|
* ```
|
|
@@ -43088,12 +43110,12 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43088
43110
|
// ============================================================================
|
|
43089
43111
|
/**
|
|
43090
43112
|
* List messages for customer
|
|
43091
|
-
*
|
|
43113
|
+
*
|
|
43092
43114
|
* Returns all conversations grouped by order, where each order represents
|
|
43093
43115
|
* a conversation with a merchant.
|
|
43094
|
-
*
|
|
43116
|
+
*
|
|
43095
43117
|
* @returns List of conversations with messages and stats
|
|
43096
|
-
*
|
|
43118
|
+
*
|
|
43097
43119
|
* @example
|
|
43098
43120
|
* ```typescript
|
|
43099
43121
|
* const result = await client.listMessages();
|
|
@@ -43108,11 +43130,11 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43108
43130
|
}
|
|
43109
43131
|
/**
|
|
43110
43132
|
* Get message stats (unread count)
|
|
43111
|
-
*
|
|
43133
|
+
*
|
|
43112
43134
|
* Lightweight endpoint for notification badges.
|
|
43113
|
-
*
|
|
43135
|
+
*
|
|
43114
43136
|
* @returns Unread message count
|
|
43115
|
-
*
|
|
43137
|
+
*
|
|
43116
43138
|
* @example
|
|
43117
43139
|
* ```typescript
|
|
43118
43140
|
* const stats = await client.getMessageStats();
|
|
@@ -43124,10 +43146,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43124
43146
|
}
|
|
43125
43147
|
/**
|
|
43126
43148
|
* Send a message to a merchant about an order
|
|
43127
|
-
*
|
|
43149
|
+
*
|
|
43128
43150
|
* @param request - Message data including orderId, recipientId (merchant user ID), and message
|
|
43129
43151
|
* @returns Sent message
|
|
43130
|
-
*
|
|
43152
|
+
*
|
|
43131
43153
|
* @example
|
|
43132
43154
|
* ```typescript
|
|
43133
43155
|
* await client.sendMessage({
|
|
@@ -43142,10 +43164,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43142
43164
|
}
|
|
43143
43165
|
/**
|
|
43144
43166
|
* Mark a message as read
|
|
43145
|
-
*
|
|
43167
|
+
*
|
|
43146
43168
|
* @param messageId - Message ID
|
|
43147
43169
|
* @returns Updated message
|
|
43148
|
-
*
|
|
43170
|
+
*
|
|
43149
43171
|
* @example
|
|
43150
43172
|
* ```typescript
|
|
43151
43173
|
* await client.markMessageAsRead("msg_123");
|
|
@@ -43159,24 +43181,24 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43159
43181
|
// ============================================================================
|
|
43160
43182
|
/**
|
|
43161
43183
|
* Get active flash sales
|
|
43162
|
-
*
|
|
43184
|
+
*
|
|
43163
43185
|
* Returns currently running flash sales with their discounted products.
|
|
43164
43186
|
* Includes countdown timer information for UI display.
|
|
43165
|
-
*
|
|
43187
|
+
*
|
|
43166
43188
|
* @param params - Query parameters
|
|
43167
43189
|
* @returns List of active flash sales with time remaining
|
|
43168
|
-
*
|
|
43190
|
+
*
|
|
43169
43191
|
* @example
|
|
43170
43192
|
* ```typescript
|
|
43171
43193
|
* const result = await client.getActiveFlashSales({ limit: 5 });
|
|
43172
|
-
*
|
|
43194
|
+
*
|
|
43173
43195
|
* result.flashSales.forEach(sale => {
|
|
43174
43196
|
* console.log(`${sale.name} - ends at ${sale.endsAt}`);
|
|
43175
43197
|
* sale.items.forEach(item => {
|
|
43176
43198
|
* console.log(` ${item.product.title}: $${item.salePrice} (${item.discountPercent}% off)`);
|
|
43177
43199
|
* });
|
|
43178
43200
|
* });
|
|
43179
|
-
*
|
|
43201
|
+
*
|
|
43180
43202
|
* // Use timeRemaining for countdown UI
|
|
43181
43203
|
* if (result.timeRemaining) {
|
|
43182
43204
|
* console.log(`Featured sale ends in ${result.timeRemaining.remainingSeconds} seconds`);
|
|
@@ -43189,19 +43211,19 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43189
43211
|
}
|
|
43190
43212
|
/**
|
|
43191
43213
|
* Get flash sale allowance
|
|
43192
|
-
*
|
|
43214
|
+
*
|
|
43193
43215
|
* Fetches user's remaining purchase allowance for flash sale items.
|
|
43194
43216
|
* Used to enforce per-customer purchase limits.
|
|
43195
|
-
*
|
|
43217
|
+
*
|
|
43196
43218
|
* @param params - Request params with product IDs
|
|
43197
43219
|
* @returns Allowance info for each product
|
|
43198
|
-
*
|
|
43220
|
+
*
|
|
43199
43221
|
* @example
|
|
43200
43222
|
* ```typescript
|
|
43201
43223
|
* const result = await client.getFlashSaleAllowance({
|
|
43202
43224
|
* productIds: ["prod_123", "prod_456"]
|
|
43203
43225
|
* });
|
|
43204
|
-
*
|
|
43226
|
+
*
|
|
43205
43227
|
* Object.entries(result.allowances).forEach(([productId, info]) => {
|
|
43206
43228
|
* if (info.limitPerCustomer !== null) {
|
|
43207
43229
|
* console.log(`Product ${productId}:`);
|
|
@@ -43213,7 +43235,9 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43213
43235
|
* ```
|
|
43214
43236
|
*/
|
|
43215
43237
|
async getFlashSaleAllowance(params) {
|
|
43216
|
-
const queryString = buildQueryString({
|
|
43238
|
+
const queryString = buildQueryString({
|
|
43239
|
+
productIds: params.productIds.join(",")
|
|
43240
|
+
});
|
|
43217
43241
|
return this.get(`/api/marketplace/flash-sales/allowance${queryString}`);
|
|
43218
43242
|
}
|
|
43219
43243
|
// ============================================================================
|
|
@@ -43221,12 +43245,12 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43221
43245
|
// ============================================================================
|
|
43222
43246
|
/**
|
|
43223
43247
|
* Get public merchant profile
|
|
43224
|
-
*
|
|
43248
|
+
*
|
|
43225
43249
|
* Fetches public information about a merchant for the storefront page.
|
|
43226
|
-
*
|
|
43250
|
+
*
|
|
43227
43251
|
* @param merchantId - Merchant ID
|
|
43228
43252
|
* @returns Public merchant profile with stats
|
|
43229
|
-
*
|
|
43253
|
+
*
|
|
43230
43254
|
* @example
|
|
43231
43255
|
* ```typescript
|
|
43232
43256
|
* const result = await client.getMerchantProfile("merchant_123");
|
|
@@ -43238,13 +43262,13 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43238
43262
|
}
|
|
43239
43263
|
/**
|
|
43240
43264
|
* List merchant products
|
|
43241
|
-
*
|
|
43265
|
+
*
|
|
43242
43266
|
* Fetches products for a specific merchant with search, filter, and sort options.
|
|
43243
|
-
*
|
|
43267
|
+
*
|
|
43244
43268
|
* @param merchantId - Merchant ID
|
|
43245
43269
|
* @param params - Query parameters for filtering and pagination
|
|
43246
43270
|
* @returns Paginated list of products
|
|
43247
|
-
*
|
|
43271
|
+
*
|
|
43248
43272
|
* @example
|
|
43249
43273
|
* ```typescript
|
|
43250
43274
|
* const result = await client.getMerchantProducts("merchant_123", {
|
|
@@ -43252,7 +43276,7 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43252
43276
|
* sortBy: "popular",
|
|
43253
43277
|
* limit: 20,
|
|
43254
43278
|
* });
|
|
43255
|
-
*
|
|
43279
|
+
*
|
|
43256
43280
|
* result.items.forEach(product => {
|
|
43257
43281
|
* console.log(product.title, product.priceUSDC);
|
|
43258
43282
|
* });
|
|
@@ -43260,17 +43284,19 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43260
43284
|
*/
|
|
43261
43285
|
async getMerchantProducts(merchantId, params) {
|
|
43262
43286
|
const queryString = params ? buildQueryString(params) : "";
|
|
43263
|
-
return this.get(
|
|
43287
|
+
return this.get(
|
|
43288
|
+
`/api/marketplace/merchants/${merchantId}/products${queryString}`
|
|
43289
|
+
);
|
|
43264
43290
|
}
|
|
43265
43291
|
// ============================================================================
|
|
43266
43292
|
// Shop Following API
|
|
43267
43293
|
// ============================================================================
|
|
43268
43294
|
/**
|
|
43269
43295
|
* Check if following a merchant
|
|
43270
|
-
*
|
|
43296
|
+
*
|
|
43271
43297
|
* @param merchantId - Merchant ID
|
|
43272
43298
|
* @returns Follow status with follow date if applicable
|
|
43273
|
-
*
|
|
43299
|
+
*
|
|
43274
43300
|
* @example
|
|
43275
43301
|
* ```typescript
|
|
43276
43302
|
* const status = await client.isFollowingMerchant("merchant_123");
|
|
@@ -43284,10 +43310,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43284
43310
|
}
|
|
43285
43311
|
/**
|
|
43286
43312
|
* Follow a merchant
|
|
43287
|
-
*
|
|
43313
|
+
*
|
|
43288
43314
|
* @param merchantId - Merchant ID to follow
|
|
43289
43315
|
* @returns Follow action result
|
|
43290
|
-
*
|
|
43316
|
+
*
|
|
43291
43317
|
* @example
|
|
43292
43318
|
* ```typescript
|
|
43293
43319
|
* const result = await client.followMerchant("merchant_123");
|
|
@@ -43299,10 +43325,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43299
43325
|
}
|
|
43300
43326
|
/**
|
|
43301
43327
|
* Unfollow a merchant
|
|
43302
|
-
*
|
|
43328
|
+
*
|
|
43303
43329
|
* @param merchantId - Merchant ID to unfollow
|
|
43304
43330
|
* @returns Unfollow action result
|
|
43305
|
-
*
|
|
43331
|
+
*
|
|
43306
43332
|
* @example
|
|
43307
43333
|
* ```typescript
|
|
43308
43334
|
* const result = await client.unfollowMerchant("merchant_123");
|
|
@@ -43314,10 +43340,10 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43314
43340
|
}
|
|
43315
43341
|
/**
|
|
43316
43342
|
* Get list of followed merchants
|
|
43317
|
-
*
|
|
43343
|
+
*
|
|
43318
43344
|
* @param params - Query parameters for pagination and sorting
|
|
43319
43345
|
* @returns Paginated list of followed merchants with their info
|
|
43320
|
-
*
|
|
43346
|
+
*
|
|
43321
43347
|
* @example
|
|
43322
43348
|
* ```typescript
|
|
43323
43349
|
* const result = await client.getFollowedMerchants({ limit: 20, sortBy: "recent" });
|
|
@@ -43335,11 +43361,11 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43335
43361
|
// ============================================================================
|
|
43336
43362
|
/**
|
|
43337
43363
|
* Get available payment methods
|
|
43338
|
-
*
|
|
43364
|
+
*
|
|
43339
43365
|
* Returns the list of enabled payment methods that can be used during checkout.
|
|
43340
|
-
*
|
|
43366
|
+
*
|
|
43341
43367
|
* @returns List of available payment methods with display info
|
|
43342
|
-
*
|
|
43368
|
+
*
|
|
43343
43369
|
* @example
|
|
43344
43370
|
* ```typescript
|
|
43345
43371
|
* const result = await client.getPaymentMethods();
|
|
@@ -43358,12 +43384,12 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43358
43384
|
// ============================================================================
|
|
43359
43385
|
/**
|
|
43360
43386
|
* Get user's gem balance
|
|
43361
|
-
*
|
|
43387
|
+
*
|
|
43362
43388
|
* Returns the current gem balance including total gems, available gems,
|
|
43363
43389
|
* and gems expiring soon. Gems are earned at 100 per $1 of revenue.
|
|
43364
|
-
*
|
|
43390
|
+
*
|
|
43365
43391
|
* @returns Current gem balance with USD equivalent
|
|
43366
|
-
*
|
|
43392
|
+
*
|
|
43367
43393
|
* @example
|
|
43368
43394
|
* ```typescript
|
|
43369
43395
|
* const balance = await client.getGemBalance();
|
|
@@ -43376,24 +43402,24 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43376
43402
|
}
|
|
43377
43403
|
/**
|
|
43378
43404
|
* Get gem transaction history
|
|
43379
|
-
*
|
|
43405
|
+
*
|
|
43380
43406
|
* Returns paginated history of gem transactions including earning,
|
|
43381
43407
|
* spending, and expiration events.
|
|
43382
|
-
*
|
|
43408
|
+
*
|
|
43383
43409
|
* @param params - Query parameters for filtering and pagination
|
|
43384
43410
|
* @returns Paginated gem history
|
|
43385
|
-
*
|
|
43411
|
+
*
|
|
43386
43412
|
* @example
|
|
43387
43413
|
* ```typescript
|
|
43388
43414
|
* // Get all history
|
|
43389
43415
|
* const history = await client.getGemHistory({ limit: 20, offset: 0 });
|
|
43390
|
-
*
|
|
43416
|
+
*
|
|
43391
43417
|
* // Get only earned gems
|
|
43392
43418
|
* const earned = await client.getGemHistory({ type: "earn", limit: 10 });
|
|
43393
|
-
*
|
|
43419
|
+
*
|
|
43394
43420
|
* // Get only spent gems
|
|
43395
43421
|
* const spent = await client.getGemHistory({ type: "spend", limit: 10 });
|
|
43396
|
-
*
|
|
43422
|
+
*
|
|
43397
43423
|
* history.items.forEach(item => {
|
|
43398
43424
|
* console.log(`${item.type}: ${item.amount} gems - ${item.createdAt}`);
|
|
43399
43425
|
* });
|
|
@@ -43405,21 +43431,21 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43405
43431
|
}
|
|
43406
43432
|
/**
|
|
43407
43433
|
* Get gems that are expiring soon
|
|
43408
|
-
*
|
|
43434
|
+
*
|
|
43409
43435
|
* Returns gem batches that will expire within the specified number of days.
|
|
43410
43436
|
* Useful for prompting users to spend gems before they expire.
|
|
43411
|
-
*
|
|
43437
|
+
*
|
|
43412
43438
|
* @param params - Query parameters (days: default 30, max 180)
|
|
43413
43439
|
* @returns Expiring gem batches with countdown info
|
|
43414
|
-
*
|
|
43440
|
+
*
|
|
43415
43441
|
* @example
|
|
43416
43442
|
* ```typescript
|
|
43417
43443
|
* // Get gems expiring in next 30 days (default)
|
|
43418
43444
|
* const expiring = await client.getExpiringGems();
|
|
43419
|
-
*
|
|
43445
|
+
*
|
|
43420
43446
|
* // Get gems expiring in next 7 days
|
|
43421
43447
|
* const urgent = await client.getExpiringGems({ days: 7 });
|
|
43422
|
-
*
|
|
43448
|
+
*
|
|
43423
43449
|
* if (expiring.totalExpiring > 0) {
|
|
43424
43450
|
* console.log(`${expiring.totalExpiring} gems expiring soon!`);
|
|
43425
43451
|
* expiring.batches.forEach(batch => {
|
|
@@ -43437,12 +43463,12 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43437
43463
|
// ============================================================================
|
|
43438
43464
|
/**
|
|
43439
43465
|
* Get user's browsing location
|
|
43440
|
-
*
|
|
43466
|
+
*
|
|
43441
43467
|
* Returns the user's saved delivery location for geo-based product filtering.
|
|
43442
43468
|
* This location is used to show products from merchants that ship to the area.
|
|
43443
|
-
*
|
|
43469
|
+
*
|
|
43444
43470
|
* @returns Current browsing location or null if not set
|
|
43445
|
-
*
|
|
43471
|
+
*
|
|
43446
43472
|
* @example
|
|
43447
43473
|
* ```typescript
|
|
43448
43474
|
* const result = await client.getBrowsingLocation();
|
|
@@ -43456,13 +43482,13 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43456
43482
|
}
|
|
43457
43483
|
/**
|
|
43458
43484
|
* Save user's browsing location
|
|
43459
|
-
*
|
|
43485
|
+
*
|
|
43460
43486
|
* Sets the user's delivery location for geo-based product filtering.
|
|
43461
43487
|
* Products will be filtered to show only items from merchants that ship to this location.
|
|
43462
|
-
*
|
|
43488
|
+
*
|
|
43463
43489
|
* @param request - Location data from Google Places or manual input
|
|
43464
43490
|
* @returns The saved location
|
|
43465
|
-
*
|
|
43491
|
+
*
|
|
43466
43492
|
* @example
|
|
43467
43493
|
* ```typescript
|
|
43468
43494
|
* const result = await client.saveBrowsingLocation({
|
|
@@ -43480,12 +43506,12 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43480
43506
|
}
|
|
43481
43507
|
/**
|
|
43482
43508
|
* Clear user's browsing location
|
|
43483
|
-
*
|
|
43509
|
+
*
|
|
43484
43510
|
* Removes the user's saved delivery location. Products will no longer
|
|
43485
43511
|
* be filtered by shipping destination.
|
|
43486
|
-
*
|
|
43512
|
+
*
|
|
43487
43513
|
* @returns Success response
|
|
43488
|
-
*
|
|
43514
|
+
*
|
|
43489
43515
|
* @example
|
|
43490
43516
|
* ```typescript
|
|
43491
43517
|
* await client.clearBrowsingLocation();
|
|
@@ -43495,6 +43521,41 @@ var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
|
43495
43521
|
async clearBrowsingLocation() {
|
|
43496
43522
|
return this.delete("/api/user/browsing-location");
|
|
43497
43523
|
}
|
|
43524
|
+
// ============================================================================
|
|
43525
|
+
// BasedPay Cash Account API
|
|
43526
|
+
// ============================================================================
|
|
43527
|
+
/**
|
|
43528
|
+
* Get user's cash account balance for BASEDPAY
|
|
43529
|
+
*
|
|
43530
|
+
* Returns the current balance in the user's BasedPay cash account.
|
|
43531
|
+
*
|
|
43532
|
+
* @returns Cash account balance with currency
|
|
43533
|
+
*
|
|
43534
|
+
* @example
|
|
43535
|
+
* ```typescript
|
|
43536
|
+
* const balance = await client.getCashAccountBalance();
|
|
43537
|
+
* console.log(`Balance: ${balance.balance} ${balance.currency}`);
|
|
43538
|
+
* ```
|
|
43539
|
+
*/
|
|
43540
|
+
async getCashAccountBalance() {
|
|
43541
|
+
return this.get("/api/basedpay/balance");
|
|
43542
|
+
}
|
|
43543
|
+
/**
|
|
43544
|
+
* Get user's delivery address for BASEDPAY
|
|
43545
|
+
*
|
|
43546
|
+
* Returns the user's delivery address for BASEDPAY.
|
|
43547
|
+
*
|
|
43548
|
+
* @returns Delivery address
|
|
43549
|
+
*
|
|
43550
|
+
* @example
|
|
43551
|
+
* ```typescript
|
|
43552
|
+
* const address = await client.getDeliveryAddress();
|
|
43553
|
+
* console.log(`Address: ${address.address}`);
|
|
43554
|
+
* ```
|
|
43555
|
+
*/
|
|
43556
|
+
async getDeliveryAddress() {
|
|
43557
|
+
return this.get("/api/basedpay/delivery-address");
|
|
43558
|
+
}
|
|
43498
43559
|
};
|
|
43499
43560
|
|
|
43500
43561
|
// lib/ecommerce/client/merchant.ts
|