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