@basedone/core 0.1.8 → 0.2.0
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-4GAKANLT.mjs +1987 -0
- package/dist/chunk-4UEJOM6W.mjs +1 -3
- package/dist/chunk-VBC6EQ7Q.mjs +235 -0
- package/dist/client-CgmiTuEX.d.mts +179 -0
- package/dist/client-CgmiTuEX.d.ts +179 -0
- package/dist/ecommerce.d.mts +3732 -0
- package/dist/ecommerce.d.ts +3732 -0
- package/dist/ecommerce.js +2031 -0
- package/dist/ecommerce.mjs +2 -0
- package/dist/index.d.mts +79 -4
- package/dist/index.d.ts +79 -4
- package/dist/index.js +3674 -331
- package/dist/index.mjs +107 -104
- package/dist/{meta-57AY44US.mjs → meta-JB5ITE27.mjs} +6 -14
- package/dist/{meta-RSZFFH63.mjs → meta-UOGUG3OW.mjs} +5 -11
- package/dist/{perpDexs-PBKWKKQU.mjs → perpDexs-3LRJ5ZHM.mjs} +100 -13
- package/dist/{perpDexs-XSB4Y2BP.mjs → perpDexs-4ISLD7NX.mjs} +798 -121
- package/dist/react.d.mts +39 -0
- package/dist/react.d.ts +39 -0
- package/dist/react.js +268 -0
- package/dist/react.mjs +31 -0
- package/dist/{spotMeta-WQ4PXRNY.mjs → spotMeta-GHXX7C5M.mjs} +85 -14
- package/dist/{spotMeta-Y7G2GI7B.mjs → spotMeta-IBBUP2SG.mjs} +249 -12
- package/dist/staticMeta-GM7T3OYL.mjs +3 -6
- package/dist/staticMeta-QV2KMX57.mjs +3 -6
- package/ecommerce.ts +15 -0
- package/index.ts +7 -0
- package/lib/cloid/cloid.ts +2 -0
- package/lib/ecommerce/QUICK_REFERENCE.md +211 -0
- package/lib/ecommerce/README.md +385 -0
- package/lib/ecommerce/USAGE_EXAMPLES.md +704 -0
- package/lib/ecommerce/client/base.ts +272 -0
- package/lib/ecommerce/client/customer.ts +522 -0
- package/lib/ecommerce/client/merchant.ts +1341 -0
- package/lib/ecommerce/index.ts +51 -0
- package/lib/ecommerce/types/entities.ts +722 -0
- package/lib/ecommerce/types/enums.ts +270 -0
- package/lib/ecommerce/types/index.ts +18 -0
- package/lib/ecommerce/types/requests.ts +525 -0
- package/lib/ecommerce/types/responses.ts +805 -0
- package/lib/ecommerce/utils/errors.ts +113 -0
- package/lib/ecommerce/utils/helpers.ts +131 -0
- package/lib/fee.ts +10 -10
- package/lib/hip3/market-info.ts +36 -8
- package/lib/hip3/utils.ts +15 -2
- package/lib/instrument/client.ts +351 -0
- package/lib/meta/data/mainnet/meta.json +2 -4
- package/lib/meta/data/mainnet/perpDexs.json +97 -9
- package/lib/meta/data/mainnet/spotMeta.json +82 -8
- package/lib/meta/data/testnet/meta.json +3 -7
- package/lib/meta/data/testnet/perpDexs.json +795 -117
- package/lib/meta/data/testnet/spotMeta.json +246 -6
- package/lib/meta/metadata.ts +8 -1
- package/lib/meta/types.ts +36 -0
- package/lib/react/InstrumentProvider.tsx +69 -0
- package/lib/utils/flooredDateTime.ts +55 -0
- package/lib/utils/time.ts +51 -0
- package/package.json +37 -11
- package/react.ts +1 -0
|
@@ -0,0 +1,1987 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
// lib/ecommerce/utils/errors.ts
|
|
4
|
+
var EcommerceApiError = class _EcommerceApiError extends Error {
|
|
5
|
+
constructor(message, statusCode, data, isNetworkError = false, isTimeoutError = false) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "EcommerceApiError";
|
|
8
|
+
this.statusCode = statusCode;
|
|
9
|
+
this.data = data;
|
|
10
|
+
this.isNetworkError = isNetworkError;
|
|
11
|
+
this.isTimeoutError = isTimeoutError;
|
|
12
|
+
this.isAuthError = statusCode === 401 || statusCode === 403;
|
|
13
|
+
if (Error.captureStackTrace) {
|
|
14
|
+
Error.captureStackTrace(this, _EcommerceApiError);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
function parseError(error) {
|
|
19
|
+
if (error.code === "ECONNABORTED" || error.code === "ETIMEDOUT") {
|
|
20
|
+
return new EcommerceApiError(
|
|
21
|
+
"Request timeout",
|
|
22
|
+
void 0,
|
|
23
|
+
void 0,
|
|
24
|
+
false,
|
|
25
|
+
true
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
if (error.code === "ERR_NETWORK" || !error.response) {
|
|
29
|
+
return new EcommerceApiError(
|
|
30
|
+
error.message || "Network error",
|
|
31
|
+
void 0,
|
|
32
|
+
void 0,
|
|
33
|
+
true,
|
|
34
|
+
false
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
const response = error.response;
|
|
38
|
+
const statusCode = response?.status;
|
|
39
|
+
const data = response?.data;
|
|
40
|
+
const message = data?.error || data?.message || error.message || `API error (${statusCode})`;
|
|
41
|
+
return new EcommerceApiError(message, statusCode, data);
|
|
42
|
+
}
|
|
43
|
+
function isRetryableError(error) {
|
|
44
|
+
if (error.isNetworkError) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
if (error.isTimeoutError) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
if (error.statusCode && error.statusCode >= 500) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
if (error.statusCode === 429) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// lib/ecommerce/utils/helpers.ts
|
|
60
|
+
function buildQueryString(params) {
|
|
61
|
+
const searchParams = new URLSearchParams();
|
|
62
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
63
|
+
if (value !== void 0 && value !== null) {
|
|
64
|
+
if (Array.isArray(value)) {
|
|
65
|
+
searchParams.append(key, value.join(","));
|
|
66
|
+
} else {
|
|
67
|
+
searchParams.append(key, String(value));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
const queryString = searchParams.toString();
|
|
72
|
+
return queryString ? `?${queryString}` : "";
|
|
73
|
+
}
|
|
74
|
+
function sleep(ms) {
|
|
75
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
76
|
+
}
|
|
77
|
+
function getBackoffDelay(attempt, baseDelay = 1e3) {
|
|
78
|
+
return Math.min(baseDelay * Math.pow(2, attempt), 3e4);
|
|
79
|
+
}
|
|
80
|
+
async function retryWithBackoff(fn, maxRetries = 3, baseDelay = 1e3, shouldRetry) {
|
|
81
|
+
let lastError;
|
|
82
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
83
|
+
try {
|
|
84
|
+
return await fn();
|
|
85
|
+
} catch (error) {
|
|
86
|
+
lastError = error;
|
|
87
|
+
if (attempt < maxRetries && (!shouldRetry || shouldRetry(error))) {
|
|
88
|
+
const delay = getBackoffDelay(attempt, baseDelay);
|
|
89
|
+
await sleep(delay);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
throw lastError;
|
|
96
|
+
}
|
|
97
|
+
function formatPrice(price, decimals = 2) {
|
|
98
|
+
const num = typeof price === "string" ? parseFloat(price) : price;
|
|
99
|
+
return num.toFixed(decimals);
|
|
100
|
+
}
|
|
101
|
+
function isValidEmail(email) {
|
|
102
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
103
|
+
return emailRegex.test(email);
|
|
104
|
+
}
|
|
105
|
+
function isValidAddress(address) {
|
|
106
|
+
return /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
107
|
+
}
|
|
108
|
+
function truncateAddress(address, start = 6, end = 4) {
|
|
109
|
+
if (!address || address.length < start + end) {
|
|
110
|
+
return address;
|
|
111
|
+
}
|
|
112
|
+
return `${address.slice(0, start)}...${address.slice(-end)}`;
|
|
113
|
+
}
|
|
114
|
+
function calculateDiscountAmount(price, discountType, discountValue) {
|
|
115
|
+
if (discountType === "PERCENTAGE") {
|
|
116
|
+
return price * discountValue / 100;
|
|
117
|
+
}
|
|
118
|
+
return Math.min(discountValue, price);
|
|
119
|
+
}
|
|
120
|
+
function calculateFinalPrice(price, discountType, discountValue) {
|
|
121
|
+
const discountAmount = calculateDiscountAmount(price, discountType, discountValue);
|
|
122
|
+
return Math.max(0, price - discountAmount);
|
|
123
|
+
}
|
|
124
|
+
var BaseEcommerceClient = class {
|
|
125
|
+
constructor(config) {
|
|
126
|
+
this.config = {
|
|
127
|
+
baseURL: config.baseURL,
|
|
128
|
+
authToken: config.authToken,
|
|
129
|
+
timeout: config.timeout || 3e4,
|
|
130
|
+
maxRetries: config.maxRetries || 3,
|
|
131
|
+
retryBaseDelay: config.retryBaseDelay || 1e3,
|
|
132
|
+
headers: config.headers,
|
|
133
|
+
enableRetry: config.enableRetry !== false
|
|
134
|
+
};
|
|
135
|
+
this.axiosInstance = axios.create({
|
|
136
|
+
baseURL: this.config.baseURL,
|
|
137
|
+
timeout: this.config.timeout,
|
|
138
|
+
headers: {
|
|
139
|
+
"Content-Type": "application/json",
|
|
140
|
+
...this.config.headers
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
this.axiosInstance.interceptors.request.use(
|
|
144
|
+
(config2) => {
|
|
145
|
+
if (this.config.authToken) {
|
|
146
|
+
config2.headers.Authorization = `Bearer ${this.config.authToken}`;
|
|
147
|
+
}
|
|
148
|
+
return config2;
|
|
149
|
+
},
|
|
150
|
+
(error) => Promise.reject(error)
|
|
151
|
+
);
|
|
152
|
+
this.axiosInstance.interceptors.response.use(
|
|
153
|
+
(response) => response,
|
|
154
|
+
(error) => Promise.reject(parseError(error))
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Update authentication token
|
|
159
|
+
*
|
|
160
|
+
* @param token - New authentication token
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* client.setAuthToken("new-auth-token");
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
setAuthToken(token) {
|
|
168
|
+
this.config.authToken = token;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Clear authentication token
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* client.clearAuthToken();
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
clearAuthToken() {
|
|
179
|
+
this.config.authToken = void 0;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Make a GET request
|
|
183
|
+
*
|
|
184
|
+
* @param url - Request URL
|
|
185
|
+
* @param config - Axios request config
|
|
186
|
+
* @returns Response data
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* const products = await client.get("/api/marketplace/products", {
|
|
191
|
+
* params: { limit: 20, offset: 0 }
|
|
192
|
+
* });
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
async get(url, config) {
|
|
196
|
+
return this.request({ ...config, method: "GET", url });
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Make a POST request
|
|
200
|
+
*
|
|
201
|
+
* @param url - Request URL
|
|
202
|
+
* @param data - Request body data
|
|
203
|
+
* @param config - Axios request config
|
|
204
|
+
* @returns Response data
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const order = await client.post("/api/marketplace/orders", {
|
|
209
|
+
* items: [{ productId: "123", quantity: 1 }],
|
|
210
|
+
* paymentMethod: "USDC_ESCROW"
|
|
211
|
+
* });
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
async post(url, data, config) {
|
|
215
|
+
return this.request({ ...config, method: "POST", url, data });
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Make a PUT request
|
|
219
|
+
*
|
|
220
|
+
* @param url - Request URL
|
|
221
|
+
* @param data - Request body data
|
|
222
|
+
* @param config - Axios request config
|
|
223
|
+
* @returns Response data
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* const product = await client.put("/api/marketplace/products/123", {
|
|
228
|
+
* title: "Updated Product"
|
|
229
|
+
* });
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
async put(url, data, config) {
|
|
233
|
+
return this.request({ ...config, method: "PUT", url, data });
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Make a PATCH request
|
|
237
|
+
*
|
|
238
|
+
* @param url - Request URL
|
|
239
|
+
* @param data - Request body data
|
|
240
|
+
* @param config - Axios request config
|
|
241
|
+
* @returns Response data
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* const order = await client.patch("/api/marketplace/merchant/orders/123", {
|
|
246
|
+
* status: "SHIPPED",
|
|
247
|
+
* tracking: { trackingNumber: "123456", carrier: "UPS" }
|
|
248
|
+
* });
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
async patch(url, data, config) {
|
|
252
|
+
return this.request({ ...config, method: "PATCH", url, data });
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Make a DELETE request
|
|
256
|
+
*
|
|
257
|
+
* @param url - Request URL
|
|
258
|
+
* @param config - Axios request config
|
|
259
|
+
* @returns Response data
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* await client.delete("/api/marketplace/products/123");
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
async delete(url, config) {
|
|
267
|
+
return this.request({ ...config, method: "DELETE", url });
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Make a request with retry logic
|
|
271
|
+
*
|
|
272
|
+
* @param config - Axios request config
|
|
273
|
+
* @returns Response data
|
|
274
|
+
*/
|
|
275
|
+
async request(config) {
|
|
276
|
+
const makeRequest = async () => {
|
|
277
|
+
return this.axiosInstance.request(config);
|
|
278
|
+
};
|
|
279
|
+
if (this.config.enableRetry) {
|
|
280
|
+
const response = await retryWithBackoff(
|
|
281
|
+
makeRequest,
|
|
282
|
+
this.config.maxRetries,
|
|
283
|
+
this.config.retryBaseDelay,
|
|
284
|
+
(error) => isRetryableError(error)
|
|
285
|
+
);
|
|
286
|
+
return response.data;
|
|
287
|
+
} else {
|
|
288
|
+
const response = await makeRequest();
|
|
289
|
+
return response.data;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Get the underlying axios instance
|
|
294
|
+
*
|
|
295
|
+
* @returns Axios instance
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* const axios = client.getAxiosInstance();
|
|
300
|
+
* // Use axios directly for advanced use cases
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
getAxiosInstance() {
|
|
304
|
+
return this.axiosInstance;
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
// lib/ecommerce/client/customer.ts
|
|
309
|
+
var CustomerEcommerceClient = class extends BaseEcommerceClient {
|
|
310
|
+
// ============================================================================
|
|
311
|
+
// Products API
|
|
312
|
+
// ============================================================================
|
|
313
|
+
/**
|
|
314
|
+
* List products with filtering and pagination
|
|
315
|
+
*
|
|
316
|
+
* @param params - Query parameters for filtering
|
|
317
|
+
* @returns Paginated list of products
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```typescript
|
|
321
|
+
* const products = await client.listProducts({
|
|
322
|
+
* limit: 20,
|
|
323
|
+
* offset: 0,
|
|
324
|
+
* category: "electronics",
|
|
325
|
+
* search: "laptop",
|
|
326
|
+
* minPrice: 500,
|
|
327
|
+
* maxPrice: 2000,
|
|
328
|
+
* sortBy: "price_asc"
|
|
329
|
+
* });
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
async listProducts(params) {
|
|
333
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
334
|
+
return this.get(`/api/marketplace/products${queryString}`);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Get product details by ID
|
|
338
|
+
*
|
|
339
|
+
* @param productId - Product ID
|
|
340
|
+
* @returns Product details with merchant info, variants, and reviews
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```typescript
|
|
344
|
+
* const product = await client.getProduct("prod_123");
|
|
345
|
+
* console.log(product.title, product.priceUSDC);
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
async getProduct(productId) {
|
|
349
|
+
return this.get(`/api/marketplace/products/${productId}`);
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Track product view (increment view count)
|
|
353
|
+
*
|
|
354
|
+
* @param productId - Product ID
|
|
355
|
+
* @returns Success response
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```typescript
|
|
359
|
+
* await client.trackProductView("prod_123");
|
|
360
|
+
* ```
|
|
361
|
+
*/
|
|
362
|
+
async trackProductView(productId) {
|
|
363
|
+
return this.post(`/api/marketplace/products/${productId}/view`);
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Get active automatic discounts for a product
|
|
367
|
+
*
|
|
368
|
+
* @param productId - Product ID
|
|
369
|
+
* @returns List of applicable discounts
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
* const discounts = await client.getProductDiscounts("prod_123");
|
|
374
|
+
* discounts.discounts.forEach(d => console.log(d.description));
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
async getProductDiscounts(productId) {
|
|
378
|
+
return this.get(`/api/marketplace/products/${productId}/discounts`);
|
|
379
|
+
}
|
|
380
|
+
// ============================================================================
|
|
381
|
+
// Orders API
|
|
382
|
+
// ============================================================================
|
|
383
|
+
/**
|
|
384
|
+
* Create order from cart checkout
|
|
385
|
+
*
|
|
386
|
+
* Supports multi-merchant checkout - automatically splits orders by merchant.
|
|
387
|
+
*
|
|
388
|
+
* @param request - Order creation request
|
|
389
|
+
* @returns Created order(s) with payment instructions
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* ```typescript
|
|
393
|
+
* const result = await client.createOrder({
|
|
394
|
+
* items: [
|
|
395
|
+
* { productId: "prod_123", quantity: 2 },
|
|
396
|
+
* { productId: "prod_456", quantity: 1, variantId: "var_789" }
|
|
397
|
+
* ],
|
|
398
|
+
* paymentMethod: "USDC_ESCROW",
|
|
399
|
+
* shippingAddress: {
|
|
400
|
+
* fullName: "John Doe",
|
|
401
|
+
* phone: "+1234567890",
|
|
402
|
+
* addressLine1: "123 Main St",
|
|
403
|
+
* city: "New York",
|
|
404
|
+
* stateProvince: "NY",
|
|
405
|
+
* postalCode: "10001",
|
|
406
|
+
* country: "US"
|
|
407
|
+
* },
|
|
408
|
+
* couponCode: "SAVE10"
|
|
409
|
+
* });
|
|
410
|
+
*
|
|
411
|
+
* // For USDC escrow, deposit to the escrow address
|
|
412
|
+
* if (result.escrow) {
|
|
413
|
+
* console.log("Deposit", result.escrow.amountUSDC, "USDC to", result.escrow.address);
|
|
414
|
+
* }
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
async createOrder(request) {
|
|
418
|
+
return this.post("/api/marketplace/orders", request);
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* List user's orders
|
|
422
|
+
*
|
|
423
|
+
* @param params - Query parameters for filtering
|
|
424
|
+
* @returns Paginated list of orders
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```typescript
|
|
428
|
+
* const orders = await client.listOrders({
|
|
429
|
+
* limit: 10,
|
|
430
|
+
* offset: 0,
|
|
431
|
+
* status: "SHIPPED"
|
|
432
|
+
* });
|
|
433
|
+
* ```
|
|
434
|
+
*/
|
|
435
|
+
async listOrders(params) {
|
|
436
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
437
|
+
return this.get(`/api/marketplace/orders${queryString}`);
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Get order details by ID
|
|
441
|
+
*
|
|
442
|
+
* @param orderId - Order ID
|
|
443
|
+
* @returns Order details with items, payment, and shipment info
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```typescript
|
|
447
|
+
* const order = await client.getOrder("ord_123");
|
|
448
|
+
* console.log(order.order.status, order.order.totalUSDC);
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
async getOrder(orderId) {
|
|
452
|
+
return this.get(`/api/marketplace/orders/${orderId}`);
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Confirm USDC escrow deposit for order payment
|
|
456
|
+
*
|
|
457
|
+
* Verifies the Hyperliquid transaction and updates order status.
|
|
458
|
+
*
|
|
459
|
+
* @param orderId - Order ID
|
|
460
|
+
* @returns Confirmation response with transaction hash
|
|
461
|
+
*
|
|
462
|
+
* @example
|
|
463
|
+
* ```typescript
|
|
464
|
+
* // After depositing USDC to escrow address
|
|
465
|
+
* const result = await client.confirmEscrowDeposit("ord_123");
|
|
466
|
+
* console.log("Payment confirmed:", result.depositTxHash);
|
|
467
|
+
* ```
|
|
468
|
+
*/
|
|
469
|
+
async confirmEscrowDeposit(orderId) {
|
|
470
|
+
return this.post(`/api/marketplace/orders/${orderId}/confirm-escrow-deposit`);
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Get order receipt
|
|
474
|
+
*
|
|
475
|
+
* @param orderId - Order ID
|
|
476
|
+
* @returns Order receipt for download/display
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* ```typescript
|
|
480
|
+
* const receipt = await client.getOrderReceipt("ord_123");
|
|
481
|
+
* console.log("Order #", receipt.receipt.orderNumber);
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
484
|
+
async getOrderReceipt(orderId) {
|
|
485
|
+
return this.get(`/api/marketplace/orders/${orderId}/receipt`);
|
|
486
|
+
}
|
|
487
|
+
// ============================================================================
|
|
488
|
+
// Reviews API
|
|
489
|
+
// ============================================================================
|
|
490
|
+
/**
|
|
491
|
+
* List reviews for a product
|
|
492
|
+
*
|
|
493
|
+
* @param productId - Product ID
|
|
494
|
+
* @param params - Query parameters
|
|
495
|
+
* @returns Paginated list of reviews
|
|
496
|
+
*
|
|
497
|
+
* @example
|
|
498
|
+
* ```typescript
|
|
499
|
+
* const reviews = await client.listProductReviews("prod_123", {
|
|
500
|
+
* limit: 10,
|
|
501
|
+
* sortBy: "highest"
|
|
502
|
+
* });
|
|
503
|
+
* ```
|
|
504
|
+
*/
|
|
505
|
+
async listProductReviews(productId, params) {
|
|
506
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
507
|
+
return this.get(`/api/marketplace/products/${productId}/reviews${queryString}`);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Create a product review
|
|
511
|
+
*
|
|
512
|
+
* Requires authenticated user who has purchased the product.
|
|
513
|
+
*
|
|
514
|
+
* @param productId - Product ID
|
|
515
|
+
* @param request - Review creation request
|
|
516
|
+
* @returns Created review
|
|
517
|
+
*
|
|
518
|
+
* @example
|
|
519
|
+
* ```typescript
|
|
520
|
+
* const review = await client.createReview("prod_123", {
|
|
521
|
+
* rating: 5,
|
|
522
|
+
* title: "Great product!",
|
|
523
|
+
* comment: "Exactly what I needed. Fast shipping too!"
|
|
524
|
+
* });
|
|
525
|
+
* ```
|
|
526
|
+
*/
|
|
527
|
+
async createReview(productId, request) {
|
|
528
|
+
return this.post(`/api/marketplace/products/${productId}/reviews`, request);
|
|
529
|
+
}
|
|
530
|
+
// ============================================================================
|
|
531
|
+
// Shipping Addresses API
|
|
532
|
+
// ============================================================================
|
|
533
|
+
/**
|
|
534
|
+
* List saved shipping addresses
|
|
535
|
+
*
|
|
536
|
+
* @returns List of user's saved shipping addresses
|
|
537
|
+
*
|
|
538
|
+
* @example
|
|
539
|
+
* ```typescript
|
|
540
|
+
* const addresses = await client.listShippingAddresses();
|
|
541
|
+
* const defaultAddress = addresses.addresses.find(a => a.isDefault);
|
|
542
|
+
* ```
|
|
543
|
+
*/
|
|
544
|
+
async listShippingAddresses() {
|
|
545
|
+
return this.get("/api/user/shipping-addresses");
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Create a new shipping address
|
|
549
|
+
*
|
|
550
|
+
* @param request - Shipping address data
|
|
551
|
+
* @returns Created address
|
|
552
|
+
*
|
|
553
|
+
* @example
|
|
554
|
+
* ```typescript
|
|
555
|
+
* const address = await client.createShippingAddress({
|
|
556
|
+
* fullName: "John Doe",
|
|
557
|
+
* phone: "+1234567890",
|
|
558
|
+
* addressLine1: "123 Main St",
|
|
559
|
+
* city: "New York",
|
|
560
|
+
* stateProvince: "NY",
|
|
561
|
+
* postalCode: "10001",
|
|
562
|
+
* country: "US",
|
|
563
|
+
* isDefault: true,
|
|
564
|
+
* label: "Home"
|
|
565
|
+
* });
|
|
566
|
+
* ```
|
|
567
|
+
*/
|
|
568
|
+
async createShippingAddress(request) {
|
|
569
|
+
return this.post("/api/user/shipping-addresses", request);
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Update a shipping address
|
|
573
|
+
*
|
|
574
|
+
* @param addressId - Address ID
|
|
575
|
+
* @param request - Updated address data
|
|
576
|
+
* @returns Updated address
|
|
577
|
+
*
|
|
578
|
+
* @example
|
|
579
|
+
* ```typescript
|
|
580
|
+
* const address = await client.updateShippingAddress("addr_123", {
|
|
581
|
+
* phone: "+0987654321"
|
|
582
|
+
* });
|
|
583
|
+
* ```
|
|
584
|
+
*/
|
|
585
|
+
async updateShippingAddress(addressId, request) {
|
|
586
|
+
return this.patch(`/api/user/shipping-addresses/${addressId}`, request);
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Delete a shipping address
|
|
590
|
+
*
|
|
591
|
+
* @param addressId - Address ID
|
|
592
|
+
* @returns Success response
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* ```typescript
|
|
596
|
+
* await client.deleteShippingAddress("addr_123");
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
async deleteShippingAddress(addressId) {
|
|
600
|
+
return this.delete(`/api/user/shipping-addresses/${addressId}`);
|
|
601
|
+
}
|
|
602
|
+
// ============================================================================
|
|
603
|
+
// Cart & Discounts API
|
|
604
|
+
// ============================================================================
|
|
605
|
+
/**
|
|
606
|
+
* Calculate automatic discounts for cart items
|
|
607
|
+
*
|
|
608
|
+
* @param request - Cart items
|
|
609
|
+
* @returns Calculated discounts and totals
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```typescript
|
|
613
|
+
* const result = await client.calculateCartDiscounts({
|
|
614
|
+
* items: [
|
|
615
|
+
* { productId: "prod_123", quantity: 2 },
|
|
616
|
+
* { productId: "prod_456", quantity: 1 }
|
|
617
|
+
* ]
|
|
618
|
+
* });
|
|
619
|
+
* console.log("Subtotal:", result.subtotal);
|
|
620
|
+
* console.log("Discount:", result.discountAmount);
|
|
621
|
+
* console.log("Total:", result.total);
|
|
622
|
+
* ```
|
|
623
|
+
*/
|
|
624
|
+
async calculateCartDiscounts(request) {
|
|
625
|
+
return this.post("/api/marketplace/cart/discounts", request);
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Validate a discount code for cart items
|
|
629
|
+
*
|
|
630
|
+
* @param request - Discount code and cart items
|
|
631
|
+
* @returns Validation result with discount details
|
|
632
|
+
*
|
|
633
|
+
* @example
|
|
634
|
+
* ```typescript
|
|
635
|
+
* const result = await client.validateDiscountCode({
|
|
636
|
+
* code: "SAVE10",
|
|
637
|
+
* items: [
|
|
638
|
+
* { productId: "prod_123", quantity: 2 }
|
|
639
|
+
* ]
|
|
640
|
+
* });
|
|
641
|
+
*
|
|
642
|
+
* if (result.valid) {
|
|
643
|
+
* console.log("Discount:", result.discount?.discountAmount);
|
|
644
|
+
* } else {
|
|
645
|
+
* console.log("Error:", result.error);
|
|
646
|
+
* }
|
|
647
|
+
* ```
|
|
648
|
+
*/
|
|
649
|
+
async validateDiscountCode(request) {
|
|
650
|
+
return this.post("/api/marketplace/discounts/validate", request);
|
|
651
|
+
}
|
|
652
|
+
// ============================================================================
|
|
653
|
+
// Tax Calculation API
|
|
654
|
+
// ============================================================================
|
|
655
|
+
/**
|
|
656
|
+
* Calculate tax for cart items based on shipping address
|
|
657
|
+
*
|
|
658
|
+
* @param request - Cart items and shipping address
|
|
659
|
+
* @returns Tax calculation with breakdown
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* ```typescript
|
|
663
|
+
* const result = await client.calculateTax({
|
|
664
|
+
* items: [
|
|
665
|
+
* { productId: "prod_123", quantity: 2 }
|
|
666
|
+
* ],
|
|
667
|
+
* shippingAddress: {
|
|
668
|
+
* country: "US",
|
|
669
|
+
* region: "NY",
|
|
670
|
+
* postalCode: "10001"
|
|
671
|
+
* }
|
|
672
|
+
* });
|
|
673
|
+
* console.log("Tax:", result.taxAmount);
|
|
674
|
+
* console.log("Total:", result.total);
|
|
675
|
+
* ```
|
|
676
|
+
*/
|
|
677
|
+
async calculateTax(request) {
|
|
678
|
+
return this.post("/api/marketplace/tax/calculate", request);
|
|
679
|
+
}
|
|
680
|
+
// ============================================================================
|
|
681
|
+
// Banners API
|
|
682
|
+
// ============================================================================
|
|
683
|
+
/**
|
|
684
|
+
* Get active promotional banners
|
|
685
|
+
*
|
|
686
|
+
* @param params - Query parameters
|
|
687
|
+
* @returns List of active banners
|
|
688
|
+
*
|
|
689
|
+
* @example
|
|
690
|
+
* ```typescript
|
|
691
|
+
* const banners = await client.getActiveBanners({
|
|
692
|
+
* type: "HERO",
|
|
693
|
+
* merchantId: "merchant_123"
|
|
694
|
+
* });
|
|
695
|
+
* ```
|
|
696
|
+
*/
|
|
697
|
+
async getActiveBanners(params) {
|
|
698
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
699
|
+
return this.get(`/api/marketplace/banners/active${queryString}`);
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Track banner impression or click
|
|
703
|
+
*
|
|
704
|
+
* @param bannerId - Banner ID
|
|
705
|
+
* @param request - Track action (impression or click)
|
|
706
|
+
* @returns Success response
|
|
707
|
+
*
|
|
708
|
+
* @example
|
|
709
|
+
* ```typescript
|
|
710
|
+
* // Track impression
|
|
711
|
+
* await client.trackBanner("banner_123", { action: "impression" });
|
|
712
|
+
*
|
|
713
|
+
* // Track click
|
|
714
|
+
* await client.trackBanner("banner_123", { action: "click" });
|
|
715
|
+
* ```
|
|
716
|
+
*/
|
|
717
|
+
async trackBanner(bannerId, request) {
|
|
718
|
+
return this.post(`/api/marketplace/banners/${bannerId}/track`, request);
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
// lib/ecommerce/client/merchant.ts
|
|
723
|
+
var MerchantEcommerceClient = class extends BaseEcommerceClient {
|
|
724
|
+
// ============================================================================
|
|
725
|
+
// Profile Management
|
|
726
|
+
// ============================================================================
|
|
727
|
+
/**
|
|
728
|
+
* Get merchant profile
|
|
729
|
+
*
|
|
730
|
+
* @returns Merchant profile
|
|
731
|
+
*
|
|
732
|
+
* @example
|
|
733
|
+
* ```typescript
|
|
734
|
+
* const profile = await client.getMerchantProfile();
|
|
735
|
+
* console.log(profile.merchant.name);
|
|
736
|
+
* ```
|
|
737
|
+
*/
|
|
738
|
+
async getMerchantProfile() {
|
|
739
|
+
return this.get("/api/marketplace/merchant/profile");
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Get merchant profile (alias for getMerchantProfile)
|
|
743
|
+
*
|
|
744
|
+
* @returns Merchant profile
|
|
745
|
+
*
|
|
746
|
+
* @example
|
|
747
|
+
* ```typescript
|
|
748
|
+
* const profile = await client.getProfile();
|
|
749
|
+
* console.log(profile.merchant.name);
|
|
750
|
+
* ```
|
|
751
|
+
*/
|
|
752
|
+
async getProfile() {
|
|
753
|
+
return this.getMerchantProfile();
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Create or update merchant profile
|
|
757
|
+
*
|
|
758
|
+
* @param request - Profile data
|
|
759
|
+
* @returns Updated merchant profile
|
|
760
|
+
*
|
|
761
|
+
* @example
|
|
762
|
+
* ```typescript
|
|
763
|
+
* const profile = await client.upsertMerchantProfile({
|
|
764
|
+
* name: "My Store",
|
|
765
|
+
* description: "We sell great products",
|
|
766
|
+
* payoutAddress: "0x1234..."
|
|
767
|
+
* });
|
|
768
|
+
* ```
|
|
769
|
+
*/
|
|
770
|
+
async upsertMerchantProfile(request) {
|
|
771
|
+
return this.post("/api/marketplace/merchant/profile", request);
|
|
772
|
+
}
|
|
773
|
+
// ============================================================================
|
|
774
|
+
// Products Management
|
|
775
|
+
// ============================================================================
|
|
776
|
+
/**
|
|
777
|
+
* List merchant's products
|
|
778
|
+
*
|
|
779
|
+
* @param params - Query parameters
|
|
780
|
+
* @returns Paginated list of products
|
|
781
|
+
*
|
|
782
|
+
* @example
|
|
783
|
+
* ```typescript
|
|
784
|
+
* const products = await client.listMerchantProducts({ limit: 20, offset: 0 });
|
|
785
|
+
* ```
|
|
786
|
+
*/
|
|
787
|
+
async listMerchantProducts(params) {
|
|
788
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
789
|
+
return this.get(`/api/marketplace/merchant/products${queryString}`);
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Get a single product by ID
|
|
793
|
+
*
|
|
794
|
+
* @param productId - Product ID
|
|
795
|
+
* @returns Product details
|
|
796
|
+
*
|
|
797
|
+
* @example
|
|
798
|
+
* ```typescript
|
|
799
|
+
* const product = await client.getProduct("prod_123");
|
|
800
|
+
* console.log(product.product?.title, product.product?.priceUSDC);
|
|
801
|
+
* ```
|
|
802
|
+
*/
|
|
803
|
+
async getProduct(productId) {
|
|
804
|
+
return this.get(`/api/marketplace/products/${productId}`);
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Create a new product
|
|
808
|
+
*
|
|
809
|
+
* @param request - Product data
|
|
810
|
+
* @returns Created product
|
|
811
|
+
*
|
|
812
|
+
* @example
|
|
813
|
+
* ```typescript
|
|
814
|
+
* const product = await client.createProduct({
|
|
815
|
+
* title: "Awesome Product",
|
|
816
|
+
* images: ["https://..."],
|
|
817
|
+
* priceUSDC: 49.99,
|
|
818
|
+
* inventory: 50,
|
|
819
|
+
* category: "electronics",
|
|
820
|
+
* moq: 1
|
|
821
|
+
* });
|
|
822
|
+
* ```
|
|
823
|
+
*/
|
|
824
|
+
async createProduct(request) {
|
|
825
|
+
return this.post("/api/marketplace/merchant/products", request);
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Update a product
|
|
829
|
+
*
|
|
830
|
+
* @param productId - Product ID
|
|
831
|
+
* @param request - Updated product data
|
|
832
|
+
* @returns Updated product
|
|
833
|
+
*
|
|
834
|
+
* @example
|
|
835
|
+
* ```typescript
|
|
836
|
+
* const product = await client.updateProduct("prod_123", {
|
|
837
|
+
* priceUSDC: 39.99,
|
|
838
|
+
* inventory: 75
|
|
839
|
+
* });
|
|
840
|
+
* ```
|
|
841
|
+
*/
|
|
842
|
+
async updateProduct(productId, request) {
|
|
843
|
+
return this.put(`/api/marketplace/products/${productId}`, request);
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Delete a product
|
|
847
|
+
*
|
|
848
|
+
* @param productId - Product ID
|
|
849
|
+
* @returns Success response
|
|
850
|
+
*
|
|
851
|
+
* @example
|
|
852
|
+
* ```typescript
|
|
853
|
+
* await client.deleteProduct("prod_123");
|
|
854
|
+
* ```
|
|
855
|
+
*/
|
|
856
|
+
async deleteProduct(productId) {
|
|
857
|
+
return this.delete(`/api/marketplace/products/${productId}`);
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Toggle product featured status
|
|
861
|
+
*
|
|
862
|
+
* @param productId - Product ID
|
|
863
|
+
* @param featured - Featured status
|
|
864
|
+
* @returns Updated product
|
|
865
|
+
*
|
|
866
|
+
* @example
|
|
867
|
+
* ```typescript
|
|
868
|
+
* await client.setProductFeatured("prod_123", true);
|
|
869
|
+
* ```
|
|
870
|
+
*/
|
|
871
|
+
async setProductFeatured(productId, featured) {
|
|
872
|
+
return this.patch(`/api/marketplace/merchant/products/${productId}/featured`, { featured });
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* List product variants
|
|
876
|
+
*
|
|
877
|
+
* @param productId - Product ID
|
|
878
|
+
* @returns List of variants
|
|
879
|
+
*
|
|
880
|
+
* @example
|
|
881
|
+
* ```typescript
|
|
882
|
+
* const variants = await client.listProductVariants("prod_123");
|
|
883
|
+
* ```
|
|
884
|
+
*/
|
|
885
|
+
async listProductVariants(productId) {
|
|
886
|
+
return this.get(`/api/marketplace/merchant/products/${productId}/variants`);
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Create a product variant
|
|
890
|
+
*
|
|
891
|
+
* @param productId - Product ID
|
|
892
|
+
* @param request - Variant data
|
|
893
|
+
* @returns Created variant
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* ```typescript
|
|
897
|
+
* const variant = await client.createProductVariant("prod_123", {
|
|
898
|
+
* name: "Large / Red",
|
|
899
|
+
* attributes: { size: "L", color: "Red" },
|
|
900
|
+
* priceUSDC: 54.99,
|
|
901
|
+
* inventory: 20
|
|
902
|
+
* });
|
|
903
|
+
* ```
|
|
904
|
+
*/
|
|
905
|
+
async createProductVariant(productId, request) {
|
|
906
|
+
return this.post(`/api/marketplace/merchant/products/${productId}/variants`, request);
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Get a product variant
|
|
910
|
+
*
|
|
911
|
+
* @param productId - Product ID
|
|
912
|
+
* @param variantId - Variant ID
|
|
913
|
+
* @returns Variant details
|
|
914
|
+
*
|
|
915
|
+
* @example
|
|
916
|
+
* ```typescript
|
|
917
|
+
* const variant = await client.getProductVariant("prod_123", "var_456");
|
|
918
|
+
* ```
|
|
919
|
+
*/
|
|
920
|
+
async getProductVariant(productId, variantId) {
|
|
921
|
+
return this.get(`/api/marketplace/merchant/products/${productId}/variants/${variantId}`);
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Update a product variant
|
|
925
|
+
*
|
|
926
|
+
* @param productId - Product ID
|
|
927
|
+
* @param variantId - Variant ID
|
|
928
|
+
* @param request - Updated variant data
|
|
929
|
+
* @returns Updated variant
|
|
930
|
+
*
|
|
931
|
+
* @example
|
|
932
|
+
* ```typescript
|
|
933
|
+
* const variant = await client.updateProductVariant("prod_123", "var_456", {
|
|
934
|
+
* inventory: 30
|
|
935
|
+
* });
|
|
936
|
+
* ```
|
|
937
|
+
*/
|
|
938
|
+
async updateProductVariant(productId, variantId, request) {
|
|
939
|
+
return this.put(`/api/marketplace/merchant/products/${productId}/variants/${variantId}`, request);
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Delete a product variant
|
|
943
|
+
*
|
|
944
|
+
* @param productId - Product ID
|
|
945
|
+
* @param variantId - Variant ID
|
|
946
|
+
* @returns Success response
|
|
947
|
+
*
|
|
948
|
+
* @example
|
|
949
|
+
* ```typescript
|
|
950
|
+
* await client.deleteProductVariant("prod_123", "var_456");
|
|
951
|
+
* ```
|
|
952
|
+
*/
|
|
953
|
+
async deleteProductVariant(productId, variantId) {
|
|
954
|
+
return this.delete(`/api/marketplace/merchant/products/${productId}/variants/${variantId}`);
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Get product metrics
|
|
958
|
+
*
|
|
959
|
+
* @returns Product performance metrics
|
|
960
|
+
*
|
|
961
|
+
* @example
|
|
962
|
+
* ```typescript
|
|
963
|
+
* const metrics = await client.getProductMetrics();
|
|
964
|
+
* console.log("Total revenue:", metrics.summary.totalRevenue);
|
|
965
|
+
* ```
|
|
966
|
+
*/
|
|
967
|
+
async getProductMetrics() {
|
|
968
|
+
return this.get("/api/marketplace/merchant/products/metrics");
|
|
969
|
+
}
|
|
970
|
+
// ============================================================================
|
|
971
|
+
// Orders Management
|
|
972
|
+
// ============================================================================
|
|
973
|
+
/**
|
|
974
|
+
* List merchant's orders
|
|
975
|
+
*
|
|
976
|
+
* @param params - Query parameters
|
|
977
|
+
* @returns Paginated list of orders
|
|
978
|
+
*
|
|
979
|
+
* @example
|
|
980
|
+
* ```typescript
|
|
981
|
+
* const orders = await client.listMerchantOrders({ limit: 20, offset: 0 });
|
|
982
|
+
* ```
|
|
983
|
+
*/
|
|
984
|
+
async listMerchantOrders(params) {
|
|
985
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
986
|
+
return this.get(`/api/marketplace/merchant/orders${queryString}`);
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Get order details
|
|
990
|
+
*
|
|
991
|
+
* @param orderId - Order ID
|
|
992
|
+
* @returns Order details with full information
|
|
993
|
+
*
|
|
994
|
+
* @example
|
|
995
|
+
* ```typescript
|
|
996
|
+
* const order = await client.getMerchantOrder("ord_123");
|
|
997
|
+
* console.log(order.order.status, order.order.items);
|
|
998
|
+
* ```
|
|
999
|
+
*/
|
|
1000
|
+
async getMerchantOrder(orderId) {
|
|
1001
|
+
return this.get(`/api/marketplace/merchant/orders/${orderId}`);
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Update order status
|
|
1005
|
+
*
|
|
1006
|
+
* @param orderId - Order ID
|
|
1007
|
+
* @param request - Status update request
|
|
1008
|
+
* @returns Updated order
|
|
1009
|
+
*
|
|
1010
|
+
* @example
|
|
1011
|
+
* ```typescript
|
|
1012
|
+
* // Accept order
|
|
1013
|
+
* await client.updateOrderStatus("ord_123", {
|
|
1014
|
+
* status: "MERCHANT_ACCEPTED"
|
|
1015
|
+
* });
|
|
1016
|
+
*
|
|
1017
|
+
* // Mark as shipped
|
|
1018
|
+
* await client.updateOrderStatus("ord_123", {
|
|
1019
|
+
* status: "SHIPPED",
|
|
1020
|
+
* tracking: {
|
|
1021
|
+
* trackingNumber: "1Z999AA10123456784",
|
|
1022
|
+
* carrier: "UPS"
|
|
1023
|
+
* }
|
|
1024
|
+
* });
|
|
1025
|
+
* ```
|
|
1026
|
+
*/
|
|
1027
|
+
async updateOrderStatus(orderId, request) {
|
|
1028
|
+
return this.patch(`/api/marketplace/merchant/orders/${orderId}`, request);
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Create a custom order event
|
|
1032
|
+
*
|
|
1033
|
+
* @param orderId - Order ID
|
|
1034
|
+
* @param request - Event data
|
|
1035
|
+
* @returns Created event
|
|
1036
|
+
*
|
|
1037
|
+
* @example
|
|
1038
|
+
* ```typescript
|
|
1039
|
+
* await client.createOrderEvent("ord_123", {
|
|
1040
|
+
* eventType: "CUSTOM",
|
|
1041
|
+
* title: "Package delayed",
|
|
1042
|
+
* description: "Shipment delayed due to weather"
|
|
1043
|
+
* });
|
|
1044
|
+
* ```
|
|
1045
|
+
*/
|
|
1046
|
+
async createOrderEvent(orderId, request) {
|
|
1047
|
+
return this.post(`/api/marketplace/merchant/orders/${orderId}/events`, request);
|
|
1048
|
+
}
|
|
1049
|
+
// ============================================================================
|
|
1050
|
+
// Customers Management
|
|
1051
|
+
// ============================================================================
|
|
1052
|
+
/**
|
|
1053
|
+
* List customers with order history and stats
|
|
1054
|
+
*
|
|
1055
|
+
* @param params - Query parameters
|
|
1056
|
+
* @returns Paginated list of customers
|
|
1057
|
+
*
|
|
1058
|
+
* @example
|
|
1059
|
+
* ```typescript
|
|
1060
|
+
* const customers = await client.listCustomers({ limit: 50, offset: 0 });
|
|
1061
|
+
* customers.items.forEach(c => {
|
|
1062
|
+
* console.log(c.username, "Total spent:", c.totalSpent);
|
|
1063
|
+
* });
|
|
1064
|
+
* ```
|
|
1065
|
+
*/
|
|
1066
|
+
async listCustomers(params) {
|
|
1067
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
1068
|
+
return this.get(`/api/marketplace/merchant/customers${queryString}`);
|
|
1069
|
+
}
|
|
1070
|
+
// ============================================================================
|
|
1071
|
+
// Coupons & Discounts Management
|
|
1072
|
+
// ============================================================================
|
|
1073
|
+
/**
|
|
1074
|
+
* List merchant's coupons
|
|
1075
|
+
*
|
|
1076
|
+
* @returns List of coupons with stats
|
|
1077
|
+
*
|
|
1078
|
+
* @example
|
|
1079
|
+
* ```typescript
|
|
1080
|
+
* const result = await client.listCoupons();
|
|
1081
|
+
* console.log("Total coupons:", result.stats.total);
|
|
1082
|
+
* console.log("Active:", result.stats.active);
|
|
1083
|
+
* ```
|
|
1084
|
+
*/
|
|
1085
|
+
async listCoupons() {
|
|
1086
|
+
return this.get("/api/marketplace/merchant/coupons");
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Create a coupon
|
|
1090
|
+
*
|
|
1091
|
+
* @param request - Coupon data
|
|
1092
|
+
* @returns Created coupon
|
|
1093
|
+
*
|
|
1094
|
+
* @example
|
|
1095
|
+
* ```typescript
|
|
1096
|
+
* const coupon = await client.createCoupon({
|
|
1097
|
+
* code: "SAVE20",
|
|
1098
|
+
* discountType: "PERCENTAGE",
|
|
1099
|
+
* discountValue: 20,
|
|
1100
|
+
* startsAt: "2025-01-01T00:00:00Z",
|
|
1101
|
+
* expiresAt: "2025-12-31T23:59:59Z",
|
|
1102
|
+
* maxUses: 100
|
|
1103
|
+
* });
|
|
1104
|
+
* ```
|
|
1105
|
+
*/
|
|
1106
|
+
async createCoupon(request) {
|
|
1107
|
+
return this.post("/api/marketplace/merchant/coupons", request);
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* Get coupon details with usage history
|
|
1111
|
+
*
|
|
1112
|
+
* @param couponId - Coupon ID
|
|
1113
|
+
* @returns Coupon with usages
|
|
1114
|
+
*
|
|
1115
|
+
* @example
|
|
1116
|
+
* ```typescript
|
|
1117
|
+
* const coupon = await client.getCoupon("coupon_123");
|
|
1118
|
+
* console.log("Used", coupon.coupon.usedCount, "times");
|
|
1119
|
+
* ```
|
|
1120
|
+
*/
|
|
1121
|
+
async getCoupon(couponId) {
|
|
1122
|
+
return this.get(`/api/marketplace/merchant/coupons/${couponId}`);
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Update a coupon
|
|
1126
|
+
*
|
|
1127
|
+
* @param couponId - Coupon ID
|
|
1128
|
+
* @param request - Updated coupon data
|
|
1129
|
+
* @returns Updated coupon
|
|
1130
|
+
*
|
|
1131
|
+
* @example
|
|
1132
|
+
* ```typescript
|
|
1133
|
+
* await client.updateCoupon("coupon_123", {
|
|
1134
|
+
* isActive: false
|
|
1135
|
+
* });
|
|
1136
|
+
* ```
|
|
1137
|
+
*/
|
|
1138
|
+
async updateCoupon(couponId, request) {
|
|
1139
|
+
return this.put(`/api/marketplace/merchant/coupons/${couponId}`, request);
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Delete a coupon
|
|
1143
|
+
*
|
|
1144
|
+
* @param couponId - Coupon ID
|
|
1145
|
+
* @returns Success response
|
|
1146
|
+
*
|
|
1147
|
+
* @example
|
|
1148
|
+
* ```typescript
|
|
1149
|
+
* await client.deleteCoupon("coupon_123");
|
|
1150
|
+
* ```
|
|
1151
|
+
*/
|
|
1152
|
+
async deleteCoupon(couponId) {
|
|
1153
|
+
return this.delete(`/api/marketplace/merchant/coupons/${couponId}`);
|
|
1154
|
+
}
|
|
1155
|
+
// ============================================================================
|
|
1156
|
+
// Shipping & Fulfillment
|
|
1157
|
+
// ============================================================================
|
|
1158
|
+
/**
|
|
1159
|
+
* List shipping methods
|
|
1160
|
+
*
|
|
1161
|
+
* @returns List of shipping methods
|
|
1162
|
+
*
|
|
1163
|
+
* @example
|
|
1164
|
+
* ```typescript
|
|
1165
|
+
* const methods = await client.listShippingMethods();
|
|
1166
|
+
* ```
|
|
1167
|
+
*/
|
|
1168
|
+
async listShippingMethods() {
|
|
1169
|
+
return this.get("/api/marketplace/merchant/shipping/methods");
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Create a shipping method
|
|
1173
|
+
*
|
|
1174
|
+
* @param request - Shipping method data
|
|
1175
|
+
* @returns Created method
|
|
1176
|
+
*
|
|
1177
|
+
* @example
|
|
1178
|
+
* ```typescript
|
|
1179
|
+
* const method = await client.createShippingMethod({
|
|
1180
|
+
* name: "Standard Shipping",
|
|
1181
|
+
* carrier: "USPS",
|
|
1182
|
+
* estimatedDays: "3-5 business days",
|
|
1183
|
+
* flatRate: 5.99
|
|
1184
|
+
* });
|
|
1185
|
+
* ```
|
|
1186
|
+
*/
|
|
1187
|
+
async createShippingMethod(request) {
|
|
1188
|
+
return this.post("/api/marketplace/merchant/shipping/methods", request);
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* Update a shipping method
|
|
1192
|
+
*
|
|
1193
|
+
* @param methodId - Method ID
|
|
1194
|
+
* @param request - Updated method data
|
|
1195
|
+
* @returns Updated method
|
|
1196
|
+
*
|
|
1197
|
+
* @example
|
|
1198
|
+
* ```typescript
|
|
1199
|
+
* await client.updateShippingMethod("method_123", {
|
|
1200
|
+
* flatRate: 6.99
|
|
1201
|
+
* });
|
|
1202
|
+
* ```
|
|
1203
|
+
*/
|
|
1204
|
+
async updateShippingMethod(methodId, request) {
|
|
1205
|
+
return this.put(`/api/marketplace/merchant/shipping/methods/${methodId}`, request);
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* Delete a shipping method
|
|
1209
|
+
*
|
|
1210
|
+
* @param methodId - Method ID
|
|
1211
|
+
* @returns Success response
|
|
1212
|
+
*
|
|
1213
|
+
* @example
|
|
1214
|
+
* ```typescript
|
|
1215
|
+
* await client.deleteShippingMethod("method_123");
|
|
1216
|
+
* ```
|
|
1217
|
+
*/
|
|
1218
|
+
async deleteShippingMethod(methodId) {
|
|
1219
|
+
return this.delete(`/api/marketplace/merchant/shipping/methods/${methodId}`);
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* List shipments
|
|
1223
|
+
*
|
|
1224
|
+
* @returns List of shipments for merchant's orders
|
|
1225
|
+
*
|
|
1226
|
+
* @example
|
|
1227
|
+
* ```typescript
|
|
1228
|
+
* const shipments = await client.listShipments();
|
|
1229
|
+
* ```
|
|
1230
|
+
*/
|
|
1231
|
+
async listShipments() {
|
|
1232
|
+
return this.get("/api/marketplace/merchant/shipping/shipments");
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Update shipment status and tracking
|
|
1236
|
+
*
|
|
1237
|
+
* @param shipmentId - Shipment ID
|
|
1238
|
+
* @param request - Updated shipment data
|
|
1239
|
+
* @returns Updated shipment
|
|
1240
|
+
*
|
|
1241
|
+
* @example
|
|
1242
|
+
* ```typescript
|
|
1243
|
+
* await client.updateShipment("ship_123", {
|
|
1244
|
+
* status: "SHIPPED",
|
|
1245
|
+
* trackingNumber: "1Z999AA10123456784",
|
|
1246
|
+
* carrier: "UPS"
|
|
1247
|
+
* });
|
|
1248
|
+
* ```
|
|
1249
|
+
*/
|
|
1250
|
+
async updateShipment(shipmentId, request) {
|
|
1251
|
+
return this.patch(`/api/marketplace/merchant/shipping/shipments/${shipmentId}`, request);
|
|
1252
|
+
}
|
|
1253
|
+
// ============================================================================
|
|
1254
|
+
// Returns & Refunds
|
|
1255
|
+
// ============================================================================
|
|
1256
|
+
/**
|
|
1257
|
+
* List returns
|
|
1258
|
+
*
|
|
1259
|
+
* @returns List of returns for merchant's orders
|
|
1260
|
+
*
|
|
1261
|
+
* @example
|
|
1262
|
+
* ```typescript
|
|
1263
|
+
* const returns = await client.listReturns();
|
|
1264
|
+
* ```
|
|
1265
|
+
*/
|
|
1266
|
+
async listReturns() {
|
|
1267
|
+
return this.get("/api/marketplace/merchant/returns");
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Approve a return request
|
|
1271
|
+
*
|
|
1272
|
+
* @param returnId - Return ID
|
|
1273
|
+
* @returns Updated return
|
|
1274
|
+
*
|
|
1275
|
+
* @example
|
|
1276
|
+
* ```typescript
|
|
1277
|
+
* await client.approveReturn("return_123");
|
|
1278
|
+
* ```
|
|
1279
|
+
*/
|
|
1280
|
+
async approveReturn(returnId) {
|
|
1281
|
+
return this.post(`/api/marketplace/merchant/returns/${returnId}/approve`);
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* Reject a return request
|
|
1285
|
+
*
|
|
1286
|
+
* @param returnId - Return ID
|
|
1287
|
+
* @returns Updated return
|
|
1288
|
+
*
|
|
1289
|
+
* @example
|
|
1290
|
+
* ```typescript
|
|
1291
|
+
* await client.rejectReturn("return_123");
|
|
1292
|
+
* ```
|
|
1293
|
+
*/
|
|
1294
|
+
async rejectReturn(returnId) {
|
|
1295
|
+
return this.post(`/api/marketplace/merchant/returns/${returnId}/reject`);
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Mark return as received
|
|
1299
|
+
*
|
|
1300
|
+
* @param returnId - Return ID
|
|
1301
|
+
* @returns Updated return
|
|
1302
|
+
*
|
|
1303
|
+
* @example
|
|
1304
|
+
* ```typescript
|
|
1305
|
+
* await client.markReturnReceived("return_123");
|
|
1306
|
+
* ```
|
|
1307
|
+
*/
|
|
1308
|
+
async markReturnReceived(returnId) {
|
|
1309
|
+
return this.post(`/api/marketplace/merchant/returns/${returnId}/received`);
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Process refund for return
|
|
1313
|
+
*
|
|
1314
|
+
* @param returnId - Return ID
|
|
1315
|
+
* @returns Updated return
|
|
1316
|
+
*
|
|
1317
|
+
* @example
|
|
1318
|
+
* ```typescript
|
|
1319
|
+
* await client.processRefund("return_123");
|
|
1320
|
+
* ```
|
|
1321
|
+
*/
|
|
1322
|
+
async processRefund(returnId) {
|
|
1323
|
+
return this.post(`/api/marketplace/merchant/returns/${returnId}/refunded`);
|
|
1324
|
+
}
|
|
1325
|
+
// ============================================================================
|
|
1326
|
+
// Reviews Management
|
|
1327
|
+
// ============================================================================
|
|
1328
|
+
/**
|
|
1329
|
+
* List reviews for merchant's products
|
|
1330
|
+
*
|
|
1331
|
+
* @returns List of reviews
|
|
1332
|
+
*
|
|
1333
|
+
* @example
|
|
1334
|
+
* ```typescript
|
|
1335
|
+
* const reviews = await client.listMerchantReviews();
|
|
1336
|
+
* ```
|
|
1337
|
+
*/
|
|
1338
|
+
async listMerchantReviews() {
|
|
1339
|
+
return this.get("/api/marketplace/merchant/reviews");
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Respond to a review
|
|
1343
|
+
*
|
|
1344
|
+
* @param reviewId - Review ID
|
|
1345
|
+
* @param request - Response data
|
|
1346
|
+
* @returns Updated review
|
|
1347
|
+
*
|
|
1348
|
+
* @example
|
|
1349
|
+
* ```typescript
|
|
1350
|
+
* await client.respondToReview("review_123", {
|
|
1351
|
+
* merchantResponse: "Thank you for your feedback!"
|
|
1352
|
+
* });
|
|
1353
|
+
* ```
|
|
1354
|
+
*/
|
|
1355
|
+
async respondToReview(reviewId, request) {
|
|
1356
|
+
return this.post(`/api/marketplace/merchant/reviews/${reviewId}/respond`, request);
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Flag a review as inappropriate
|
|
1360
|
+
*
|
|
1361
|
+
* @param reviewId - Review ID
|
|
1362
|
+
* @returns Updated review
|
|
1363
|
+
*
|
|
1364
|
+
* @example
|
|
1365
|
+
* ```typescript
|
|
1366
|
+
* await client.flagReview("review_123");
|
|
1367
|
+
* ```
|
|
1368
|
+
*/
|
|
1369
|
+
async flagReview(reviewId) {
|
|
1370
|
+
return this.post(`/api/marketplace/merchant/reviews/${reviewId}/flag`);
|
|
1371
|
+
}
|
|
1372
|
+
// ============================================================================
|
|
1373
|
+
// Messages
|
|
1374
|
+
// ============================================================================
|
|
1375
|
+
/**
|
|
1376
|
+
* List messages/conversations
|
|
1377
|
+
*
|
|
1378
|
+
* @returns List of conversations grouped by order
|
|
1379
|
+
*
|
|
1380
|
+
* @example
|
|
1381
|
+
* ```typescript
|
|
1382
|
+
* const messages = await client.listMessages();
|
|
1383
|
+
* console.log("Unread:", messages.stats.unread);
|
|
1384
|
+
* ```
|
|
1385
|
+
*/
|
|
1386
|
+
async listMessages() {
|
|
1387
|
+
return this.get("/api/marketplace/merchant/messages");
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Send a message to customer
|
|
1391
|
+
*
|
|
1392
|
+
* @param request - Message data
|
|
1393
|
+
* @returns Sent message
|
|
1394
|
+
*
|
|
1395
|
+
* @example
|
|
1396
|
+
* ```typescript
|
|
1397
|
+
* await client.sendMessage({
|
|
1398
|
+
* orderId: "ord_123",
|
|
1399
|
+
* recipientId: "user_456",
|
|
1400
|
+
* message: "Your order has been shipped!"
|
|
1401
|
+
* });
|
|
1402
|
+
* ```
|
|
1403
|
+
*/
|
|
1404
|
+
async sendMessage(request) {
|
|
1405
|
+
return this.post("/api/marketplace/merchant/messages/send", request);
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Mark message as read
|
|
1409
|
+
*
|
|
1410
|
+
* @param messageId - Message ID
|
|
1411
|
+
* @returns Updated message
|
|
1412
|
+
*
|
|
1413
|
+
* @example
|
|
1414
|
+
* ```typescript
|
|
1415
|
+
* await client.markMessageRead("msg_123");
|
|
1416
|
+
* ```
|
|
1417
|
+
*/
|
|
1418
|
+
async markMessageRead(messageId) {
|
|
1419
|
+
return this.patch(`/api/marketplace/merchant/messages/${messageId}/read`);
|
|
1420
|
+
}
|
|
1421
|
+
// ============================================================================
|
|
1422
|
+
// Media Library
|
|
1423
|
+
// ============================================================================
|
|
1424
|
+
/**
|
|
1425
|
+
* List media assets
|
|
1426
|
+
*
|
|
1427
|
+
* @param params - Query parameters
|
|
1428
|
+
* @returns Paginated list of media assets
|
|
1429
|
+
*
|
|
1430
|
+
* @example
|
|
1431
|
+
* ```typescript
|
|
1432
|
+
* const media = await client.listMediaAssets({ limit: 50, offset: 0 });
|
|
1433
|
+
* ```
|
|
1434
|
+
*/
|
|
1435
|
+
async listMediaAssets(params) {
|
|
1436
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
1437
|
+
return this.get(`/api/marketplace/merchant/media${queryString}`);
|
|
1438
|
+
}
|
|
1439
|
+
/**
|
|
1440
|
+
* Upload a media asset
|
|
1441
|
+
*
|
|
1442
|
+
* @param file - File to upload (max 10MB, images only)
|
|
1443
|
+
* @returns Uploaded asset
|
|
1444
|
+
*
|
|
1445
|
+
* @example
|
|
1446
|
+
* ```typescript
|
|
1447
|
+
* const formData = new FormData();
|
|
1448
|
+
* formData.append("file", imageFile);
|
|
1449
|
+
*
|
|
1450
|
+
* const asset = await client.uploadMediaAsset(formData);
|
|
1451
|
+
* console.log("Uploaded:", asset.asset.blobUrl);
|
|
1452
|
+
* ```
|
|
1453
|
+
*/
|
|
1454
|
+
async uploadMediaAsset(formData) {
|
|
1455
|
+
return this.post("/api/marketplace/merchant/media/upload", formData, {
|
|
1456
|
+
headers: { "Content-Type": "multipart/form-data" }
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
/**
|
|
1460
|
+
* Delete a media asset
|
|
1461
|
+
*
|
|
1462
|
+
* @param assetId - Asset ID
|
|
1463
|
+
* @returns Success response
|
|
1464
|
+
*
|
|
1465
|
+
* @example
|
|
1466
|
+
* ```typescript
|
|
1467
|
+
* await client.deleteMediaAsset("asset_123");
|
|
1468
|
+
* ```
|
|
1469
|
+
*/
|
|
1470
|
+
async deleteMediaAsset(assetId) {
|
|
1471
|
+
return this.delete(`/api/marketplace/merchant/media?id=${assetId}`);
|
|
1472
|
+
}
|
|
1473
|
+
// ============================================================================
|
|
1474
|
+
// Banners
|
|
1475
|
+
// ============================================================================
|
|
1476
|
+
/**
|
|
1477
|
+
* List merchant's banners
|
|
1478
|
+
*
|
|
1479
|
+
* @returns List of banners
|
|
1480
|
+
*
|
|
1481
|
+
* @example
|
|
1482
|
+
* ```typescript
|
|
1483
|
+
* const banners = await client.listMerchantBanners();
|
|
1484
|
+
* ```
|
|
1485
|
+
*/
|
|
1486
|
+
async listMerchantBanners() {
|
|
1487
|
+
return this.get("/api/marketplace/merchant/banners");
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Create a promotional banner
|
|
1491
|
+
*
|
|
1492
|
+
* @param request - Banner data
|
|
1493
|
+
* @returns Created banner
|
|
1494
|
+
*
|
|
1495
|
+
* @example
|
|
1496
|
+
* ```typescript
|
|
1497
|
+
* const banner = await client.createBanner({
|
|
1498
|
+
* title: "Summer Sale",
|
|
1499
|
+
* imageUrl: "https://...",
|
|
1500
|
+
* linkUrl: "/products?category=summer",
|
|
1501
|
+
* ctaText: "Shop Now",
|
|
1502
|
+
* priority: 10
|
|
1503
|
+
* });
|
|
1504
|
+
* ```
|
|
1505
|
+
*/
|
|
1506
|
+
async createBanner(request) {
|
|
1507
|
+
return this.post("/api/marketplace/merchant/banners", request);
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Get banner details
|
|
1511
|
+
*
|
|
1512
|
+
* @param bannerId - Banner ID
|
|
1513
|
+
* @returns Banner details
|
|
1514
|
+
*
|
|
1515
|
+
* @example
|
|
1516
|
+
* ```typescript
|
|
1517
|
+
* const banner = await client.getBanner("banner_123");
|
|
1518
|
+
* ```
|
|
1519
|
+
*/
|
|
1520
|
+
async getBanner(bannerId) {
|
|
1521
|
+
return this.get(`/api/marketplace/merchant/banners/${bannerId}`);
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* Update a banner
|
|
1525
|
+
*
|
|
1526
|
+
* @param bannerId - Banner ID
|
|
1527
|
+
* @param request - Updated banner data
|
|
1528
|
+
* @returns Updated banner
|
|
1529
|
+
*
|
|
1530
|
+
* @example
|
|
1531
|
+
* ```typescript
|
|
1532
|
+
* await client.updateBanner("banner_123", {
|
|
1533
|
+
* isActive: false
|
|
1534
|
+
* });
|
|
1535
|
+
* ```
|
|
1536
|
+
*/
|
|
1537
|
+
async updateBanner(bannerId, request) {
|
|
1538
|
+
return this.put(`/api/marketplace/merchant/banners/${bannerId}`, request);
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Delete a banner
|
|
1542
|
+
*
|
|
1543
|
+
* @param bannerId - Banner ID
|
|
1544
|
+
* @returns Success response
|
|
1545
|
+
*
|
|
1546
|
+
* @example
|
|
1547
|
+
* ```typescript
|
|
1548
|
+
* await client.deleteBanner("banner_123");
|
|
1549
|
+
* ```
|
|
1550
|
+
*/
|
|
1551
|
+
async deleteBanner(bannerId) {
|
|
1552
|
+
return this.delete(`/api/marketplace/merchant/banners/${bannerId}`);
|
|
1553
|
+
}
|
|
1554
|
+
// ============================================================================
|
|
1555
|
+
// Analytics
|
|
1556
|
+
// ============================================================================
|
|
1557
|
+
/**
|
|
1558
|
+
* Get merchant analytics
|
|
1559
|
+
*
|
|
1560
|
+
* @param params - Query parameters
|
|
1561
|
+
* @returns Analytics data with overview, charts, and insights
|
|
1562
|
+
*
|
|
1563
|
+
* @example
|
|
1564
|
+
* ```typescript
|
|
1565
|
+
* const analytics = await client.getAnalytics({ range: "30days" });
|
|
1566
|
+
* console.log("Revenue:", analytics.overview.totalRevenue);
|
|
1567
|
+
* console.log("Orders:", analytics.overview.totalOrders);
|
|
1568
|
+
* ```
|
|
1569
|
+
*/
|
|
1570
|
+
async getAnalytics(params) {
|
|
1571
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
1572
|
+
return this.get(`/api/marketplace/merchant/analytics${queryString}`);
|
|
1573
|
+
}
|
|
1574
|
+
// ============================================================================
|
|
1575
|
+
// Inventory
|
|
1576
|
+
// ============================================================================
|
|
1577
|
+
/**
|
|
1578
|
+
* Get inventory audit log
|
|
1579
|
+
*
|
|
1580
|
+
* @returns Recent inventory audit entries (last 500)
|
|
1581
|
+
*
|
|
1582
|
+
* @example
|
|
1583
|
+
* ```typescript
|
|
1584
|
+
* const audit = await client.getInventoryAudit();
|
|
1585
|
+
* audit.entries.forEach(e => {
|
|
1586
|
+
* console.log(e.action, e.product.title, e.changeAmount);
|
|
1587
|
+
* });
|
|
1588
|
+
* ```
|
|
1589
|
+
*/
|
|
1590
|
+
async getInventoryAudit() {
|
|
1591
|
+
return this.get("/api/marketplace/merchant/inventory/audit");
|
|
1592
|
+
}
|
|
1593
|
+
// ============================================================================
|
|
1594
|
+
// Tax Management
|
|
1595
|
+
// ============================================================================
|
|
1596
|
+
/**
|
|
1597
|
+
* Get tax settings
|
|
1598
|
+
*
|
|
1599
|
+
* @returns Tax settings
|
|
1600
|
+
*
|
|
1601
|
+
* @example
|
|
1602
|
+
* ```typescript
|
|
1603
|
+
* const settings = await client.getTaxSettings();
|
|
1604
|
+
* console.log("Tax enabled:", settings.settings.taxEnabled);
|
|
1605
|
+
* ```
|
|
1606
|
+
*/
|
|
1607
|
+
async getTaxSettings() {
|
|
1608
|
+
return this.get("/api/marketplace/merchant/tax-settings");
|
|
1609
|
+
}
|
|
1610
|
+
/**
|
|
1611
|
+
* Update tax settings
|
|
1612
|
+
*
|
|
1613
|
+
* @param request - Updated settings
|
|
1614
|
+
* @returns Updated tax settings
|
|
1615
|
+
*
|
|
1616
|
+
* @example
|
|
1617
|
+
* ```typescript
|
|
1618
|
+
* await client.updateTaxSettings({
|
|
1619
|
+
* taxEnabled: true,
|
|
1620
|
+
* pricesIncludeTax: false,
|
|
1621
|
+
* defaultTaxBehavior: "CHARGE"
|
|
1622
|
+
* });
|
|
1623
|
+
* ```
|
|
1624
|
+
*/
|
|
1625
|
+
async updateTaxSettings(request) {
|
|
1626
|
+
return this.put("/api/marketplace/merchant/tax-settings", request);
|
|
1627
|
+
}
|
|
1628
|
+
/**
|
|
1629
|
+
* List tax rules
|
|
1630
|
+
*
|
|
1631
|
+
* @returns List of tax rules
|
|
1632
|
+
*
|
|
1633
|
+
* @example
|
|
1634
|
+
* ```typescript
|
|
1635
|
+
* const rules = await client.listTaxRules();
|
|
1636
|
+
* ```
|
|
1637
|
+
*/
|
|
1638
|
+
async listTaxRules() {
|
|
1639
|
+
return this.get("/api/marketplace/merchant/tax-rules");
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Create a tax rule
|
|
1643
|
+
*
|
|
1644
|
+
* @param request - Tax rule data
|
|
1645
|
+
* @returns Created tax rule
|
|
1646
|
+
*
|
|
1647
|
+
* @example
|
|
1648
|
+
* ```typescript
|
|
1649
|
+
* const rule = await client.createTaxRule({
|
|
1650
|
+
* country: "US",
|
|
1651
|
+
* region: "NY",
|
|
1652
|
+
* taxType: "SALES_TAX",
|
|
1653
|
+
* taxName: "NY Sales Tax",
|
|
1654
|
+
* taxRate: 8.875
|
|
1655
|
+
* });
|
|
1656
|
+
* ```
|
|
1657
|
+
*/
|
|
1658
|
+
async createTaxRule(request) {
|
|
1659
|
+
return this.post("/api/marketplace/merchant/tax-rules", request);
|
|
1660
|
+
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Get tax rule details
|
|
1663
|
+
*
|
|
1664
|
+
* @param ruleId - Rule ID
|
|
1665
|
+
* @returns Tax rule details
|
|
1666
|
+
*
|
|
1667
|
+
* @example
|
|
1668
|
+
* ```typescript
|
|
1669
|
+
* const rule = await client.getTaxRule("rule_123");
|
|
1670
|
+
* ```
|
|
1671
|
+
*/
|
|
1672
|
+
async getTaxRule(ruleId) {
|
|
1673
|
+
return this.get(`/api/marketplace/merchant/tax-rules/${ruleId}`);
|
|
1674
|
+
}
|
|
1675
|
+
/**
|
|
1676
|
+
* Update a tax rule
|
|
1677
|
+
*
|
|
1678
|
+
* @param ruleId - Rule ID
|
|
1679
|
+
* @param request - Updated rule data
|
|
1680
|
+
* @returns Updated tax rule
|
|
1681
|
+
*
|
|
1682
|
+
* @example
|
|
1683
|
+
* ```typescript
|
|
1684
|
+
* await client.updateTaxRule("rule_123", {
|
|
1685
|
+
* taxRate: 9.0
|
|
1686
|
+
* });
|
|
1687
|
+
* ```
|
|
1688
|
+
*/
|
|
1689
|
+
async updateTaxRule(ruleId, request) {
|
|
1690
|
+
return this.put(`/api/marketplace/merchant/tax-rules/${ruleId}`, request);
|
|
1691
|
+
}
|
|
1692
|
+
/**
|
|
1693
|
+
* Delete a tax rule
|
|
1694
|
+
*
|
|
1695
|
+
* @param ruleId - Rule ID
|
|
1696
|
+
* @returns Success response
|
|
1697
|
+
*
|
|
1698
|
+
* @example
|
|
1699
|
+
* ```typescript
|
|
1700
|
+
* await client.deleteTaxRule("rule_123");
|
|
1701
|
+
* ```
|
|
1702
|
+
*/
|
|
1703
|
+
async deleteTaxRule(ruleId) {
|
|
1704
|
+
return this.delete(`/api/marketplace/merchant/tax-rules/${ruleId}`);
|
|
1705
|
+
}
|
|
1706
|
+
/**
|
|
1707
|
+
* List tax nexus locations
|
|
1708
|
+
*
|
|
1709
|
+
* @returns List of nexus locations
|
|
1710
|
+
*
|
|
1711
|
+
* @example
|
|
1712
|
+
* ```typescript
|
|
1713
|
+
* const nexus = await client.listTaxNexus();
|
|
1714
|
+
* ```
|
|
1715
|
+
*/
|
|
1716
|
+
async listTaxNexus() {
|
|
1717
|
+
return this.get("/api/marketplace/merchant/tax-nexus");
|
|
1718
|
+
}
|
|
1719
|
+
/**
|
|
1720
|
+
* Add a tax nexus location
|
|
1721
|
+
*
|
|
1722
|
+
* @param request - Nexus data
|
|
1723
|
+
* @returns Created nexus
|
|
1724
|
+
*
|
|
1725
|
+
* @example
|
|
1726
|
+
* ```typescript
|
|
1727
|
+
* const nexus = await client.createTaxNexus({
|
|
1728
|
+
* country: "US",
|
|
1729
|
+
* region: "CA",
|
|
1730
|
+
* registrationId: "123456789"
|
|
1731
|
+
* });
|
|
1732
|
+
* ```
|
|
1733
|
+
*/
|
|
1734
|
+
async createTaxNexus(request) {
|
|
1735
|
+
return this.post("/api/marketplace/merchant/tax-nexus", request);
|
|
1736
|
+
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Update a tax nexus location
|
|
1739
|
+
*
|
|
1740
|
+
* @param nexusId - Nexus ID
|
|
1741
|
+
* @param request - Updated nexus data
|
|
1742
|
+
* @returns Updated nexus
|
|
1743
|
+
*
|
|
1744
|
+
* @example
|
|
1745
|
+
* ```typescript
|
|
1746
|
+
* await client.updateTaxNexus("nexus_123", {
|
|
1747
|
+
* registrationId: "987654321"
|
|
1748
|
+
* });
|
|
1749
|
+
* ```
|
|
1750
|
+
*/
|
|
1751
|
+
async updateTaxNexus(nexusId, request) {
|
|
1752
|
+
return this.put(`/api/marketplace/merchant/tax-nexus/${nexusId}`, request);
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* Delete a tax nexus location
|
|
1756
|
+
*
|
|
1757
|
+
* @param nexusId - Nexus ID
|
|
1758
|
+
* @returns Success response
|
|
1759
|
+
*
|
|
1760
|
+
* @example
|
|
1761
|
+
* ```typescript
|
|
1762
|
+
* await client.deleteTaxNexus("nexus_123");
|
|
1763
|
+
* ```
|
|
1764
|
+
*/
|
|
1765
|
+
async deleteTaxNexus(nexusId) {
|
|
1766
|
+
return this.delete(`/api/marketplace/merchant/tax-nexus/${nexusId}`);
|
|
1767
|
+
}
|
|
1768
|
+
/**
|
|
1769
|
+
* List tax reports
|
|
1770
|
+
*
|
|
1771
|
+
* @param params - Query parameters
|
|
1772
|
+
* @returns Paginated list of tax reports
|
|
1773
|
+
*
|
|
1774
|
+
* @example
|
|
1775
|
+
* ```typescript
|
|
1776
|
+
* const reports = await client.listTaxReports({ limit: 20, offset: 0 });
|
|
1777
|
+
*
|
|
1778
|
+
* // Get summary for a specific year
|
|
1779
|
+
* const summary = await client.listTaxReports({ year: 2025 });
|
|
1780
|
+
* ```
|
|
1781
|
+
*/
|
|
1782
|
+
async listTaxReports(params) {
|
|
1783
|
+
const queryString = params ? buildQueryString(params) : "";
|
|
1784
|
+
return this.get(`/api/marketplace/merchant/tax-reports${queryString}`);
|
|
1785
|
+
}
|
|
1786
|
+
/**
|
|
1787
|
+
* Generate a tax report
|
|
1788
|
+
*
|
|
1789
|
+
* @param request - Report generation request
|
|
1790
|
+
* @returns Generated report
|
|
1791
|
+
*
|
|
1792
|
+
* @example
|
|
1793
|
+
* ```typescript
|
|
1794
|
+
* const report = await client.generateTaxReport({
|
|
1795
|
+
* periodType: "MONTHLY",
|
|
1796
|
+
* year: 2025,
|
|
1797
|
+
* period: 1 // January
|
|
1798
|
+
* });
|
|
1799
|
+
* ```
|
|
1800
|
+
*/
|
|
1801
|
+
async generateTaxReport(request) {
|
|
1802
|
+
return this.post("/api/marketplace/merchant/tax-reports/generate", request);
|
|
1803
|
+
}
|
|
1804
|
+
/**
|
|
1805
|
+
* Get tax report details
|
|
1806
|
+
*
|
|
1807
|
+
* @param reportId - Report ID
|
|
1808
|
+
* @returns Report with detailed records
|
|
1809
|
+
*
|
|
1810
|
+
* @example
|
|
1811
|
+
* ```typescript
|
|
1812
|
+
* const report = await client.getTaxReport("report_123");
|
|
1813
|
+
* console.log("Total tax:", report.report.totalTax);
|
|
1814
|
+
* ```
|
|
1815
|
+
*/
|
|
1816
|
+
async getTaxReport(reportId) {
|
|
1817
|
+
return this.get(`/api/marketplace/merchant/tax-reports/${reportId}`);
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Update tax report status
|
|
1821
|
+
*
|
|
1822
|
+
* @param reportId - Report ID
|
|
1823
|
+
* @param request - Status update
|
|
1824
|
+
* @returns Updated report
|
|
1825
|
+
*
|
|
1826
|
+
* @example
|
|
1827
|
+
* ```typescript
|
|
1828
|
+
* await client.updateTaxReportStatus("report_123", {
|
|
1829
|
+
* status: "FINALIZED"
|
|
1830
|
+
* });
|
|
1831
|
+
* ```
|
|
1832
|
+
*/
|
|
1833
|
+
async updateTaxReportStatus(reportId, request) {
|
|
1834
|
+
return this.put(`/api/marketplace/merchant/tax-reports/${reportId}`, request);
|
|
1835
|
+
}
|
|
1836
|
+
/**
|
|
1837
|
+
* Export tax report as CSV
|
|
1838
|
+
*
|
|
1839
|
+
* @param reportId - Report ID
|
|
1840
|
+
* @returns CSV file data
|
|
1841
|
+
*
|
|
1842
|
+
* @example
|
|
1843
|
+
* ```typescript
|
|
1844
|
+
* const csv = await client.exportTaxReport("report_123");
|
|
1845
|
+
* // Save or download the CSV
|
|
1846
|
+
* ```
|
|
1847
|
+
*/
|
|
1848
|
+
async exportTaxReport(reportId) {
|
|
1849
|
+
return this.get(`/api/marketplace/merchant/tax-reports/${reportId}/export`);
|
|
1850
|
+
}
|
|
1851
|
+
};
|
|
1852
|
+
|
|
1853
|
+
// lib/ecommerce/types/enums.ts
|
|
1854
|
+
var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
|
|
1855
|
+
OrderStatus2["CREATED"] = "CREATED";
|
|
1856
|
+
OrderStatus2["AWAITING_DEPOSIT"] = "AWAITING_DEPOSIT";
|
|
1857
|
+
OrderStatus2["PAYMENT_RESERVED"] = "PAYMENT_RESERVED";
|
|
1858
|
+
OrderStatus2["MERCHANT_ACCEPTED"] = "MERCHANT_ACCEPTED";
|
|
1859
|
+
OrderStatus2["SHIPPED"] = "SHIPPED";
|
|
1860
|
+
OrderStatus2["DELIVERED"] = "DELIVERED";
|
|
1861
|
+
OrderStatus2["CANCELLED"] = "CANCELLED";
|
|
1862
|
+
OrderStatus2["CONFIRMED"] = "CONFIRMED";
|
|
1863
|
+
OrderStatus2["COMPLETED"] = "COMPLETED";
|
|
1864
|
+
return OrderStatus2;
|
|
1865
|
+
})(OrderStatus || {});
|
|
1866
|
+
var PaymentMethod = /* @__PURE__ */ ((PaymentMethod2) => {
|
|
1867
|
+
PaymentMethod2["USDC_ESCROW"] = "USDC_ESCROW";
|
|
1868
|
+
PaymentMethod2["POINTS"] = "POINTS";
|
|
1869
|
+
return PaymentMethod2;
|
|
1870
|
+
})(PaymentMethod || {});
|
|
1871
|
+
var PaymentStatus = /* @__PURE__ */ ((PaymentStatus2) => {
|
|
1872
|
+
PaymentStatus2["PENDING"] = "PENDING";
|
|
1873
|
+
PaymentStatus2["RESERVED"] = "RESERVED";
|
|
1874
|
+
PaymentStatus2["COMPLETED"] = "COMPLETED";
|
|
1875
|
+
PaymentStatus2["FAILED"] = "FAILED";
|
|
1876
|
+
PaymentStatus2["REFUNDED"] = "REFUNDED";
|
|
1877
|
+
return PaymentStatus2;
|
|
1878
|
+
})(PaymentStatus || {});
|
|
1879
|
+
var MerchantStatus = /* @__PURE__ */ ((MerchantStatus2) => {
|
|
1880
|
+
MerchantStatus2["ACTIVE"] = "ACTIVE";
|
|
1881
|
+
MerchantStatus2["SUSPENDED"] = "SUSPENDED";
|
|
1882
|
+
MerchantStatus2["PENDING"] = "PENDING";
|
|
1883
|
+
return MerchantStatus2;
|
|
1884
|
+
})(MerchantStatus || {});
|
|
1885
|
+
var ShipmentStatus = /* @__PURE__ */ ((ShipmentStatus2) => {
|
|
1886
|
+
ShipmentStatus2["PENDING"] = "PENDING";
|
|
1887
|
+
ShipmentStatus2["SHIPPED"] = "SHIPPED";
|
|
1888
|
+
ShipmentStatus2["DELIVERED"] = "DELIVERED";
|
|
1889
|
+
ShipmentStatus2["FAILED"] = "FAILED";
|
|
1890
|
+
return ShipmentStatus2;
|
|
1891
|
+
})(ShipmentStatus || {});
|
|
1892
|
+
var ReturnStatus = /* @__PURE__ */ ((ReturnStatus2) => {
|
|
1893
|
+
ReturnStatus2["REQUESTED"] = "REQUESTED";
|
|
1894
|
+
ReturnStatus2["APPROVED"] = "APPROVED";
|
|
1895
|
+
ReturnStatus2["REJECTED"] = "REJECTED";
|
|
1896
|
+
ReturnStatus2["SHIPPED_BACK"] = "SHIPPED_BACK";
|
|
1897
|
+
ReturnStatus2["RECEIVED"] = "RECEIVED";
|
|
1898
|
+
ReturnStatus2["REFUNDED"] = "REFUNDED";
|
|
1899
|
+
return ReturnStatus2;
|
|
1900
|
+
})(ReturnStatus || {});
|
|
1901
|
+
var ReviewStatus = /* @__PURE__ */ ((ReviewStatus2) => {
|
|
1902
|
+
ReviewStatus2["PENDING"] = "PENDING";
|
|
1903
|
+
ReviewStatus2["RESPONDED"] = "RESPONDED";
|
|
1904
|
+
ReviewStatus2["FLAGGED"] = "FLAGGED";
|
|
1905
|
+
return ReviewStatus2;
|
|
1906
|
+
})(ReviewStatus || {});
|
|
1907
|
+
var DiscountType = /* @__PURE__ */ ((DiscountType2) => {
|
|
1908
|
+
DiscountType2["PERCENTAGE"] = "PERCENTAGE";
|
|
1909
|
+
DiscountType2["FIXED_AMOUNT"] = "FIXED_AMOUNT";
|
|
1910
|
+
DiscountType2["BUY_X_GET_Y"] = "BUY_X_GET_Y";
|
|
1911
|
+
DiscountType2["FREE_SHIPPING"] = "FREE_SHIPPING";
|
|
1912
|
+
return DiscountType2;
|
|
1913
|
+
})(DiscountType || {});
|
|
1914
|
+
var DiscountMethod = /* @__PURE__ */ ((DiscountMethod2) => {
|
|
1915
|
+
DiscountMethod2["CODE"] = "CODE";
|
|
1916
|
+
DiscountMethod2["AUTOMATIC"] = "AUTOMATIC";
|
|
1917
|
+
return DiscountMethod2;
|
|
1918
|
+
})(DiscountMethod || {});
|
|
1919
|
+
var DiscountScope = /* @__PURE__ */ ((DiscountScope2) => {
|
|
1920
|
+
DiscountScope2["ORDER"] = "ORDER";
|
|
1921
|
+
DiscountScope2["PRODUCT"] = "PRODUCT";
|
|
1922
|
+
DiscountScope2["CATEGORY"] = "CATEGORY";
|
|
1923
|
+
DiscountScope2["SHIPPING"] = "SHIPPING";
|
|
1924
|
+
return DiscountScope2;
|
|
1925
|
+
})(DiscountScope || {});
|
|
1926
|
+
var BannerType = /* @__PURE__ */ ((BannerType2) => {
|
|
1927
|
+
BannerType2["HERO"] = "HERO";
|
|
1928
|
+
BannerType2["PROMO"] = "PROMO";
|
|
1929
|
+
BannerType2["FEATURED"] = "FEATURED";
|
|
1930
|
+
return BannerType2;
|
|
1931
|
+
})(BannerType || {});
|
|
1932
|
+
var TaxType = /* @__PURE__ */ ((TaxType2) => {
|
|
1933
|
+
TaxType2["SALES_TAX"] = "SALES_TAX";
|
|
1934
|
+
TaxType2["VAT"] = "VAT";
|
|
1935
|
+
TaxType2["GST"] = "GST";
|
|
1936
|
+
TaxType2["PST"] = "PST";
|
|
1937
|
+
TaxType2["HST"] = "HST";
|
|
1938
|
+
return TaxType2;
|
|
1939
|
+
})(TaxType || {});
|
|
1940
|
+
var TaxBehavior = /* @__PURE__ */ ((TaxBehavior2) => {
|
|
1941
|
+
TaxBehavior2["CHARGE"] = "CHARGE";
|
|
1942
|
+
TaxBehavior2["INCLUSIVE"] = "INCLUSIVE";
|
|
1943
|
+
TaxBehavior2["EXEMPT"] = "EXEMPT";
|
|
1944
|
+
return TaxBehavior2;
|
|
1945
|
+
})(TaxBehavior || {});
|
|
1946
|
+
var TaxReportPeriodType = /* @__PURE__ */ ((TaxReportPeriodType2) => {
|
|
1947
|
+
TaxReportPeriodType2["MONTHLY"] = "MONTHLY";
|
|
1948
|
+
TaxReportPeriodType2["QUARTERLY"] = "QUARTERLY";
|
|
1949
|
+
TaxReportPeriodType2["YEARLY"] = "YEARLY";
|
|
1950
|
+
return TaxReportPeriodType2;
|
|
1951
|
+
})(TaxReportPeriodType || {});
|
|
1952
|
+
var TaxReportStatus = /* @__PURE__ */ ((TaxReportStatus2) => {
|
|
1953
|
+
TaxReportStatus2["DRAFT"] = "DRAFT";
|
|
1954
|
+
TaxReportStatus2["FINALIZED"] = "FINALIZED";
|
|
1955
|
+
TaxReportStatus2["FILED"] = "FILED";
|
|
1956
|
+
return TaxReportStatus2;
|
|
1957
|
+
})(TaxReportStatus || {});
|
|
1958
|
+
var InventoryAuditAction = /* @__PURE__ */ ((InventoryAuditAction2) => {
|
|
1959
|
+
InventoryAuditAction2["CREATED"] = "CREATED";
|
|
1960
|
+
InventoryAuditAction2["UPDATED"] = "UPDATED";
|
|
1961
|
+
InventoryAuditAction2["RESERVED"] = "RESERVED";
|
|
1962
|
+
InventoryAuditAction2["DEDUCTED"] = "DEDUCTED";
|
|
1963
|
+
InventoryAuditAction2["RESTORED"] = "RESTORED";
|
|
1964
|
+
return InventoryAuditAction2;
|
|
1965
|
+
})(InventoryAuditAction || {});
|
|
1966
|
+
var SortOrder = /* @__PURE__ */ ((SortOrder2) => {
|
|
1967
|
+
SortOrder2["ASC"] = "asc";
|
|
1968
|
+
SortOrder2["DESC"] = "desc";
|
|
1969
|
+
return SortOrder2;
|
|
1970
|
+
})(SortOrder || {});
|
|
1971
|
+
var ProductSortBy = /* @__PURE__ */ ((ProductSortBy2) => {
|
|
1972
|
+
ProductSortBy2["DATE_DESC"] = "date_desc";
|
|
1973
|
+
ProductSortBy2["DATE_ASC"] = "date_asc";
|
|
1974
|
+
ProductSortBy2["PRICE_ASC"] = "price_asc";
|
|
1975
|
+
ProductSortBy2["PRICE_DESC"] = "price_desc";
|
|
1976
|
+
ProductSortBy2["POPULAR"] = "popular";
|
|
1977
|
+
ProductSortBy2["FEATURED"] = "featured";
|
|
1978
|
+
return ProductSortBy2;
|
|
1979
|
+
})(ProductSortBy || {});
|
|
1980
|
+
var ReviewSortBy = /* @__PURE__ */ ((ReviewSortBy2) => {
|
|
1981
|
+
ReviewSortBy2["NEWEST"] = "newest";
|
|
1982
|
+
ReviewSortBy2["HIGHEST"] = "highest";
|
|
1983
|
+
ReviewSortBy2["LOWEST"] = "lowest";
|
|
1984
|
+
return ReviewSortBy2;
|
|
1985
|
+
})(ReviewSortBy || {});
|
|
1986
|
+
|
|
1987
|
+
export { BannerType, BaseEcommerceClient, CustomerEcommerceClient, DiscountMethod, DiscountScope, DiscountType, EcommerceApiError, InventoryAuditAction, MerchantEcommerceClient, MerchantStatus, OrderStatus, PaymentMethod, PaymentStatus, ProductSortBy, ReturnStatus, ReviewSortBy, ReviewStatus, ShipmentStatus, SortOrder, TaxBehavior, TaxReportPeriodType, TaxReportStatus, TaxType, buildQueryString, calculateDiscountAmount, calculateFinalPrice, formatPrice, getBackoffDelay, isRetryableError, isValidAddress, isValidEmail, parseError, retryWithBackoff, sleep, truncateAddress };
|