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