sound-tank 1.3.1 → 2.1.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/.env.example +3 -1
- package/.vscode/settings.json +3 -0
- package/CHANGELOG.md +28 -0
- package/README.md +44 -35
- package/dist/index.d.mts +252 -102
- package/dist/index.d.ts +252 -102
- package/dist/index.js +527 -201
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +526 -200
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -12
- package/.prtrc.json +0 -13
- package/prt.json +0 -10
package/.env.example
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# sound-tank
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f3a8df0: Add `streamAllMy()` to `ListingsResource` and `streamAllMyListings()` method. Returns an `AsyncGenerator<Listing>` that yields listings one at a time as paginated responses arrive, rather than waiting for all pages to complete.
|
|
8
|
+
|
|
9
|
+
Also adds the underlying `paginateStream<T>()` utility in `pagination.ts` for streaming any paginated endpoint.
|
|
10
|
+
|
|
11
|
+
## 2.0.0
|
|
12
|
+
|
|
13
|
+
### Major Changes
|
|
14
|
+
|
|
15
|
+
- ce70040: Resource class architecture (v2.0 breaking change)
|
|
16
|
+
- Add `ListingsResource`, `OrdersResource` classes (`reverb.listings.getMy`, etc.)
|
|
17
|
+
- Remove flat methods from `Reverb` class; rename `getArbitraryEndpoint` -> `_getArbitraryEndpoint`
|
|
18
|
+
- Migrate all methods from axios -> `HttpClient` abstraction
|
|
19
|
+
- Remove dual `(reverb, options)` pattern; all methods now `(client, config, options)`
|
|
20
|
+
- Move `PaginatedReverbResponse` to `types.ts`
|
|
21
|
+
- Remove `getMyRoot`
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- ce70040: Add `NegotiationsResource` (`reverb.negotiations.*`)
|
|
26
|
+
- `getNegotiations(options)` — fetch active offers grouped by listing (`/my/listings/negotiations`)
|
|
27
|
+
- `getNegotiation(offerId)` — fetch a single offer by id (`/my/negotiations/:id`)
|
|
28
|
+
- Add `Negotiation`, `NegotiationOffer`, `NegotiationPriceDisplay`, `NegotiationLinks` types to `types.ts`
|
|
29
|
+
- Add `ListingWithNegotiations` type (`Listing & { negotiations: Negotiation[] }`)
|
|
30
|
+
|
|
3
31
|
## 1.3.1
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ pnpm add sound-tank
|
|
|
32
32
|
import Reverb from 'sound-tank';
|
|
33
33
|
|
|
34
34
|
const reverb = new Reverb({ apiKey: process.env.REVERB_API_KEY });
|
|
35
|
-
const { data } = await reverb.
|
|
35
|
+
const { data } = await reverb.listings.getMy({ perPage: 10, state: 'live' });
|
|
36
36
|
|
|
37
37
|
data.listings.forEach(listing => {
|
|
38
38
|
console.log(`${listing.title}: ${listing.price.display}`);
|
|
@@ -56,11 +56,11 @@ data.listings.forEach(listing => {
|
|
|
56
56
|
- [Getting Started](#getting-started)
|
|
57
57
|
- [Configuration](#configuration)
|
|
58
58
|
- [API Methods](#api-methods)
|
|
59
|
-
- [
|
|
60
|
-
- [
|
|
61
|
-
- [
|
|
62
|
-
- [
|
|
63
|
-
- [
|
|
59
|
+
- [listings.getMy](#listingsgetmyoptions)
|
|
60
|
+
- [listings.getAllMy](#listingsgetallmyoptions)
|
|
61
|
+
- [listings.getOne](#listingsgetoneoptions)
|
|
62
|
+
- [orders.getMy](#ordersgetmyoptions)
|
|
63
|
+
- [_getArbitraryEndpoint](#_getarbitraryendpointurl-params)
|
|
64
64
|
- [TypeScript Usage](#typescript-usage)
|
|
65
65
|
- [Advanced Features](#advanced-features)
|
|
66
66
|
- [Examples](#examples)
|
|
@@ -118,7 +118,7 @@ const reverb = new Reverb({
|
|
|
118
118
|
### Fetch Your Listings
|
|
119
119
|
|
|
120
120
|
```typescript
|
|
121
|
-
const response = await reverb.
|
|
121
|
+
const response = await reverb.listings.getMy({
|
|
122
122
|
perPage: 25,
|
|
123
123
|
page: 1,
|
|
124
124
|
state: 'live',
|
|
@@ -132,7 +132,7 @@ console.log(response.data.listings);
|
|
|
132
132
|
|
|
133
133
|
```typescript
|
|
134
134
|
try {
|
|
135
|
-
const response = await reverb.
|
|
135
|
+
const response = await reverb.listings.getMy({ state: 'live' });
|
|
136
136
|
console.log(`Found ${response.data.listings.length} listings`);
|
|
137
137
|
} catch (error) {
|
|
138
138
|
console.error('Failed to fetch listings:', error.message);
|
|
@@ -167,7 +167,7 @@ These changes automatically update the internal headers and configuration for su
|
|
|
167
167
|
|
|
168
168
|
## API Methods
|
|
169
169
|
|
|
170
|
-
###
|
|
170
|
+
### listings.getMy(options?)
|
|
171
171
|
|
|
172
172
|
Fetch a paginated list of your listings.
|
|
173
173
|
|
|
@@ -181,7 +181,7 @@ Fetch a paginated list of your listings.
|
|
|
181
181
|
|
|
182
182
|
**Example:**
|
|
183
183
|
```typescript
|
|
184
|
-
const response = await reverb.
|
|
184
|
+
const response = await reverb.listings.getMy({
|
|
185
185
|
perPage: 50,
|
|
186
186
|
page: 1,
|
|
187
187
|
state: 'live',
|
|
@@ -194,7 +194,7 @@ console.log(`Page 1: ${listings.length} listings`);
|
|
|
194
194
|
|
|
195
195
|
---
|
|
196
196
|
|
|
197
|
-
###
|
|
197
|
+
### listings.getAllMy(options?)
|
|
198
198
|
|
|
199
199
|
Automatically fetches **all** listings across all pages using automatic pagination.
|
|
200
200
|
|
|
@@ -206,7 +206,7 @@ Automatically fetches **all** listings across all pages using automatic paginati
|
|
|
206
206
|
|
|
207
207
|
**Example:**
|
|
208
208
|
```typescript
|
|
209
|
-
const response = await reverb.
|
|
209
|
+
const response = await reverb.listings.getAllMy({ state: 'live' });
|
|
210
210
|
const allListings = response.data; // All listings from all pages
|
|
211
211
|
|
|
212
212
|
console.log(`Total listings: ${allListings.length}`);
|
|
@@ -216,7 +216,7 @@ console.log(`Total listings: ${allListings.length}`);
|
|
|
216
216
|
|
|
217
217
|
---
|
|
218
218
|
|
|
219
|
-
###
|
|
219
|
+
### listings.getOne(options)
|
|
220
220
|
|
|
221
221
|
Fetch a single listing by ID.
|
|
222
222
|
|
|
@@ -227,7 +227,7 @@ Fetch a single listing by ID.
|
|
|
227
227
|
|
|
228
228
|
**Example:**
|
|
229
229
|
```typescript
|
|
230
|
-
const response = await reverb.
|
|
230
|
+
const response = await reverb.listings.getOne({ id: '12345' });
|
|
231
231
|
const listing = response.data;
|
|
232
232
|
|
|
233
233
|
console.log(`${listing.title} - ${listing.price.display}`);
|
|
@@ -236,7 +236,7 @@ console.log(`Condition: ${listing.condition.displayName}`);
|
|
|
236
236
|
|
|
237
237
|
---
|
|
238
238
|
|
|
239
|
-
###
|
|
239
|
+
### orders.getMy(options?)
|
|
240
240
|
|
|
241
241
|
Fetch your orders with pagination.
|
|
242
242
|
|
|
@@ -248,7 +248,7 @@ Fetch your orders with pagination.
|
|
|
248
248
|
|
|
249
249
|
**Example:**
|
|
250
250
|
```typescript
|
|
251
|
-
const response = await reverb.
|
|
251
|
+
const response = await reverb.orders.getMy({
|
|
252
252
|
page: 1,
|
|
253
253
|
perPage: 25
|
|
254
254
|
});
|
|
@@ -261,9 +261,9 @@ orders.forEach(order => {
|
|
|
261
261
|
|
|
262
262
|
---
|
|
263
263
|
|
|
264
|
-
###
|
|
264
|
+
### _getArbitraryEndpoint(url, params?)
|
|
265
265
|
|
|
266
|
-
|
|
266
|
+
Escape hatch to call any Reverb endpoint not yet wrapped by a resource. The `_` prefix indicates this is not part of the stable public API but is intentionally supported.
|
|
267
267
|
|
|
268
268
|
**Parameters:**
|
|
269
269
|
- `url: string` - Endpoint URL (absolute or relative to root endpoint)
|
|
@@ -274,14 +274,10 @@ Make requests to any Reverb API endpoint not explicitly covered by other methods
|
|
|
274
274
|
**Example:**
|
|
275
275
|
```typescript
|
|
276
276
|
// Fetch categories
|
|
277
|
-
const categories = await reverb.
|
|
278
|
-
url: '/categories/flat'
|
|
279
|
-
});
|
|
277
|
+
const categories = await reverb._getArbitraryEndpoint('/categories/flat');
|
|
280
278
|
|
|
281
279
|
// Fetch listing conditions
|
|
282
|
-
const conditions = await reverb.
|
|
283
|
-
url: '/listing_conditions'
|
|
284
|
-
});
|
|
280
|
+
const conditions = await reverb._getArbitraryEndpoint('/listing_conditions');
|
|
285
281
|
|
|
286
282
|
console.log(categories.data);
|
|
287
283
|
```
|
|
@@ -308,7 +304,7 @@ import Reverb, {
|
|
|
308
304
|
### Working with Typed Responses
|
|
309
305
|
|
|
310
306
|
```typescript
|
|
311
|
-
const response = await reverb.
|
|
307
|
+
const response = await reverb.listings.getMy();
|
|
312
308
|
const listings: Listing[] = response.data.listings;
|
|
313
309
|
|
|
314
310
|
listings.forEach((listing: Listing) => {
|
|
@@ -361,13 +357,13 @@ let allListings = [];
|
|
|
361
357
|
let response;
|
|
362
358
|
|
|
363
359
|
do {
|
|
364
|
-
response = await reverb.
|
|
360
|
+
response = await reverb.listings.getMy({ page, perPage: 50 });
|
|
365
361
|
allListings = allListings.concat(response.data.listings);
|
|
366
362
|
page++;
|
|
367
363
|
} while (response.data.listings.length === 50);
|
|
368
364
|
|
|
369
365
|
// Or use the built-in helper
|
|
370
|
-
const autoResponse = await reverb.
|
|
366
|
+
const autoResponse = await reverb.listings.getAllMy();
|
|
371
367
|
const listings = autoResponse.data; // Same result, simpler code
|
|
372
368
|
```
|
|
373
369
|
|
|
@@ -405,7 +401,7 @@ console.log(headers['X-Display-Currency']); // 'USD'
|
|
|
405
401
|
```typescript
|
|
406
402
|
const reverb = new Reverb({ apiKey: process.env.REVERB_API_KEY });
|
|
407
403
|
|
|
408
|
-
const response = await reverb.
|
|
404
|
+
const response = await reverb.listings.getAllMy({ query: 'guitar' });
|
|
409
405
|
const affordable = response.data.filter(listing =>
|
|
410
406
|
listing.price.amount_cents < 100000 // $1000 = 100,000 cents
|
|
411
407
|
);
|
|
@@ -423,7 +419,7 @@ const reverb = new Reverb({ apiKey: process.env.REVERB_API_KEY });
|
|
|
423
419
|
|
|
424
420
|
// Get prices in USD
|
|
425
421
|
reverb.displayCurrency = 'USD';
|
|
426
|
-
const usdResponse = await reverb.
|
|
422
|
+
const usdResponse = await reverb.listings.getMy({ perPage: 5 });
|
|
427
423
|
console.log('USD Prices:');
|
|
428
424
|
usdResponse.data.listings.forEach(l =>
|
|
429
425
|
console.log(` ${l.title}: ${l.price.display}`)
|
|
@@ -431,7 +427,7 @@ usdResponse.data.listings.forEach(l =>
|
|
|
431
427
|
|
|
432
428
|
// Switch to EUR
|
|
433
429
|
reverb.displayCurrency = 'EUR';
|
|
434
|
-
const eurResponse = await reverb.
|
|
430
|
+
const eurResponse = await reverb.listings.getMy({ perPage: 5 });
|
|
435
431
|
console.log('\nEUR Prices:');
|
|
436
432
|
eurResponse.data.listings.forEach(l =>
|
|
437
433
|
console.log(` ${l.title}: ${l.price.display}`)
|
|
@@ -441,7 +437,7 @@ eurResponse.data.listings.forEach(l =>
|
|
|
441
437
|
### Export Listings to CSV
|
|
442
438
|
|
|
443
439
|
```typescript
|
|
444
|
-
const response = await reverb.
|
|
440
|
+
const response = await reverb.listings.getAllMy({ state: 'live' });
|
|
445
441
|
|
|
446
442
|
const csvHeader = 'ID,Title,Price,Currency,Condition,Year,State\n';
|
|
447
443
|
const csvRows = response.data.map(listing =>
|
|
@@ -457,7 +453,7 @@ console.log(csv);
|
|
|
457
453
|
|
|
458
454
|
```typescript
|
|
459
455
|
// Search for specific items
|
|
460
|
-
const response = await reverb.
|
|
456
|
+
const response = await reverb.listings.getMy({
|
|
461
457
|
query: 'Les Paul',
|
|
462
458
|
state: 'live',
|
|
463
459
|
perPage: 100
|
|
@@ -514,9 +510,12 @@ sound-tank/
|
|
|
514
510
|
│ │ ├── AxiosHttpClient.ts # Axios implementation
|
|
515
511
|
│ │ └── MockHttpClient.ts # Mock for testing
|
|
516
512
|
│ ├── methods/
|
|
517
|
-
│ │ ├── listings/ # Listing operations
|
|
518
|
-
│ │ └── orders/ # Order operations
|
|
519
|
-
│
|
|
513
|
+
│ │ ├── listings/ # Listing operations (pure functions)
|
|
514
|
+
│ │ └── orders/ # Order operations (pure functions)
|
|
515
|
+
│ ├── resources/
|
|
516
|
+
│ │ ├── ListingsResource.ts # Listings resource class
|
|
517
|
+
│ │ └── OrdersResource.ts # Orders resource class
|
|
518
|
+
│ └── utils/ # Helper utilities (pagination, url/query builders, logger)
|
|
520
519
|
├── tests/ # Test files
|
|
521
520
|
├── dist/ # Build output (git-ignored)
|
|
522
521
|
├── package.json
|
|
@@ -525,6 +524,16 @@ sound-tank/
|
|
|
525
524
|
└── vite.config.mts # Test configuration
|
|
526
525
|
```
|
|
527
526
|
|
|
527
|
+
### Debugging
|
|
528
|
+
|
|
529
|
+
Set `SOUNDTANK_LOG_LEVEL` to enable SDK logging:
|
|
530
|
+
|
|
531
|
+
```bash
|
|
532
|
+
SOUNDTANK_LOG_LEVEL=DEBUG yarn dev
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
Valid values: `ERROR | WARN | INFO | DEBUG | TRACE`. Silent by default.
|
|
536
|
+
|
|
528
537
|
### Available Scripts
|
|
529
538
|
|
|
530
539
|
| Command | Description |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
interface HttpRequestConfig {
|
|
2
|
+
headers?: Record<string, string | undefined>;
|
|
3
|
+
params?: Record<string, string | number | boolean | undefined | null>;
|
|
4
|
+
/**
|
|
5
|
+
* Request timeout in milliseconds
|
|
6
|
+
*/
|
|
7
|
+
timeout?: number;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* HTTP response structure compatible with AxiosResponse
|
|
12
|
+
*/
|
|
13
|
+
interface HttpResponse<T = any> {
|
|
14
|
+
data: T;
|
|
15
|
+
status: number;
|
|
16
|
+
statusText: string;
|
|
17
|
+
headers: Record<string, string>;
|
|
18
|
+
config: HttpRequestConfig;
|
|
19
|
+
request?: any;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Abstract HTTP client interface for making API requests.
|
|
24
|
+
* This abstraction allows for different implementations (e.g., axios, fetch, mock)
|
|
25
|
+
* while keeping the business logic decoupled from the HTTP layer.
|
|
26
|
+
*/
|
|
27
|
+
interface HttpClient {
|
|
28
|
+
/**
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const response = await client.get<User>('/api/users/123', {
|
|
32
|
+
* headers: { 'Authorization': 'Bearer token' }
|
|
33
|
+
* });
|
|
34
|
+
* console.log(response.data);
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
get<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
38
|
+
/**
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const response = await client.post<User>('/api/users', {
|
|
42
|
+
* name: 'John Doe',
|
|
43
|
+
* email: 'john@example.com'
|
|
44
|
+
* }, {
|
|
45
|
+
* headers: { 'Authorization': 'Bearer token' }
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
post<T = any>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
50
|
+
/**
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const response = await client.put<User>('/api/users/123', {
|
|
54
|
+
* name: 'Jane Doe'
|
|
55
|
+
* }, {
|
|
56
|
+
* headers: { 'Authorization': 'Bearer token' }
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
put<T = any>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
61
|
+
/**
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const response = await client.delete('/api/users/123', {
|
|
65
|
+
* headers: { 'Authorization': 'Bearer token' }
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
delete<T = any>(url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
70
|
+
/**
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const response = await client.patch<User>('/api/users/123', {
|
|
74
|
+
* email: 'newemail@example.com'
|
|
75
|
+
* }, {
|
|
76
|
+
* headers: { 'Authorization': 'Bearer token' }
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
patch<T = any>(url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface ReverbConfig {
|
|
84
|
+
rootEndpoint: RootEndpoint;
|
|
85
|
+
apiKey: ApiKey;
|
|
86
|
+
headers: AuthReverbHeaders;
|
|
87
|
+
version: ApiVersion;
|
|
88
|
+
locale: Locale;
|
|
89
|
+
displayCurrency: DisplayCurrency;
|
|
90
|
+
shippingRegion?: ShippingRegion;
|
|
91
|
+
}
|
|
3
92
|
|
|
4
93
|
declare enum LinkMethods {
|
|
5
94
|
PUT = "PUT",
|
|
@@ -107,6 +196,48 @@ type Listing = {
|
|
|
107
196
|
}[];
|
|
108
197
|
_links: ListingLinks;
|
|
109
198
|
};
|
|
199
|
+
type ListingPostBody = {
|
|
200
|
+
make: string;
|
|
201
|
+
model: string;
|
|
202
|
+
categories: {
|
|
203
|
+
uuid: string;
|
|
204
|
+
}[];
|
|
205
|
+
condition: {
|
|
206
|
+
uuid: string;
|
|
207
|
+
};
|
|
208
|
+
photos: string[];
|
|
209
|
+
videos: [
|
|
210
|
+
{
|
|
211
|
+
link: string;
|
|
212
|
+
}
|
|
213
|
+
];
|
|
214
|
+
description: string;
|
|
215
|
+
finish: string;
|
|
216
|
+
price: {
|
|
217
|
+
amount: string;
|
|
218
|
+
currency: string;
|
|
219
|
+
};
|
|
220
|
+
title: string;
|
|
221
|
+
year: string;
|
|
222
|
+
sku: string;
|
|
223
|
+
upc: string;
|
|
224
|
+
upc_does_not_apply: `${boolean}`;
|
|
225
|
+
has_inventory: boolean;
|
|
226
|
+
inventory: number;
|
|
227
|
+
offers_enabled: boolean;
|
|
228
|
+
handmade: boolean;
|
|
229
|
+
shipping_profile_id?: string;
|
|
230
|
+
shipping?: {
|
|
231
|
+
rates: {
|
|
232
|
+
rate: {
|
|
233
|
+
amount: string;
|
|
234
|
+
currency: string;
|
|
235
|
+
};
|
|
236
|
+
region_code: string;
|
|
237
|
+
}[];
|
|
238
|
+
local: boolean;
|
|
239
|
+
};
|
|
240
|
+
};
|
|
110
241
|
declare enum OrderStatusOptions {
|
|
111
242
|
Unpaid = "unpaid",
|
|
112
243
|
Paid = "paid",
|
|
@@ -236,42 +367,72 @@ type ShippingAddress = {
|
|
|
236
367
|
self: Link;
|
|
237
368
|
};
|
|
238
369
|
};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
370
|
+
type PaginatedReverbResponse<T> = T & {
|
|
371
|
+
total: number;
|
|
372
|
+
current_page: number;
|
|
373
|
+
total_pages: number;
|
|
374
|
+
_links: {
|
|
375
|
+
next?: Link;
|
|
376
|
+
prev?: Link;
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
type NegotiationPriceDisplay = {
|
|
380
|
+
original: Price;
|
|
381
|
+
display: Price;
|
|
382
|
+
};
|
|
383
|
+
type NegotiationOffer = {
|
|
384
|
+
created_at: string;
|
|
385
|
+
message: string;
|
|
386
|
+
price: NegotiationPriceDisplay;
|
|
387
|
+
shipping_price: NegotiationPriceDisplay;
|
|
388
|
+
total_price: NegotiationPriceDisplay;
|
|
389
|
+
initiated_by_name: string;
|
|
390
|
+
initiated_by_shop_name: string;
|
|
391
|
+
initiated_by_me: boolean;
|
|
392
|
+
initiator_type: 'seller' | 'buyer' | Exclude<string, 'seller' | 'buyer'>;
|
|
393
|
+
};
|
|
394
|
+
type NegotiationLinks = {
|
|
395
|
+
listing: Link;
|
|
396
|
+
self: Link;
|
|
397
|
+
counter: Link;
|
|
398
|
+
accept: Link;
|
|
399
|
+
decline: Link;
|
|
400
|
+
};
|
|
401
|
+
type Negotiation = {
|
|
402
|
+
id: number | string;
|
|
403
|
+
state: 'active' | 'accepted' | 'declined' | 'expired' | Exclude<string, 'active' | 'accepted' | 'declined' | 'expired'>;
|
|
404
|
+
offers_count: number;
|
|
405
|
+
expires_at: string;
|
|
406
|
+
created_at: string;
|
|
407
|
+
updated_at: string;
|
|
408
|
+
buyer_name: string;
|
|
409
|
+
buyer_id: number | string;
|
|
410
|
+
seller_name: string;
|
|
411
|
+
shop_id?: number | string;
|
|
412
|
+
shop_name: string;
|
|
413
|
+
other_party_name: string;
|
|
414
|
+
other_party?: {
|
|
415
|
+
_links: {
|
|
416
|
+
avatar: Link;
|
|
417
|
+
};
|
|
418
|
+
profile_slug: string | null;
|
|
419
|
+
};
|
|
420
|
+
actionable: boolean;
|
|
421
|
+
you_last_initiated?: boolean;
|
|
422
|
+
can_ship_to_buyer: boolean;
|
|
423
|
+
buyer_shipping_region_code: string;
|
|
424
|
+
buyer_address: ShippingAddress & {
|
|
425
|
+
uuid?: string;
|
|
426
|
+
};
|
|
427
|
+
last_offered_price: NegotiationPriceDisplay;
|
|
428
|
+
last_offered_shipping: NegotiationPriceDisplay;
|
|
429
|
+
last_offered_total: NegotiationPriceDisplay;
|
|
430
|
+
offers?: NegotiationOffer[];
|
|
431
|
+
_links: NegotiationLinks;
|
|
432
|
+
};
|
|
433
|
+
type ListingWithNegotiations = Listing & {
|
|
434
|
+
negotiations: Negotiation[];
|
|
435
|
+
};
|
|
275
436
|
|
|
276
437
|
interface GetMyListingsOptions {
|
|
277
438
|
page?: number;
|
|
@@ -287,19 +448,50 @@ interface GetOneListingOptions {
|
|
|
287
448
|
id: string;
|
|
288
449
|
}
|
|
289
450
|
|
|
451
|
+
declare class ListingsResource {
|
|
452
|
+
private getClient;
|
|
453
|
+
private getConfig;
|
|
454
|
+
constructor(getClient: () => HttpClient, getConfig: () => ReverbConfig);
|
|
455
|
+
getMy(options?: GetMyListingsOptions): Promise<HttpResponse<PaginatedReverbResponse<{
|
|
456
|
+
listings: Listing[];
|
|
457
|
+
}>>>;
|
|
458
|
+
getOne(options: GetOneListingOptions): Promise<HttpResponse<Listing>>;
|
|
459
|
+
getPhotos(options: GetOneListingOptions): Promise<string[]>;
|
|
460
|
+
getAllMy(options?: GetAllMyListingsOptions): Promise<HttpResponse<Listing[]>>;
|
|
461
|
+
streamAllMy(options?: GetAllMyListingsOptions): AsyncGenerator<Listing, any, any>;
|
|
462
|
+
create(body: ListingPostBody): Promise<HttpResponse<Listing>>;
|
|
463
|
+
}
|
|
464
|
+
|
|
290
465
|
interface GetMyOrdersOptions {
|
|
291
466
|
page?: number;
|
|
292
467
|
}
|
|
293
468
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
469
|
+
declare class OrdersResource {
|
|
470
|
+
private getClient;
|
|
471
|
+
private getConfig;
|
|
472
|
+
constructor(getClient: () => HttpClient, getConfig: () => ReverbConfig);
|
|
473
|
+
getMy(options?: GetMyOrdersOptions): Promise<HttpResponse<PaginatedReverbResponse<{
|
|
474
|
+
orders: Order[];
|
|
475
|
+
}>>>;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
interface GetNegotiationsOptions {
|
|
479
|
+
page?: number;
|
|
480
|
+
perPage?: number;
|
|
481
|
+
status?: 'active' | 'active_for_seller' | 'all';
|
|
482
|
+
negotiation_type?: 'standard' | 'auto_push_offer';
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
declare class NegotiationsResource {
|
|
486
|
+
private getClient;
|
|
487
|
+
private getConfig;
|
|
488
|
+
constructor(getClient: () => HttpClient, getConfig: () => ReverbConfig);
|
|
489
|
+
getNegotiations(options: GetNegotiationsOptions): Promise<HttpResponse<PaginatedReverbResponse<{
|
|
490
|
+
listings: ListingWithNegotiations[];
|
|
491
|
+
}>>>;
|
|
492
|
+
getNegotiation(offerId: number): Promise<HttpResponse<Negotiation>>;
|
|
493
|
+
}
|
|
494
|
+
|
|
303
495
|
type GetArbitraryEndpointOptions = {
|
|
304
496
|
url: string;
|
|
305
497
|
params?: {
|
|
@@ -322,14 +514,15 @@ interface ReverbOptions {
|
|
|
322
514
|
shippingRegion?: ShippingRegion | undefined;
|
|
323
515
|
locale?: Locale | undefined;
|
|
324
516
|
}
|
|
325
|
-
type ReverbHeaders =
|
|
326
|
-
|
|
327
|
-
|
|
517
|
+
type ReverbHeaders = {
|
|
518
|
+
"Content-Type": string;
|
|
519
|
+
"Accept-Version": ApiVersion;
|
|
328
520
|
Accept: string;
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
521
|
+
"Accept-Language": Locale;
|
|
522
|
+
"X-Display-Currency": DisplayCurrency;
|
|
523
|
+
"X-Shipping-Region"?: ShippingRegion | undefined;
|
|
524
|
+
"User-Agent"?: string;
|
|
525
|
+
[key: string]: string | undefined;
|
|
333
526
|
};
|
|
334
527
|
interface AuthReverbHeaders extends ReverbHeaders {
|
|
335
528
|
Authorization: `Bearer ${ApiKey}`;
|
|
@@ -345,16 +538,11 @@ declare class Reverb {
|
|
|
345
538
|
private _locale;
|
|
346
539
|
private _config;
|
|
347
540
|
private _httpClient;
|
|
541
|
+
readonly listings: ListingsResource;
|
|
542
|
+
readonly orders: OrdersResource;
|
|
543
|
+
readonly negotiations: NegotiationsResource;
|
|
348
544
|
constructor(options: ReverbOptions);
|
|
349
|
-
/**
|
|
350
|
-
* Updates the headers based on the current state of the Reverb instance.
|
|
351
|
-
* This method is called whenever a property that affects the headers is changed, rather than every time a request is made.
|
|
352
|
-
*/
|
|
353
545
|
private updateHeaders;
|
|
354
|
-
/**
|
|
355
|
-
* Updates the internal config object based on current state.
|
|
356
|
-
* This is called whenever configuration-related properties change.
|
|
357
|
-
*/
|
|
358
546
|
private _updateConfig;
|
|
359
547
|
set locale(locale: Locale);
|
|
360
548
|
get locale(): Locale;
|
|
@@ -367,46 +555,8 @@ declare class Reverb {
|
|
|
367
555
|
get version(): ApiVersion;
|
|
368
556
|
set rootEndpoint(rootEndpoint: RootEndpoint);
|
|
369
557
|
get rootEndpoint(): RootEndpoint;
|
|
370
|
-
/**
|
|
371
|
-
* Gets the current configuration object.
|
|
372
|
-
* This provides access to all configuration values in a single object,
|
|
373
|
-
* useful for passing to methods without requiring the entire Reverb instance.
|
|
374
|
-
*/
|
|
375
558
|
get config(): ReverbConfig;
|
|
376
|
-
|
|
377
|
-
* Retrieves the current user's listings.
|
|
378
|
-
* @param {methods.GetMyListingsOptions} options - Optional parameters for the request.
|
|
379
|
-
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves to the user's listings. Structured as an axios response
|
|
380
|
-
*/
|
|
381
|
-
getMyListings(options?: GetMyListingsOptions): Promise<axios.AxiosResponse<PaginatedReverbResponse<{
|
|
382
|
-
listings: Listing[];
|
|
383
|
-
}>, any, {}>>;
|
|
384
|
-
/**
|
|
385
|
-
* Retrieves the orders for the current user.
|
|
386
|
-
* @param {methods.GetMyOrdersOptions} options - An optional object containing options for the request.
|
|
387
|
-
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ orders: Order[] }>>>} A Promise that resolves with the user's orders. Structured as an axios response
|
|
388
|
-
*/
|
|
389
|
-
getMyOrders(options?: GetMyOrdersOptions): Promise<axios.AxiosResponse<PaginatedReverbResponse<{
|
|
390
|
-
orders: Order[];
|
|
391
|
-
}>, any, {}>>;
|
|
392
|
-
/**
|
|
393
|
-
* Retrieves an arbitrary endpoint using the provided options.
|
|
394
|
-
* @param {methods.GetArbitraryEndpointOptions} options - The options to use when retrieving the endpoint.
|
|
395
|
-
* @returns {Promise<AxiosResponse<unknown>>} A Promise that resolves with the retrieved endpoint. Structured as an axios response
|
|
396
|
-
*/
|
|
397
|
-
getArbitraryEndpoint(options: GetArbitraryEndpointOptions): Promise<axios.AxiosResponse<any, any, {}>>;
|
|
398
|
-
/**
|
|
399
|
-
* Retrieves a single listing based on the provided options.
|
|
400
|
-
* @param {methods.GetOneListingOptions} options - The options to use when retrieving the listing.
|
|
401
|
-
* @returns {Promise<AxiosResponse<Listing>>} A Promise that resolves with the retrieved listing.
|
|
402
|
-
*/
|
|
403
|
-
getOneListing(options: GetOneListingOptions): Promise<axios.AxiosResponse<Listing, any, {}>>;
|
|
404
|
-
/**
|
|
405
|
-
* Retrieves all listings associated with the current user.
|
|
406
|
-
* @param {methods.GetAllMyListingsOptions} options - An optional object containing options for the request.
|
|
407
|
-
* @returns {Promise<AxiosResponse<PaginatedReverbResponse<{ listings: Listing[] }>>>} A Promise that resolves with an array of listings.
|
|
408
|
-
*/
|
|
409
|
-
getAllMyListings(options?: GetAllMyListingsOptions): Promise<axios.AxiosResponse<Listing[], any, {}>>;
|
|
559
|
+
_getArbitraryEndpoint<T = any>(url: string, params?: GetArbitraryEndpointOptions["params"]): Promise<HttpResponse<T>>;
|
|
410
560
|
}
|
|
411
561
|
|
|
412
|
-
export { type ApiKey, type ApiVersion, type AuthReverbHeaders, type DisplayCurrency, type Locale, type ReverbHeaders, type ReverbOptions, type RootEndpoint, type ShippingRegion, Reverb as default };
|
|
562
|
+
export { type ApiKey, type ApiVersion, type AuthReverbHeaders, type DisplayCurrency, ListingsResource, type Locale, OrdersResource, type ReverbHeaders, type ReverbOptions, type RootEndpoint, type ShippingRegion, Reverb as default };
|