@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Customer/End-User Ecommerce API Client
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* This module provides methods for customer-facing ecommerce operations including
|
|
5
5
|
* browsing products, placing orders, managing reviews, and more.
|
|
6
6
|
*/
|
|
@@ -29,7 +29,7 @@ import type {
|
|
|
29
29
|
GetGemHistoryParams,
|
|
30
30
|
GetExpiringGemsParams,
|
|
31
31
|
SaveBrowsingLocationRequest,
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
// Response types
|
|
34
34
|
ListProductsResponse,
|
|
35
35
|
GetProductResponse,
|
|
@@ -66,24 +66,26 @@ import type {
|
|
|
66
66
|
DeleteBrowsingLocationResponse,
|
|
67
67
|
GetGemHistoryResponse,
|
|
68
68
|
GetExpiringGemsResponse,
|
|
69
|
+
CashAccountBalanceResponse,
|
|
70
|
+
DeliveryAddressResponse,
|
|
69
71
|
} from "../types";
|
|
70
72
|
|
|
71
73
|
/**
|
|
72
74
|
* Customer API client for end-user ecommerce operations
|
|
73
|
-
*
|
|
75
|
+
*
|
|
74
76
|
* Provides methods for browsing products, placing orders, managing reviews,
|
|
75
77
|
* and other customer-facing operations.
|
|
76
|
-
*
|
|
78
|
+
*
|
|
77
79
|
* @example
|
|
78
80
|
* ```typescript
|
|
79
81
|
* const client = new CustomerEcommerceClient({
|
|
80
82
|
* baseURL: "https://api.example.com",
|
|
81
83
|
* authToken: "user-auth-token"
|
|
82
84
|
* });
|
|
83
|
-
*
|
|
85
|
+
*
|
|
84
86
|
* // Browse products
|
|
85
87
|
* const products = await client.listProducts({ limit: 20, category: "electronics" });
|
|
86
|
-
*
|
|
88
|
+
*
|
|
87
89
|
* // Place an order
|
|
88
90
|
* const order = await client.createOrder({
|
|
89
91
|
* items: [{ productId: "123", quantity: 1 }],
|
|
@@ -93,17 +95,16 @@ import type {
|
|
|
93
95
|
* ```
|
|
94
96
|
*/
|
|
95
97
|
export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
96
|
-
|
|
97
98
|
// ============================================================================
|
|
98
99
|
// Products API
|
|
99
100
|
// ============================================================================
|
|
100
|
-
|
|
101
|
+
|
|
101
102
|
/**
|
|
102
103
|
* List products with filtering and pagination
|
|
103
|
-
*
|
|
104
|
+
*
|
|
104
105
|
* @param params - Query parameters for filtering
|
|
105
106
|
* @returns Paginated list of products
|
|
106
|
-
*
|
|
107
|
+
*
|
|
107
108
|
* @example
|
|
108
109
|
* ```typescript
|
|
109
110
|
* const products = await client.listProducts({
|
|
@@ -117,17 +118,19 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
117
118
|
* });
|
|
118
119
|
* ```
|
|
119
120
|
*/
|
|
120
|
-
async listProducts(
|
|
121
|
+
async listProducts(
|
|
122
|
+
params?: ListProductsParams,
|
|
123
|
+
): Promise<ListProductsResponse> {
|
|
121
124
|
const queryString = params ? buildQueryString(params) : "";
|
|
122
125
|
return this.get(`/api/marketplace/products${queryString}`);
|
|
123
126
|
}
|
|
124
|
-
|
|
127
|
+
|
|
125
128
|
/**
|
|
126
129
|
* Get product details by ID
|
|
127
|
-
*
|
|
130
|
+
*
|
|
128
131
|
* @param productId - Product ID
|
|
129
132
|
* @returns Product details with merchant info, variants, and reviews
|
|
130
|
-
*
|
|
133
|
+
*
|
|
131
134
|
* @example
|
|
132
135
|
* ```typescript
|
|
133
136
|
* const product = await client.getProduct("prod_123");
|
|
@@ -137,13 +140,13 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
137
140
|
async getProduct(productId: string): Promise<GetProductResponse> {
|
|
138
141
|
return this.get(`/api/marketplace/products/${productId}`);
|
|
139
142
|
}
|
|
140
|
-
|
|
143
|
+
|
|
141
144
|
/**
|
|
142
145
|
* Track product view (increment view count)
|
|
143
|
-
*
|
|
146
|
+
*
|
|
144
147
|
* @param productId - Product ID
|
|
145
148
|
* @returns Success response
|
|
146
|
-
*
|
|
149
|
+
*
|
|
147
150
|
* @example
|
|
148
151
|
* ```typescript
|
|
149
152
|
* await client.trackProductView("prod_123");
|
|
@@ -152,37 +155,56 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
152
155
|
async trackProductView(productId: string): Promise<SuccessResponse> {
|
|
153
156
|
return this.post(`/api/marketplace/products/${productId}/view`);
|
|
154
157
|
}
|
|
155
|
-
|
|
158
|
+
|
|
156
159
|
/**
|
|
157
160
|
* Get active automatic discounts for a product
|
|
158
|
-
*
|
|
161
|
+
*
|
|
159
162
|
* @param productId - Product ID
|
|
160
163
|
* @returns List of applicable discounts
|
|
161
|
-
*
|
|
164
|
+
*
|
|
162
165
|
* @example
|
|
163
166
|
* ```typescript
|
|
164
167
|
* const discounts = await client.getProductDiscounts("prod_123");
|
|
165
168
|
* discounts.discounts.forEach(d => console.log(d.description));
|
|
166
169
|
* ```
|
|
167
170
|
*/
|
|
168
|
-
async getProductDiscounts(
|
|
171
|
+
async getProductDiscounts(
|
|
172
|
+
productId: string,
|
|
173
|
+
): Promise<ProductDiscountsResponse> {
|
|
169
174
|
return this.get(`/api/marketplace/products/${productId}/discounts`);
|
|
170
175
|
}
|
|
171
|
-
|
|
176
|
+
|
|
172
177
|
// ============================================================================
|
|
173
178
|
// Orders API
|
|
174
179
|
// ============================================================================
|
|
175
|
-
|
|
180
|
+
|
|
176
181
|
/**
|
|
177
182
|
* Create order from cart checkout
|
|
178
|
-
*
|
|
183
|
+
*
|
|
179
184
|
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
180
|
-
*
|
|
185
|
+
*
|
|
186
|
+
* **IMPORTANT: Shipping Cost Security**
|
|
187
|
+
* - Use `shippingRateId` to specify the selected shipping rate
|
|
188
|
+
* - The server calculates shipping cost from the rate ID (never trust frontend costs)
|
|
189
|
+
* - Get available rates from `calculateShippingOptions()` first
|
|
190
|
+
*
|
|
181
191
|
* @param request - Order creation request
|
|
182
192
|
* @returns Created order(s) with payment instructions
|
|
183
|
-
*
|
|
193
|
+
*
|
|
184
194
|
* @example
|
|
185
195
|
* ```typescript
|
|
196
|
+
* // Step 1: Calculate available shipping options
|
|
197
|
+
* const shippingOptions = await client.calculateShippingOptions({
|
|
198
|
+
* merchantId: "merchant_123",
|
|
199
|
+
* destinationCountry: "US",
|
|
200
|
+
* cartItems: [{ productId: "prod_123", quantity: 2, priceUSDC: 29.99 }],
|
|
201
|
+
* orderSubtotal: 59.98
|
|
202
|
+
* });
|
|
203
|
+
*
|
|
204
|
+
* // Step 2: Let user select a shipping option, get the rateId
|
|
205
|
+
* const selectedRateId = shippingOptions.shippingOptions[0].rateId;
|
|
206
|
+
*
|
|
207
|
+
* // Step 3: Create order with shippingRateId (server validates and calculates cost)
|
|
186
208
|
* const result = await client.createOrder({
|
|
187
209
|
* items: [
|
|
188
210
|
* { productId: "prod_123", quantity: 2 },
|
|
@@ -198,9 +220,10 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
198
220
|
* postalCode: "10001",
|
|
199
221
|
* country: "US"
|
|
200
222
|
* },
|
|
223
|
+
* shippingRateId: selectedRateId, // Server validates and calculates cost
|
|
201
224
|
* couponCode: "SAVE10"
|
|
202
225
|
* });
|
|
203
|
-
*
|
|
226
|
+
*
|
|
204
227
|
* // For USDC escrow, deposit to the escrow address
|
|
205
228
|
* if (result.escrow) {
|
|
206
229
|
* console.log("Deposit", result.escrow.amountUSDC, "USDC to", result.escrow.address);
|
|
@@ -210,13 +233,13 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
210
233
|
async createOrder(request: CreateOrderRequest): Promise<CreateOrderResponse> {
|
|
211
234
|
return this.post("/api/marketplace/orders", request);
|
|
212
235
|
}
|
|
213
|
-
|
|
236
|
+
|
|
214
237
|
/**
|
|
215
238
|
* List user's orders
|
|
216
|
-
*
|
|
239
|
+
*
|
|
217
240
|
* @param params - Query parameters for filtering
|
|
218
241
|
* @returns Paginated list of orders
|
|
219
|
-
*
|
|
242
|
+
*
|
|
220
243
|
* @example
|
|
221
244
|
* ```typescript
|
|
222
245
|
* const orders = await client.listOrders({
|
|
@@ -230,13 +253,13 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
230
253
|
const queryString = params ? buildQueryString(params) : "";
|
|
231
254
|
return this.get(`/api/marketplace/orders${queryString}`);
|
|
232
255
|
}
|
|
233
|
-
|
|
256
|
+
|
|
234
257
|
/**
|
|
235
258
|
* Get order details by ID
|
|
236
|
-
*
|
|
259
|
+
*
|
|
237
260
|
* @param orderId - Order ID
|
|
238
261
|
* @returns Order details with items, payment, and shipment info
|
|
239
|
-
*
|
|
262
|
+
*
|
|
240
263
|
* @example
|
|
241
264
|
* ```typescript
|
|
242
265
|
* const order = await client.getOrder("ord_123");
|
|
@@ -246,15 +269,15 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
246
269
|
async getOrder(orderId: string): Promise<GetOrderResponse> {
|
|
247
270
|
return this.get(`/api/marketplace/orders/${orderId}`);
|
|
248
271
|
}
|
|
249
|
-
|
|
272
|
+
|
|
250
273
|
/**
|
|
251
274
|
* Confirm USDC escrow deposit for order payment
|
|
252
|
-
*
|
|
275
|
+
*
|
|
253
276
|
* Verifies the Hyperliquid transaction and updates order status.
|
|
254
|
-
*
|
|
277
|
+
*
|
|
255
278
|
* @param orderId - Order ID
|
|
256
279
|
* @returns Confirmation response with transaction hash
|
|
257
|
-
*
|
|
280
|
+
*
|
|
258
281
|
* @example
|
|
259
282
|
* ```typescript
|
|
260
283
|
* // After depositing USDC to escrow address
|
|
@@ -262,16 +285,20 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
262
285
|
* console.log("Payment confirmed:", result.depositTxHash);
|
|
263
286
|
* ```
|
|
264
287
|
*/
|
|
265
|
-
async confirmEscrowDeposit(
|
|
266
|
-
|
|
288
|
+
async confirmEscrowDeposit(
|
|
289
|
+
orderId: string,
|
|
290
|
+
): Promise<ConfirmEscrowDepositResponse> {
|
|
291
|
+
return this.post(
|
|
292
|
+
`/api/marketplace/orders/${orderId}/confirm-escrow-deposit`,
|
|
293
|
+
);
|
|
267
294
|
}
|
|
268
|
-
|
|
295
|
+
|
|
269
296
|
/**
|
|
270
297
|
* Get order receipt
|
|
271
|
-
*
|
|
298
|
+
*
|
|
272
299
|
* @param orderId - Order ID
|
|
273
300
|
* @returns Order receipt for download/display
|
|
274
|
-
*
|
|
301
|
+
*
|
|
275
302
|
* @example
|
|
276
303
|
* ```typescript
|
|
277
304
|
* const receipt = await client.getOrderReceipt("ord_123");
|
|
@@ -281,18 +308,18 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
281
308
|
async getOrderReceipt(orderId: string): Promise<OrderReceiptResponse> {
|
|
282
309
|
return this.get(`/api/marketplace/orders/${orderId}/receipt`);
|
|
283
310
|
}
|
|
284
|
-
|
|
311
|
+
|
|
285
312
|
// ============================================================================
|
|
286
313
|
// Reviews API
|
|
287
314
|
// ============================================================================
|
|
288
|
-
|
|
315
|
+
|
|
289
316
|
/**
|
|
290
317
|
* List reviews for a product
|
|
291
|
-
*
|
|
318
|
+
*
|
|
292
319
|
* @param productId - Product ID
|
|
293
320
|
* @param params - Query parameters
|
|
294
321
|
* @returns Paginated list of reviews
|
|
295
|
-
*
|
|
322
|
+
*
|
|
296
323
|
* @example
|
|
297
324
|
* ```typescript
|
|
298
325
|
* const reviews = await client.listProductReviews("prod_123", {
|
|
@@ -303,21 +330,23 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
303
330
|
*/
|
|
304
331
|
async listProductReviews(
|
|
305
332
|
productId: string,
|
|
306
|
-
params?: ListReviewsParams
|
|
333
|
+
params?: ListReviewsParams,
|
|
307
334
|
): Promise<ListReviewsResponse> {
|
|
308
335
|
const queryString = params ? buildQueryString(params) : "";
|
|
309
|
-
return this.get(
|
|
336
|
+
return this.get(
|
|
337
|
+
`/api/marketplace/products/${productId}/reviews${queryString}`,
|
|
338
|
+
);
|
|
310
339
|
}
|
|
311
|
-
|
|
340
|
+
|
|
312
341
|
/**
|
|
313
342
|
* Create a product review
|
|
314
|
-
*
|
|
343
|
+
*
|
|
315
344
|
* Requires authenticated user who has purchased the product.
|
|
316
|
-
*
|
|
345
|
+
*
|
|
317
346
|
* @param productId - Product ID
|
|
318
347
|
* @param request - Review creation request
|
|
319
348
|
* @returns Created review
|
|
320
|
-
*
|
|
349
|
+
*
|
|
321
350
|
* @example
|
|
322
351
|
* ```typescript
|
|
323
352
|
* const review = await client.createReview("prod_123", {
|
|
@@ -329,20 +358,20 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
329
358
|
*/
|
|
330
359
|
async createReview(
|
|
331
360
|
productId: string,
|
|
332
|
-
request: CreateReviewRequest
|
|
361
|
+
request: CreateReviewRequest,
|
|
333
362
|
): Promise<ReviewResponse> {
|
|
334
363
|
return this.post(`/api/marketplace/products/${productId}/reviews`, request);
|
|
335
364
|
}
|
|
336
|
-
|
|
365
|
+
|
|
337
366
|
// ============================================================================
|
|
338
367
|
// Shipping Addresses API
|
|
339
368
|
// ============================================================================
|
|
340
|
-
|
|
369
|
+
|
|
341
370
|
/**
|
|
342
371
|
* List saved shipping addresses
|
|
343
|
-
*
|
|
372
|
+
*
|
|
344
373
|
* @returns List of user's saved shipping addresses
|
|
345
|
-
*
|
|
374
|
+
*
|
|
346
375
|
* @example
|
|
347
376
|
* ```typescript
|
|
348
377
|
* const addresses = await client.listShippingAddresses();
|
|
@@ -352,13 +381,13 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
352
381
|
async listShippingAddresses(): Promise<ListShippingAddressesResponse> {
|
|
353
382
|
return this.get("/api/user/shipping-addresses");
|
|
354
383
|
}
|
|
355
|
-
|
|
384
|
+
|
|
356
385
|
/**
|
|
357
386
|
* Create a new shipping address
|
|
358
|
-
*
|
|
387
|
+
*
|
|
359
388
|
* @param request - Shipping address data
|
|
360
389
|
* @returns Created address
|
|
361
|
-
*
|
|
390
|
+
*
|
|
362
391
|
* @example
|
|
363
392
|
* ```typescript
|
|
364
393
|
* const address = await client.createShippingAddress({
|
|
@@ -375,18 +404,18 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
375
404
|
* ```
|
|
376
405
|
*/
|
|
377
406
|
async createShippingAddress(
|
|
378
|
-
request: ShippingAddressRequest
|
|
407
|
+
request: ShippingAddressRequest,
|
|
379
408
|
): Promise<ShippingAddressResponse> {
|
|
380
409
|
return this.post("/api/user/shipping-addresses", request);
|
|
381
410
|
}
|
|
382
|
-
|
|
411
|
+
|
|
383
412
|
/**
|
|
384
413
|
* Update a shipping address
|
|
385
|
-
*
|
|
414
|
+
*
|
|
386
415
|
* @param addressId - Address ID
|
|
387
416
|
* @param request - Updated address data
|
|
388
417
|
* @returns Updated address
|
|
389
|
-
*
|
|
418
|
+
*
|
|
390
419
|
* @example
|
|
391
420
|
* ```typescript
|
|
392
421
|
* const address = await client.updateShippingAddress("addr_123", {
|
|
@@ -396,17 +425,17 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
396
425
|
*/
|
|
397
426
|
async updateShippingAddress(
|
|
398
427
|
addressId: string,
|
|
399
|
-
request: Partial<ShippingAddressRequest
|
|
428
|
+
request: Partial<ShippingAddressRequest>,
|
|
400
429
|
): Promise<ShippingAddressResponse> {
|
|
401
430
|
return this.patch(`/api/user/shipping-addresses/${addressId}`, request);
|
|
402
431
|
}
|
|
403
|
-
|
|
432
|
+
|
|
404
433
|
/**
|
|
405
434
|
* Delete a shipping address
|
|
406
|
-
*
|
|
435
|
+
*
|
|
407
436
|
* @param addressId - Address ID
|
|
408
437
|
* @returns Success response
|
|
409
|
-
*
|
|
438
|
+
*
|
|
410
439
|
* @example
|
|
411
440
|
* ```typescript
|
|
412
441
|
* await client.deleteShippingAddress("addr_123");
|
|
@@ -415,17 +444,17 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
415
444
|
async deleteShippingAddress(addressId: string): Promise<SuccessResponse> {
|
|
416
445
|
return this.delete(`/api/user/shipping-addresses/${addressId}`);
|
|
417
446
|
}
|
|
418
|
-
|
|
447
|
+
|
|
419
448
|
// ============================================================================
|
|
420
449
|
// Cart & Discounts API
|
|
421
450
|
// ============================================================================
|
|
422
|
-
|
|
451
|
+
|
|
423
452
|
/**
|
|
424
453
|
* Calculate automatic discounts for cart items
|
|
425
|
-
*
|
|
454
|
+
*
|
|
426
455
|
* @param request - Cart items
|
|
427
456
|
* @returns Calculated discounts and totals
|
|
428
|
-
*
|
|
457
|
+
*
|
|
429
458
|
* @example
|
|
430
459
|
* ```typescript
|
|
431
460
|
* const result = await client.calculateCartDiscounts({
|
|
@@ -440,17 +469,17 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
440
469
|
* ```
|
|
441
470
|
*/
|
|
442
471
|
async calculateCartDiscounts(
|
|
443
|
-
request: CalculateCartDiscountsRequest
|
|
472
|
+
request: CalculateCartDiscountsRequest,
|
|
444
473
|
): Promise<CalculateCartDiscountsResponse> {
|
|
445
474
|
return this.post("/api/marketplace/cart/discounts", request);
|
|
446
475
|
}
|
|
447
|
-
|
|
476
|
+
|
|
448
477
|
/**
|
|
449
478
|
* Validate a discount code for cart items
|
|
450
|
-
*
|
|
479
|
+
*
|
|
451
480
|
* @param request - Discount code and cart items
|
|
452
481
|
* @returns Validation result with discount details
|
|
453
|
-
*
|
|
482
|
+
*
|
|
454
483
|
* @example
|
|
455
484
|
* ```typescript
|
|
456
485
|
* const result = await client.validateDiscountCode({
|
|
@@ -459,7 +488,7 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
459
488
|
* { productId: "prod_123", quantity: 2 }
|
|
460
489
|
* ]
|
|
461
490
|
* });
|
|
462
|
-
*
|
|
491
|
+
*
|
|
463
492
|
* if (result.valid) {
|
|
464
493
|
* console.log("Discount:", result.discount?.discountAmount);
|
|
465
494
|
* } else {
|
|
@@ -468,21 +497,21 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
468
497
|
* ```
|
|
469
498
|
*/
|
|
470
499
|
async validateDiscountCode(
|
|
471
|
-
request: ValidateDiscountRequest
|
|
500
|
+
request: ValidateDiscountRequest,
|
|
472
501
|
): Promise<ValidateDiscountResponse> {
|
|
473
502
|
return this.post("/api/marketplace/discounts/validate", request);
|
|
474
503
|
}
|
|
475
|
-
|
|
504
|
+
|
|
476
505
|
// ============================================================================
|
|
477
506
|
// Tax Calculation API
|
|
478
507
|
// ============================================================================
|
|
479
|
-
|
|
508
|
+
|
|
480
509
|
/**
|
|
481
510
|
* Calculate tax for cart items based on shipping address
|
|
482
|
-
*
|
|
511
|
+
*
|
|
483
512
|
* @param request - Cart items and shipping address
|
|
484
513
|
* @returns Tax calculation with breakdown
|
|
485
|
-
*
|
|
514
|
+
*
|
|
486
515
|
* @example
|
|
487
516
|
* ```typescript
|
|
488
517
|
* const result = await client.calculateTax({
|
|
@@ -499,7 +528,9 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
499
528
|
* console.log("Total:", result.total);
|
|
500
529
|
* ```
|
|
501
530
|
*/
|
|
502
|
-
async calculateTax(
|
|
531
|
+
async calculateTax(
|
|
532
|
+
request: CalculateTaxRequest,
|
|
533
|
+
): Promise<CalculateTaxResponse> {
|
|
503
534
|
return this.post("/api/marketplace/tax/calculate", request);
|
|
504
535
|
}
|
|
505
536
|
|
|
@@ -509,10 +540,10 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
509
540
|
|
|
510
541
|
/**
|
|
511
542
|
* Calculate shipping options for cart items
|
|
512
|
-
*
|
|
543
|
+
*
|
|
513
544
|
* @param request - Cart items, merchant, and destination
|
|
514
545
|
* @returns Available shipping options with costs
|
|
515
|
-
*
|
|
546
|
+
*
|
|
516
547
|
* @example
|
|
517
548
|
* ```typescript
|
|
518
549
|
* const result = await client.calculateShippingOptions({
|
|
@@ -523,26 +554,28 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
523
554
|
* destinationCountry: "US",
|
|
524
555
|
* orderSubtotal: 99.99
|
|
525
556
|
* });
|
|
526
|
-
*
|
|
557
|
+
*
|
|
527
558
|
* result.shippingOptions.forEach(opt => {
|
|
528
559
|
* console.log(opt.name, opt.cost, opt.estimatedDelivery);
|
|
529
560
|
* });
|
|
530
561
|
* ```
|
|
531
562
|
*/
|
|
532
|
-
async calculateShippingOptions(
|
|
563
|
+
async calculateShippingOptions(
|
|
564
|
+
request: CalculateShippingRequest,
|
|
565
|
+
): Promise<CalculateShippingResponse> {
|
|
533
566
|
return this.post("/api/marketplace/shipping/calculate", request);
|
|
534
567
|
}
|
|
535
|
-
|
|
568
|
+
|
|
536
569
|
// ============================================================================
|
|
537
570
|
// Banners API
|
|
538
571
|
// ============================================================================
|
|
539
|
-
|
|
572
|
+
|
|
540
573
|
/**
|
|
541
574
|
* Get active promotional banners
|
|
542
|
-
*
|
|
575
|
+
*
|
|
543
576
|
* @param params - Query parameters
|
|
544
577
|
* @returns List of active banners
|
|
545
|
-
*
|
|
578
|
+
*
|
|
546
579
|
* @example
|
|
547
580
|
* ```typescript
|
|
548
581
|
* const banners = await client.getActiveBanners({
|
|
@@ -551,43 +584,48 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
551
584
|
* });
|
|
552
585
|
* ```
|
|
553
586
|
*/
|
|
554
|
-
async getActiveBanners(
|
|
587
|
+
async getActiveBanners(
|
|
588
|
+
params?: ListActiveBannersParams,
|
|
589
|
+
): Promise<ListBannersResponse> {
|
|
555
590
|
const queryString = params ? buildQueryString(params) : "";
|
|
556
591
|
return this.get(`/api/marketplace/banners/active${queryString}`);
|
|
557
592
|
}
|
|
558
|
-
|
|
593
|
+
|
|
559
594
|
/**
|
|
560
595
|
* Track banner impression or click
|
|
561
|
-
*
|
|
596
|
+
*
|
|
562
597
|
* @param bannerId - Banner ID
|
|
563
598
|
* @param request - Track action (impression or click)
|
|
564
599
|
* @returns Success response
|
|
565
|
-
*
|
|
600
|
+
*
|
|
566
601
|
* @example
|
|
567
602
|
* ```typescript
|
|
568
603
|
* // Track impression
|
|
569
604
|
* await client.trackBanner("banner_123", { action: "impression" });
|
|
570
|
-
*
|
|
605
|
+
*
|
|
571
606
|
* // Track click
|
|
572
607
|
* await client.trackBanner("banner_123", { action: "click" });
|
|
573
608
|
* ```
|
|
574
609
|
*/
|
|
575
|
-
async trackBanner(
|
|
610
|
+
async trackBanner(
|
|
611
|
+
bannerId: string,
|
|
612
|
+
request: TrackBannerRequest,
|
|
613
|
+
): Promise<SuccessResponse> {
|
|
576
614
|
return this.post(`/api/marketplace/banners/${bannerId}/track`, request);
|
|
577
615
|
}
|
|
578
|
-
|
|
616
|
+
|
|
579
617
|
// ============================================================================
|
|
580
618
|
// Messages API
|
|
581
619
|
// ============================================================================
|
|
582
|
-
|
|
620
|
+
|
|
583
621
|
/**
|
|
584
622
|
* List messages for customer
|
|
585
|
-
*
|
|
623
|
+
*
|
|
586
624
|
* Returns all conversations grouped by order, where each order represents
|
|
587
625
|
* a conversation with a merchant.
|
|
588
|
-
*
|
|
626
|
+
*
|
|
589
627
|
* @returns List of conversations with messages and stats
|
|
590
|
-
*
|
|
628
|
+
*
|
|
591
629
|
* @example
|
|
592
630
|
* ```typescript
|
|
593
631
|
* const result = await client.listMessages();
|
|
@@ -600,14 +638,14 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
600
638
|
async listMessages(): Promise<CustomerMessagesResponse> {
|
|
601
639
|
return this.get("/api/marketplace/messages");
|
|
602
640
|
}
|
|
603
|
-
|
|
641
|
+
|
|
604
642
|
/**
|
|
605
643
|
* Get message stats (unread count)
|
|
606
|
-
*
|
|
644
|
+
*
|
|
607
645
|
* Lightweight endpoint for notification badges.
|
|
608
|
-
*
|
|
646
|
+
*
|
|
609
647
|
* @returns Unread message count
|
|
610
|
-
*
|
|
648
|
+
*
|
|
611
649
|
* @example
|
|
612
650
|
* ```typescript
|
|
613
651
|
* const stats = await client.getMessageStats();
|
|
@@ -617,13 +655,13 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
617
655
|
async getMessageStats(): Promise<MessageStatsResponse> {
|
|
618
656
|
return this.get("/api/marketplace/messages/stats");
|
|
619
657
|
}
|
|
620
|
-
|
|
658
|
+
|
|
621
659
|
/**
|
|
622
660
|
* Send a message to a merchant about an order
|
|
623
|
-
*
|
|
661
|
+
*
|
|
624
662
|
* @param request - Message data including orderId, recipientId (merchant user ID), and message
|
|
625
663
|
* @returns Sent message
|
|
626
|
-
*
|
|
664
|
+
*
|
|
627
665
|
* @example
|
|
628
666
|
* ```typescript
|
|
629
667
|
* await client.sendMessage({
|
|
@@ -636,13 +674,13 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
636
674
|
async sendMessage(request: SendMessageRequest): Promise<MessageResponse> {
|
|
637
675
|
return this.post("/api/marketplace/messages/send", request);
|
|
638
676
|
}
|
|
639
|
-
|
|
677
|
+
|
|
640
678
|
/**
|
|
641
679
|
* Mark a message as read
|
|
642
|
-
*
|
|
680
|
+
*
|
|
643
681
|
* @param messageId - Message ID
|
|
644
682
|
* @returns Updated message
|
|
645
|
-
*
|
|
683
|
+
*
|
|
646
684
|
* @example
|
|
647
685
|
* ```typescript
|
|
648
686
|
* await client.markMessageAsRead("msg_123");
|
|
@@ -651,57 +689,59 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
651
689
|
async markMessageAsRead(messageId: string): Promise<MessageResponse> {
|
|
652
690
|
return this.patch(`/api/marketplace/messages/${messageId}/read`, {});
|
|
653
691
|
}
|
|
654
|
-
|
|
692
|
+
|
|
655
693
|
// ============================================================================
|
|
656
694
|
// Flash Sales API
|
|
657
695
|
// ============================================================================
|
|
658
|
-
|
|
696
|
+
|
|
659
697
|
/**
|
|
660
698
|
* Get active flash sales
|
|
661
|
-
*
|
|
699
|
+
*
|
|
662
700
|
* Returns currently running flash sales with their discounted products.
|
|
663
701
|
* Includes countdown timer information for UI display.
|
|
664
|
-
*
|
|
702
|
+
*
|
|
665
703
|
* @param params - Query parameters
|
|
666
704
|
* @returns List of active flash sales with time remaining
|
|
667
|
-
*
|
|
705
|
+
*
|
|
668
706
|
* @example
|
|
669
707
|
* ```typescript
|
|
670
708
|
* const result = await client.getActiveFlashSales({ limit: 5 });
|
|
671
|
-
*
|
|
709
|
+
*
|
|
672
710
|
* result.flashSales.forEach(sale => {
|
|
673
711
|
* console.log(`${sale.name} - ends at ${sale.endsAt}`);
|
|
674
712
|
* sale.items.forEach(item => {
|
|
675
713
|
* console.log(` ${item.product.title}: $${item.salePrice} (${item.discountPercent}% off)`);
|
|
676
714
|
* });
|
|
677
715
|
* });
|
|
678
|
-
*
|
|
716
|
+
*
|
|
679
717
|
* // Use timeRemaining for countdown UI
|
|
680
718
|
* if (result.timeRemaining) {
|
|
681
719
|
* console.log(`Featured sale ends in ${result.timeRemaining.remainingSeconds} seconds`);
|
|
682
720
|
* }
|
|
683
721
|
* ```
|
|
684
722
|
*/
|
|
685
|
-
async getActiveFlashSales(
|
|
723
|
+
async getActiveFlashSales(
|
|
724
|
+
params?: ListActiveFlashSalesParams,
|
|
725
|
+
): Promise<ActiveFlashSalesResponse> {
|
|
686
726
|
const queryString = params ? buildQueryString(params) : "";
|
|
687
727
|
return this.get(`/api/marketplace/flash-sales/active${queryString}`);
|
|
688
728
|
}
|
|
689
729
|
|
|
690
730
|
/**
|
|
691
731
|
* Get flash sale allowance
|
|
692
|
-
*
|
|
732
|
+
*
|
|
693
733
|
* Fetches user's remaining purchase allowance for flash sale items.
|
|
694
734
|
* Used to enforce per-customer purchase limits.
|
|
695
|
-
*
|
|
735
|
+
*
|
|
696
736
|
* @param params - Request params with product IDs
|
|
697
737
|
* @returns Allowance info for each product
|
|
698
|
-
*
|
|
738
|
+
*
|
|
699
739
|
* @example
|
|
700
740
|
* ```typescript
|
|
701
741
|
* const result = await client.getFlashSaleAllowance({
|
|
702
742
|
* productIds: ["prod_123", "prod_456"]
|
|
703
743
|
* });
|
|
704
|
-
*
|
|
744
|
+
*
|
|
705
745
|
* Object.entries(result.allowances).forEach(([productId, info]) => {
|
|
706
746
|
* if (info.limitPerCustomer !== null) {
|
|
707
747
|
* console.log(`Product ${productId}:`);
|
|
@@ -712,42 +752,48 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
712
752
|
* });
|
|
713
753
|
* ```
|
|
714
754
|
*/
|
|
715
|
-
async getFlashSaleAllowance(
|
|
716
|
-
|
|
755
|
+
async getFlashSaleAllowance(
|
|
756
|
+
params: GetFlashSaleAllowanceParams,
|
|
757
|
+
): Promise<GetFlashSaleAllowanceResponse> {
|
|
758
|
+
const queryString = buildQueryString({
|
|
759
|
+
productIds: params.productIds.join(","),
|
|
760
|
+
});
|
|
717
761
|
return this.get(`/api/marketplace/flash-sales/allowance${queryString}`);
|
|
718
762
|
}
|
|
719
|
-
|
|
763
|
+
|
|
720
764
|
// ============================================================================
|
|
721
765
|
// Merchant Storefront API
|
|
722
766
|
// ============================================================================
|
|
723
|
-
|
|
767
|
+
|
|
724
768
|
/**
|
|
725
769
|
* Get public merchant profile
|
|
726
|
-
*
|
|
770
|
+
*
|
|
727
771
|
* Fetches public information about a merchant for the storefront page.
|
|
728
|
-
*
|
|
772
|
+
*
|
|
729
773
|
* @param merchantId - Merchant ID
|
|
730
774
|
* @returns Public merchant profile with stats
|
|
731
|
-
*
|
|
775
|
+
*
|
|
732
776
|
* @example
|
|
733
777
|
* ```typescript
|
|
734
778
|
* const result = await client.getMerchantProfile("merchant_123");
|
|
735
779
|
* console.log(result.merchant.name, result.merchant.productCount);
|
|
736
780
|
* ```
|
|
737
781
|
*/
|
|
738
|
-
async getMerchantProfile(
|
|
782
|
+
async getMerchantProfile(
|
|
783
|
+
merchantId: string,
|
|
784
|
+
): Promise<PublicMerchantProfileResponse> {
|
|
739
785
|
return this.get(`/api/marketplace/merchants/${merchantId}`);
|
|
740
786
|
}
|
|
741
|
-
|
|
787
|
+
|
|
742
788
|
/**
|
|
743
789
|
* List merchant products
|
|
744
|
-
*
|
|
790
|
+
*
|
|
745
791
|
* Fetches products for a specific merchant with search, filter, and sort options.
|
|
746
|
-
*
|
|
792
|
+
*
|
|
747
793
|
* @param merchantId - Merchant ID
|
|
748
794
|
* @param params - Query parameters for filtering and pagination
|
|
749
795
|
* @returns Paginated list of products
|
|
750
|
-
*
|
|
796
|
+
*
|
|
751
797
|
* @example
|
|
752
798
|
* ```typescript
|
|
753
799
|
* const result = await client.getMerchantProducts("merchant_123", {
|
|
@@ -755,7 +801,7 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
755
801
|
* sortBy: "popular",
|
|
756
802
|
* limit: 20,
|
|
757
803
|
* });
|
|
758
|
-
*
|
|
804
|
+
*
|
|
759
805
|
* result.items.forEach(product => {
|
|
760
806
|
* console.log(product.title, product.priceUSDC);
|
|
761
807
|
* });
|
|
@@ -763,22 +809,24 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
763
809
|
*/
|
|
764
810
|
async getMerchantProducts(
|
|
765
811
|
merchantId: string,
|
|
766
|
-
params?: ListMerchantProductsParams
|
|
812
|
+
params?: ListMerchantProductsParams,
|
|
767
813
|
): Promise<MerchantProductsResponse> {
|
|
768
814
|
const queryString = params ? buildQueryString(params) : "";
|
|
769
|
-
return this.get(
|
|
815
|
+
return this.get(
|
|
816
|
+
`/api/marketplace/merchants/${merchantId}/products${queryString}`,
|
|
817
|
+
);
|
|
770
818
|
}
|
|
771
|
-
|
|
819
|
+
|
|
772
820
|
// ============================================================================
|
|
773
821
|
// Shop Following API
|
|
774
822
|
// ============================================================================
|
|
775
|
-
|
|
823
|
+
|
|
776
824
|
/**
|
|
777
825
|
* Check if following a merchant
|
|
778
|
-
*
|
|
826
|
+
*
|
|
779
827
|
* @param merchantId - Merchant ID
|
|
780
828
|
* @returns Follow status with follow date if applicable
|
|
781
|
-
*
|
|
829
|
+
*
|
|
782
830
|
* @example
|
|
783
831
|
* ```typescript
|
|
784
832
|
* const status = await client.isFollowingMerchant("merchant_123");
|
|
@@ -790,13 +838,13 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
790
838
|
async isFollowingMerchant(merchantId: string): Promise<FollowStatusResponse> {
|
|
791
839
|
return this.get(`/api/marketplace/merchants/${merchantId}/follow`);
|
|
792
840
|
}
|
|
793
|
-
|
|
841
|
+
|
|
794
842
|
/**
|
|
795
843
|
* Follow a merchant
|
|
796
|
-
*
|
|
844
|
+
*
|
|
797
845
|
* @param merchantId - Merchant ID to follow
|
|
798
846
|
* @returns Follow action result
|
|
799
|
-
*
|
|
847
|
+
*
|
|
800
848
|
* @example
|
|
801
849
|
* ```typescript
|
|
802
850
|
* const result = await client.followMerchant("merchant_123");
|
|
@@ -806,13 +854,13 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
806
854
|
async followMerchant(merchantId: string): Promise<FollowActionResponse> {
|
|
807
855
|
return this.post(`/api/marketplace/merchants/${merchantId}/follow`);
|
|
808
856
|
}
|
|
809
|
-
|
|
857
|
+
|
|
810
858
|
/**
|
|
811
859
|
* Unfollow a merchant
|
|
812
|
-
*
|
|
860
|
+
*
|
|
813
861
|
* @param merchantId - Merchant ID to unfollow
|
|
814
862
|
* @returns Unfollow action result
|
|
815
|
-
*
|
|
863
|
+
*
|
|
816
864
|
* @example
|
|
817
865
|
* ```typescript
|
|
818
866
|
* const result = await client.unfollowMerchant("merchant_123");
|
|
@@ -822,13 +870,13 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
822
870
|
async unfollowMerchant(merchantId: string): Promise<FollowActionResponse> {
|
|
823
871
|
return this.delete(`/api/marketplace/merchants/${merchantId}/follow`);
|
|
824
872
|
}
|
|
825
|
-
|
|
873
|
+
|
|
826
874
|
/**
|
|
827
875
|
* Get list of followed merchants
|
|
828
|
-
*
|
|
876
|
+
*
|
|
829
877
|
* @param params - Query parameters for pagination and sorting
|
|
830
878
|
* @returns Paginated list of followed merchants with their info
|
|
831
|
-
*
|
|
879
|
+
*
|
|
832
880
|
* @example
|
|
833
881
|
* ```typescript
|
|
834
882
|
* const result = await client.getFollowedMerchants({ limit: 20, sortBy: "recent" });
|
|
@@ -837,7 +885,9 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
837
885
|
* });
|
|
838
886
|
* ```
|
|
839
887
|
*/
|
|
840
|
-
async getFollowedMerchants(
|
|
888
|
+
async getFollowedMerchants(
|
|
889
|
+
params?: ListFollowingParams,
|
|
890
|
+
): Promise<ListFollowingResponse> {
|
|
841
891
|
const queryString = params ? buildQueryString(params) : "";
|
|
842
892
|
return this.get(`/api/marketplace/following${queryString}`);
|
|
843
893
|
}
|
|
@@ -848,11 +898,11 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
848
898
|
|
|
849
899
|
/**
|
|
850
900
|
* Get available payment methods
|
|
851
|
-
*
|
|
901
|
+
*
|
|
852
902
|
* Returns the list of enabled payment methods that can be used during checkout.
|
|
853
|
-
*
|
|
903
|
+
*
|
|
854
904
|
* @returns List of available payment methods with display info
|
|
855
|
-
*
|
|
905
|
+
*
|
|
856
906
|
* @example
|
|
857
907
|
* ```typescript
|
|
858
908
|
* const result = await client.getPaymentMethods();
|
|
@@ -873,12 +923,12 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
873
923
|
|
|
874
924
|
/**
|
|
875
925
|
* Get user's gem balance
|
|
876
|
-
*
|
|
926
|
+
*
|
|
877
927
|
* Returns the current gem balance including total gems, available gems,
|
|
878
928
|
* and gems expiring soon. Gems are earned at 100 per $1 of revenue.
|
|
879
|
-
*
|
|
929
|
+
*
|
|
880
930
|
* @returns Current gem balance with USD equivalent
|
|
881
|
-
*
|
|
931
|
+
*
|
|
882
932
|
* @example
|
|
883
933
|
* ```typescript
|
|
884
934
|
* const balance = await client.getGemBalance();
|
|
@@ -892,51 +942,53 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
892
942
|
|
|
893
943
|
/**
|
|
894
944
|
* Get gem transaction history
|
|
895
|
-
*
|
|
945
|
+
*
|
|
896
946
|
* Returns paginated history of gem transactions including earning,
|
|
897
947
|
* spending, and expiration events.
|
|
898
|
-
*
|
|
948
|
+
*
|
|
899
949
|
* @param params - Query parameters for filtering and pagination
|
|
900
950
|
* @returns Paginated gem history
|
|
901
|
-
*
|
|
951
|
+
*
|
|
902
952
|
* @example
|
|
903
953
|
* ```typescript
|
|
904
954
|
* // Get all history
|
|
905
955
|
* const history = await client.getGemHistory({ limit: 20, offset: 0 });
|
|
906
|
-
*
|
|
956
|
+
*
|
|
907
957
|
* // Get only earned gems
|
|
908
958
|
* const earned = await client.getGemHistory({ type: "earn", limit: 10 });
|
|
909
|
-
*
|
|
959
|
+
*
|
|
910
960
|
* // Get only spent gems
|
|
911
961
|
* const spent = await client.getGemHistory({ type: "spend", limit: 10 });
|
|
912
|
-
*
|
|
962
|
+
*
|
|
913
963
|
* history.items.forEach(item => {
|
|
914
964
|
* console.log(`${item.type}: ${item.amount} gems - ${item.createdAt}`);
|
|
915
965
|
* });
|
|
916
966
|
* ```
|
|
917
967
|
*/
|
|
918
|
-
async getGemHistory(
|
|
968
|
+
async getGemHistory(
|
|
969
|
+
params?: GetGemHistoryParams,
|
|
970
|
+
): Promise<GetGemHistoryResponse> {
|
|
919
971
|
const queryString = params ? buildQueryString(params) : "";
|
|
920
972
|
return this.get(`/api/gems/history${queryString}`);
|
|
921
973
|
}
|
|
922
974
|
|
|
923
975
|
/**
|
|
924
976
|
* Get gems that are expiring soon
|
|
925
|
-
*
|
|
977
|
+
*
|
|
926
978
|
* Returns gem batches that will expire within the specified number of days.
|
|
927
979
|
* Useful for prompting users to spend gems before they expire.
|
|
928
|
-
*
|
|
980
|
+
*
|
|
929
981
|
* @param params - Query parameters (days: default 30, max 180)
|
|
930
982
|
* @returns Expiring gem batches with countdown info
|
|
931
|
-
*
|
|
983
|
+
*
|
|
932
984
|
* @example
|
|
933
985
|
* ```typescript
|
|
934
986
|
* // Get gems expiring in next 30 days (default)
|
|
935
987
|
* const expiring = await client.getExpiringGems();
|
|
936
|
-
*
|
|
988
|
+
*
|
|
937
989
|
* // Get gems expiring in next 7 days
|
|
938
990
|
* const urgent = await client.getExpiringGems({ days: 7 });
|
|
939
|
-
*
|
|
991
|
+
*
|
|
940
992
|
* if (expiring.totalExpiring > 0) {
|
|
941
993
|
* console.log(`${expiring.totalExpiring} gems expiring soon!`);
|
|
942
994
|
* expiring.batches.forEach(batch => {
|
|
@@ -945,7 +997,9 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
945
997
|
* }
|
|
946
998
|
* ```
|
|
947
999
|
*/
|
|
948
|
-
async getExpiringGems(
|
|
1000
|
+
async getExpiringGems(
|
|
1001
|
+
params?: GetExpiringGemsParams,
|
|
1002
|
+
): Promise<GetExpiringGemsResponse> {
|
|
949
1003
|
const queryString = params ? buildQueryString(params) : "";
|
|
950
1004
|
return this.get(`/api/gems/expiring${queryString}`);
|
|
951
1005
|
}
|
|
@@ -956,12 +1010,12 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
956
1010
|
|
|
957
1011
|
/**
|
|
958
1012
|
* Get user's browsing location
|
|
959
|
-
*
|
|
1013
|
+
*
|
|
960
1014
|
* Returns the user's saved delivery location for geo-based product filtering.
|
|
961
1015
|
* This location is used to show products from merchants that ship to the area.
|
|
962
|
-
*
|
|
1016
|
+
*
|
|
963
1017
|
* @returns Current browsing location or null if not set
|
|
964
|
-
*
|
|
1018
|
+
*
|
|
965
1019
|
* @example
|
|
966
1020
|
* ```typescript
|
|
967
1021
|
* const result = await client.getBrowsingLocation();
|
|
@@ -976,13 +1030,13 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
976
1030
|
|
|
977
1031
|
/**
|
|
978
1032
|
* Save user's browsing location
|
|
979
|
-
*
|
|
1033
|
+
*
|
|
980
1034
|
* Sets the user's delivery location for geo-based product filtering.
|
|
981
1035
|
* Products will be filtered to show only items from merchants that ship to this location.
|
|
982
|
-
*
|
|
1036
|
+
*
|
|
983
1037
|
* @param request - Location data from Google Places or manual input
|
|
984
1038
|
* @returns The saved location
|
|
985
|
-
*
|
|
1039
|
+
*
|
|
986
1040
|
* @example
|
|
987
1041
|
* ```typescript
|
|
988
1042
|
* const result = await client.saveBrowsingLocation({
|
|
@@ -995,18 +1049,20 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
995
1049
|
* console.log(`Location saved: ${result.location.formattedAddress}`);
|
|
996
1050
|
* ```
|
|
997
1051
|
*/
|
|
998
|
-
async saveBrowsingLocation(
|
|
1052
|
+
async saveBrowsingLocation(
|
|
1053
|
+
request: SaveBrowsingLocationRequest,
|
|
1054
|
+
): Promise<SaveBrowsingLocationResponse> {
|
|
999
1055
|
return this.post("/api/user/browsing-location", request);
|
|
1000
1056
|
}
|
|
1001
1057
|
|
|
1002
1058
|
/**
|
|
1003
1059
|
* Clear user's browsing location
|
|
1004
|
-
*
|
|
1060
|
+
*
|
|
1005
1061
|
* Removes the user's saved delivery location. Products will no longer
|
|
1006
1062
|
* be filtered by shipping destination.
|
|
1007
|
-
*
|
|
1063
|
+
*
|
|
1008
1064
|
* @returns Success response
|
|
1009
|
-
*
|
|
1065
|
+
*
|
|
1010
1066
|
* @example
|
|
1011
1067
|
* ```typescript
|
|
1012
1068
|
* await client.clearBrowsingLocation();
|
|
@@ -1016,5 +1072,42 @@ export class CustomerEcommerceClient extends BaseEcommerceClient {
|
|
|
1016
1072
|
async clearBrowsingLocation(): Promise<DeleteBrowsingLocationResponse> {
|
|
1017
1073
|
return this.delete("/api/user/browsing-location");
|
|
1018
1074
|
}
|
|
1019
|
-
}
|
|
1020
1075
|
|
|
1076
|
+
// ============================================================================
|
|
1077
|
+
// BasedPay Cash Account API
|
|
1078
|
+
// ============================================================================
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
1081
|
+
* Get user's cash account balance for BASEDPAY
|
|
1082
|
+
*
|
|
1083
|
+
* Returns the current balance in the user's BasedPay cash account.
|
|
1084
|
+
*
|
|
1085
|
+
* @returns Cash account balance with currency
|
|
1086
|
+
*
|
|
1087
|
+
* @example
|
|
1088
|
+
* ```typescript
|
|
1089
|
+
* const balance = await client.getCashAccountBalance();
|
|
1090
|
+
* console.log(`Balance: ${balance.balance} ${balance.currency}`);
|
|
1091
|
+
* ```
|
|
1092
|
+
*/
|
|
1093
|
+
async getCashAccountBalance(): Promise<CashAccountBalanceResponse> {
|
|
1094
|
+
return this.get("/api/basedpay/balance");
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* Get user's delivery address for BASEDPAY
|
|
1099
|
+
*
|
|
1100
|
+
* Returns the user's delivery address for BASEDPAY.
|
|
1101
|
+
*
|
|
1102
|
+
* @returns Delivery address
|
|
1103
|
+
*
|
|
1104
|
+
* @example
|
|
1105
|
+
* ```typescript
|
|
1106
|
+
* const address = await client.getDeliveryAddress();
|
|
1107
|
+
* console.log(`Address: ${address.address}`);
|
|
1108
|
+
* ```
|
|
1109
|
+
*/
|
|
1110
|
+
async getDeliveryAddress(): Promise<DeliveryAddressResponse> {
|
|
1111
|
+
return this.get("/api/basedpay/delivery-address");
|
|
1112
|
+
}
|
|
1113
|
+
}
|