sound-tank 1.0.0 → 1.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/CHANGELOG.md +13 -0
- package/README.md +31 -13
- package/bun.lockb +0 -0
- package/dist/index.d.mts +315 -0
- package/dist/index.d.ts +143 -1
- package/dist/index.js +109 -94
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +104 -57
- package/dist/index.mjs.map +1 -0
- package/package.json +14 -10
- package/prettier.config.mjs +10 -0
- package/tsup.config.ts +17 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# sound-tank
|
|
2
|
+
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 13e1148: Add getAllListings, better testing, remove a few bad options that were assumed but aren't respected by Reverb
|
|
8
|
+
|
|
9
|
+
## 1.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- additional typing, expose more methods
|
package/README.md
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
Sound Tank
|
|
3
|
+
</h1>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<p align="center">
|
|
6
|
+
A library to interface with <a href="https://www.reverb.com/" target="_blank">Reverb's</a> API programmatically.
|
|
7
|
+
</p>
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
<p align="center">
|
|
10
|
+
To get started, just run <code>npm install sound-tank</code> in your project's directory, or <code>yarn add sound-tank</code> if you prefer Yarn.
|
|
11
|
+
</p>
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- Add a NPM token to your github environment variables as "NPM_TOKEN"
|
|
11
|
-
- Delete this README.md and replace it with your own
|
|
12
|
-
- Update the package.json with your own information
|
|
13
|
-
- Update the LICENSE file with your own information
|
|
13
|
+
<h2>
|
|
14
|
+
Example Usage
|
|
15
|
+
</h2>
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
```typescript
|
|
18
|
+
import Reverb from 'sound-tank';
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
const { REVERB_API_KEY } = process.env;
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
(async () => {
|
|
23
|
+
const reverb = new Reverb({ apiKey: REVERB_API_KEY });
|
|
24
|
+
|
|
25
|
+
const response = await reverb.getMyListings({
|
|
26
|
+
perPage: 10,
|
|
27
|
+
page: 1,
|
|
28
|
+
state: 'all',
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const { listings } = response.data;
|
|
32
|
+
|
|
33
|
+
listings.forEach((listing) => {
|
|
34
|
+
console.log(listing.title);
|
|
35
|
+
});
|
|
36
|
+
})();
|
|
37
|
+
```
|
package/bun.lockb
ADDED
|
Binary file
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import * as axios from 'axios';
|
|
2
|
+
import { Axios } from 'axios';
|
|
3
|
+
|
|
4
|
+
type Link = {
|
|
5
|
+
href: string;
|
|
6
|
+
method?: 'PUT' | 'POST' | 'GET' | Exclude<string, 'PUT' | 'POST' | 'GET'>;
|
|
7
|
+
};
|
|
8
|
+
type ShippingRate = {
|
|
9
|
+
region_code: string;
|
|
10
|
+
rate: Price;
|
|
11
|
+
carrier_calculated: boolean;
|
|
12
|
+
regional: boolean;
|
|
13
|
+
destination_postal_code_needed: boolean;
|
|
14
|
+
};
|
|
15
|
+
type ListingStateSlug = 'sold' | 'live' | Exclude<string, 'sold' | 'live'>;
|
|
16
|
+
type ListingState = {
|
|
17
|
+
slug: ListingStateSlug;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
type ListingStats = {
|
|
21
|
+
views: number;
|
|
22
|
+
watches: number;
|
|
23
|
+
};
|
|
24
|
+
type ConditionDisplayName = 'Excellent' | 'New' | 'B-Stock' | 'Very Good' | 'Good' | 'Fair' | 'Poor' | Exclude<string, 'Excellent' | 'New' | 'B-Stock' | 'Very Good' | 'Good' | 'Fair' | 'Poor'>;
|
|
25
|
+
type ListingCondition = {
|
|
26
|
+
uuid: string;
|
|
27
|
+
displayName: ConditionDisplayName;
|
|
28
|
+
};
|
|
29
|
+
type ListingShipping = {
|
|
30
|
+
local: boolean;
|
|
31
|
+
rates: ShippingRate[];
|
|
32
|
+
user_region_rate: ShippingRate;
|
|
33
|
+
initial_offer_rate: ShippingRate;
|
|
34
|
+
};
|
|
35
|
+
type ListingLinks = {
|
|
36
|
+
photo: Link;
|
|
37
|
+
self: Link;
|
|
38
|
+
update: Link;
|
|
39
|
+
end: Link;
|
|
40
|
+
want: Link;
|
|
41
|
+
unwant: Link;
|
|
42
|
+
edit: Link;
|
|
43
|
+
web: Link;
|
|
44
|
+
make_offer: Link;
|
|
45
|
+
cart: Link;
|
|
46
|
+
};
|
|
47
|
+
type Category = {
|
|
48
|
+
uuid: string;
|
|
49
|
+
full_name: string;
|
|
50
|
+
};
|
|
51
|
+
type CurrencyCode = string;
|
|
52
|
+
type CurrencySymbol = '$' | Exclude<string, '$'>;
|
|
53
|
+
type Price = {
|
|
54
|
+
amount: `${number}.${number}` | `${number}`;
|
|
55
|
+
amount_cents: number;
|
|
56
|
+
currency: CurrencyCode;
|
|
57
|
+
symbol: CurrencySymbol;
|
|
58
|
+
display: string;
|
|
59
|
+
tax_included_hint?: string;
|
|
60
|
+
tax_included?: boolean;
|
|
61
|
+
tax_included_rate?: number;
|
|
62
|
+
};
|
|
63
|
+
type PhotoLinks = {
|
|
64
|
+
large_crop: Link;
|
|
65
|
+
small_crop: Link;
|
|
66
|
+
full: Link;
|
|
67
|
+
thumbnail: Link;
|
|
68
|
+
};
|
|
69
|
+
type Listing = {
|
|
70
|
+
id: number | string;
|
|
71
|
+
make: string;
|
|
72
|
+
model: string;
|
|
73
|
+
finish: string;
|
|
74
|
+
year: string;
|
|
75
|
+
title: string;
|
|
76
|
+
created_at: ReturnType<typeof Date.toString>;
|
|
77
|
+
shop_name: string;
|
|
78
|
+
description: string;
|
|
79
|
+
condition: ListingCondition;
|
|
80
|
+
price: Price;
|
|
81
|
+
inventory: number;
|
|
82
|
+
has_inventory: boolean;
|
|
83
|
+
offers_enabled: boolean;
|
|
84
|
+
auction: boolean;
|
|
85
|
+
categories: Category[];
|
|
86
|
+
listing_currency: string;
|
|
87
|
+
published_at: ReturnType<typeof Date.toString>;
|
|
88
|
+
buyer_price: Price;
|
|
89
|
+
seller_price: Price;
|
|
90
|
+
state: ListingState;
|
|
91
|
+
shipping_profile_id: number;
|
|
92
|
+
shipping: ListingShipping;
|
|
93
|
+
stats: ListingStats;
|
|
94
|
+
slug: string;
|
|
95
|
+
photos: {
|
|
96
|
+
_links: PhotoLinks;
|
|
97
|
+
}[];
|
|
98
|
+
_links: ListingLinks;
|
|
99
|
+
};
|
|
100
|
+
type OrderStatus = 'unpaid' | 'paid' | 'awaiting_shipment' | 'shipped' | Exclude<string, 'unpaid' | 'awaiting_shipment' | 'shipped'>;
|
|
101
|
+
type ShippingProvider = 'UPS' | 'USPS' | 'FedEx' | 'DHL Deutschland' | 'DHLExpress' | 'DHLGlobalMail' | 'DHL' | 'Canada Post' | 'CanPar' | 'Royal Mail' | 'PostNL' | 'Australia Post' | 'EMS' | 'La Poste - Colissimo' | 'China Post' | 'GLS' | 'Parcelforce' | 'Purolator' | 'Interlogistica' | 'Correos España' | 'Ukraine Post' | 'DPD Germany' | 'DPD UK' | 'DPD France' | 'Hermes' | 'TNT' | 'Other';
|
|
102
|
+
type OrderTaxResponsibleParty = 'reverb' | Exclude<string, 'reverb'>;
|
|
103
|
+
type OrderShippingMethod = 'shipped' | Exclude<string, 'shipped'>;
|
|
104
|
+
type OrderShipmentStatus = 'in_transit' | Exclude<string, 'in_transit'>;
|
|
105
|
+
type OrderType = 'offer' | Exclude<string, 'offer'>;
|
|
106
|
+
type OrderSource = 'reverb' | Exclude<string, 'reverb'>;
|
|
107
|
+
type Order = {
|
|
108
|
+
amount_product: Price;
|
|
109
|
+
presentment_amount_product: Price;
|
|
110
|
+
amount_product_subtotal: Price;
|
|
111
|
+
presentment_amount_product_subtotal: Price;
|
|
112
|
+
shipping: Price;
|
|
113
|
+
presentment_amount_shipping: Price;
|
|
114
|
+
amount_tax: Price;
|
|
115
|
+
presentment_amount_tax: Price;
|
|
116
|
+
total: Price;
|
|
117
|
+
presentment_amount_total: Price;
|
|
118
|
+
shipping_taxed: boolean;
|
|
119
|
+
buyer_name: string;
|
|
120
|
+
buyer_first_name: string;
|
|
121
|
+
buyer_email: string;
|
|
122
|
+
buyer_last_name: string;
|
|
123
|
+
buyer_id: number | string;
|
|
124
|
+
created_at: ReturnType<typeof Date.toString>;
|
|
125
|
+
order_number: number | string;
|
|
126
|
+
tax_rate: number;
|
|
127
|
+
order_source: OrderSource;
|
|
128
|
+
needs_feedback_for_buyer: boolean;
|
|
129
|
+
needs_feedback_for_seller: boolean;
|
|
130
|
+
order_type: OrderType;
|
|
131
|
+
paid_at: ReturnType<typeof Date.toString>;
|
|
132
|
+
quantity: number;
|
|
133
|
+
shipping_address: ShippingAddress;
|
|
134
|
+
shipping_date: ReturnType<typeof Date.toString>;
|
|
135
|
+
shipped_at: ReturnType<typeof Date.toString>;
|
|
136
|
+
shipping_provider: ShippingProvider;
|
|
137
|
+
shipping_code: string;
|
|
138
|
+
shipping_method: OrderShippingMethod;
|
|
139
|
+
shipment_status: OrderShipmentStatus;
|
|
140
|
+
local_pickup: boolean;
|
|
141
|
+
shop_name: string;
|
|
142
|
+
status: OrderStatus;
|
|
143
|
+
title: string;
|
|
144
|
+
updated_at: ReturnType<typeof Date.toString>;
|
|
145
|
+
payment_method: string;
|
|
146
|
+
order_bundle_id: number | string;
|
|
147
|
+
product_id: number | string;
|
|
148
|
+
uuid: string;
|
|
149
|
+
photos: {
|
|
150
|
+
_links: PhotoLinks;
|
|
151
|
+
}[];
|
|
152
|
+
selling_fee: Price;
|
|
153
|
+
bump_fee: Price;
|
|
154
|
+
direct_checkout_fee: Price;
|
|
155
|
+
tax_on_fees: Price;
|
|
156
|
+
tax_responsible_party: OrderTaxResponsibleParty;
|
|
157
|
+
direct_checkout_payout: Price;
|
|
158
|
+
order_notes: any[];
|
|
159
|
+
_links: OrderLinks;
|
|
160
|
+
};
|
|
161
|
+
type OrderLinks = {
|
|
162
|
+
photo: Link;
|
|
163
|
+
feedback_for_buyer: Link;
|
|
164
|
+
feedback_for_seller: Link;
|
|
165
|
+
listing: Link;
|
|
166
|
+
start_conversation: Link;
|
|
167
|
+
web_tracking: Link;
|
|
168
|
+
web: Link;
|
|
169
|
+
web_listing: Link;
|
|
170
|
+
self: Link;
|
|
171
|
+
mark_picked_up: Link;
|
|
172
|
+
payments: Link;
|
|
173
|
+
contact_buyer: {
|
|
174
|
+
web: Link;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
type ShippingAddress = {
|
|
178
|
+
region: string;
|
|
179
|
+
locality: string;
|
|
180
|
+
country_code: string;
|
|
181
|
+
display_location: string;
|
|
182
|
+
id: number | string;
|
|
183
|
+
primary: boolean;
|
|
184
|
+
name: string;
|
|
185
|
+
street_address: string;
|
|
186
|
+
extended_address: string;
|
|
187
|
+
postal_code: string;
|
|
188
|
+
phone: string;
|
|
189
|
+
unformatted_phone: string;
|
|
190
|
+
complete_shipping_address: boolean;
|
|
191
|
+
_links: {
|
|
192
|
+
self: Link;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
interface GetMyListingsOptions {
|
|
197
|
+
page?: number;
|
|
198
|
+
perPage?: number;
|
|
199
|
+
query?: string;
|
|
200
|
+
state?: string;
|
|
201
|
+
}
|
|
202
|
+
interface GetAllMyListingsOptions {
|
|
203
|
+
query?: string;
|
|
204
|
+
state?: string;
|
|
205
|
+
}
|
|
206
|
+
interface GetOneListingOptions {
|
|
207
|
+
id: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
interface GetMyOrdersOptions {
|
|
211
|
+
page?: number;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
type PaginatedReverbResponse<T> = T & {
|
|
215
|
+
total: number;
|
|
216
|
+
current_page: number;
|
|
217
|
+
total_pages: number;
|
|
218
|
+
_links: {
|
|
219
|
+
next?: Link;
|
|
220
|
+
prev?: Link;
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
type GetArbitraryEndpointOptions = {
|
|
224
|
+
url: string;
|
|
225
|
+
params?: {
|
|
226
|
+
[key: string]: string;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
type ApiVersion = string;
|
|
231
|
+
type ApiKey = string;
|
|
232
|
+
type Locale = string;
|
|
233
|
+
type ShippingRegion = string;
|
|
234
|
+
type DisplayCurrency = string;
|
|
235
|
+
type RootEndpoint = Domain;
|
|
236
|
+
type Domain = `${string}.${string}` | `${string}.${string}.${string}`;
|
|
237
|
+
interface ReverbOptions {
|
|
238
|
+
apiKey: ApiKey;
|
|
239
|
+
version?: ApiVersion | undefined;
|
|
240
|
+
rootEndpoint?: RootEndpoint | undefined;
|
|
241
|
+
displayCurrency?: DisplayCurrency | undefined;
|
|
242
|
+
shippingRegion?: ShippingRegion | undefined;
|
|
243
|
+
locale?: Locale | undefined;
|
|
244
|
+
}
|
|
245
|
+
type ReverbHeaders = Axios['get']['arguments'][1] & {
|
|
246
|
+
'Content-Type': string;
|
|
247
|
+
'Accept-Version': ApiVersion;
|
|
248
|
+
Accept: string;
|
|
249
|
+
'Accept-Language': Locale;
|
|
250
|
+
'X-Display-Currency': DisplayCurrency;
|
|
251
|
+
'X-Shipping-Region'?: ShippingRegion | undefined;
|
|
252
|
+
'User-Agent'?: string;
|
|
253
|
+
};
|
|
254
|
+
interface AuthReverbHeaders extends ReverbHeaders {
|
|
255
|
+
Authorization: `Bearer ${ApiKey}`;
|
|
256
|
+
}
|
|
257
|
+
declare class Reverb {
|
|
258
|
+
static defaultHeaders: ReverbHeaders;
|
|
259
|
+
private _rootEndpoint;
|
|
260
|
+
private _version;
|
|
261
|
+
private apiKey;
|
|
262
|
+
private _headers;
|
|
263
|
+
private _displayCurrency;
|
|
264
|
+
private _shippingRegion;
|
|
265
|
+
private _locale;
|
|
266
|
+
constructor(options: ReverbOptions);
|
|
267
|
+
private updateHeaders;
|
|
268
|
+
set locale(locale: Locale);
|
|
269
|
+
get locale(): Locale;
|
|
270
|
+
set shippingRegion(shippingRegion: ShippingRegion | undefined);
|
|
271
|
+
get shippingRegion(): ShippingRegion | undefined;
|
|
272
|
+
get headers(): AuthReverbHeaders;
|
|
273
|
+
set displayCurrency(displayCurrency: DisplayCurrency);
|
|
274
|
+
get displayCurrency(): DisplayCurrency;
|
|
275
|
+
set version(version: ApiVersion);
|
|
276
|
+
get version(): ApiVersion;
|
|
277
|
+
set rootEndpoint(rootEndpoint: RootEndpoint);
|
|
278
|
+
get rootEndpoint(): RootEndpoint;
|
|
279
|
+
/**
|
|
280
|
+
* Retrieves the current user's listings.
|
|
281
|
+
* @param options - Optional parameters for the request.
|
|
282
|
+
* @returns A Promise that resolves to the user's listings. Structured as an axios response
|
|
283
|
+
*/
|
|
284
|
+
getMyListings(options?: GetMyListingsOptions): Promise<axios.AxiosResponse<PaginatedReverbResponse<{
|
|
285
|
+
listings: Listing[];
|
|
286
|
+
}>, any>>;
|
|
287
|
+
/**
|
|
288
|
+
* Retrieves the orders for the current user.
|
|
289
|
+
* @param options - An optional object containing options for the request.
|
|
290
|
+
* @returns A Promise that resolves with the user's orders. Structured as an axios response
|
|
291
|
+
*/
|
|
292
|
+
getMyOrders(options?: GetMyOrdersOptions): Promise<axios.AxiosResponse<PaginatedReverbResponse<{
|
|
293
|
+
orders: Order[];
|
|
294
|
+
}>, any>>;
|
|
295
|
+
/**
|
|
296
|
+
* Retrieves an arbitrary endpoint using the provided options.
|
|
297
|
+
* @param options - The options to use when retrieving the endpoint.
|
|
298
|
+
* @returns A Promise that resolves with the retrieved endpoint. Structured as an axios response
|
|
299
|
+
*/
|
|
300
|
+
getArbitraryEndpoint(options: GetArbitraryEndpointOptions): Promise<axios.AxiosResponse<any, any>>;
|
|
301
|
+
/**
|
|
302
|
+
* Retrieves a single listing based on the provided options.
|
|
303
|
+
* @param options - The options to use when retrieving the listing.
|
|
304
|
+
* @returns A Promise that resolves with the retrieved listing.
|
|
305
|
+
*/
|
|
306
|
+
getOneListing(options: GetOneListingOptions): Promise<axios.AxiosResponse<Listing, any>>;
|
|
307
|
+
/**
|
|
308
|
+
* Retrieves all listings associated with the current user.
|
|
309
|
+
* @param options - An optional object containing options for the request.
|
|
310
|
+
* @returns A Promise that resolves with an array of listings.
|
|
311
|
+
*/
|
|
312
|
+
getAllMyListings(options?: GetAllMyListingsOptions): Promise<axios.AxiosResponse<Listing[], any>>;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export { ApiKey, ApiVersion, AuthReverbHeaders, DisplayCurrency, Locale, ReverbHeaders, ReverbOptions, RootEndpoint, ShippingRegion, Reverb as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -97,14 +97,119 @@ type Listing = {
|
|
|
97
97
|
}[];
|
|
98
98
|
_links: ListingLinks;
|
|
99
99
|
};
|
|
100
|
+
type OrderStatus = 'unpaid' | 'paid' | 'awaiting_shipment' | 'shipped' | Exclude<string, 'unpaid' | 'awaiting_shipment' | 'shipped'>;
|
|
101
|
+
type ShippingProvider = 'UPS' | 'USPS' | 'FedEx' | 'DHL Deutschland' | 'DHLExpress' | 'DHLGlobalMail' | 'DHL' | 'Canada Post' | 'CanPar' | 'Royal Mail' | 'PostNL' | 'Australia Post' | 'EMS' | 'La Poste - Colissimo' | 'China Post' | 'GLS' | 'Parcelforce' | 'Purolator' | 'Interlogistica' | 'Correos España' | 'Ukraine Post' | 'DPD Germany' | 'DPD UK' | 'DPD France' | 'Hermes' | 'TNT' | 'Other';
|
|
102
|
+
type OrderTaxResponsibleParty = 'reverb' | Exclude<string, 'reverb'>;
|
|
103
|
+
type OrderShippingMethod = 'shipped' | Exclude<string, 'shipped'>;
|
|
104
|
+
type OrderShipmentStatus = 'in_transit' | Exclude<string, 'in_transit'>;
|
|
105
|
+
type OrderType = 'offer' | Exclude<string, 'offer'>;
|
|
106
|
+
type OrderSource = 'reverb' | Exclude<string, 'reverb'>;
|
|
107
|
+
type Order = {
|
|
108
|
+
amount_product: Price;
|
|
109
|
+
presentment_amount_product: Price;
|
|
110
|
+
amount_product_subtotal: Price;
|
|
111
|
+
presentment_amount_product_subtotal: Price;
|
|
112
|
+
shipping: Price;
|
|
113
|
+
presentment_amount_shipping: Price;
|
|
114
|
+
amount_tax: Price;
|
|
115
|
+
presentment_amount_tax: Price;
|
|
116
|
+
total: Price;
|
|
117
|
+
presentment_amount_total: Price;
|
|
118
|
+
shipping_taxed: boolean;
|
|
119
|
+
buyer_name: string;
|
|
120
|
+
buyer_first_name: string;
|
|
121
|
+
buyer_email: string;
|
|
122
|
+
buyer_last_name: string;
|
|
123
|
+
buyer_id: number | string;
|
|
124
|
+
created_at: ReturnType<typeof Date.toString>;
|
|
125
|
+
order_number: number | string;
|
|
126
|
+
tax_rate: number;
|
|
127
|
+
order_source: OrderSource;
|
|
128
|
+
needs_feedback_for_buyer: boolean;
|
|
129
|
+
needs_feedback_for_seller: boolean;
|
|
130
|
+
order_type: OrderType;
|
|
131
|
+
paid_at: ReturnType<typeof Date.toString>;
|
|
132
|
+
quantity: number;
|
|
133
|
+
shipping_address: ShippingAddress;
|
|
134
|
+
shipping_date: ReturnType<typeof Date.toString>;
|
|
135
|
+
shipped_at: ReturnType<typeof Date.toString>;
|
|
136
|
+
shipping_provider: ShippingProvider;
|
|
137
|
+
shipping_code: string;
|
|
138
|
+
shipping_method: OrderShippingMethod;
|
|
139
|
+
shipment_status: OrderShipmentStatus;
|
|
140
|
+
local_pickup: boolean;
|
|
141
|
+
shop_name: string;
|
|
142
|
+
status: OrderStatus;
|
|
143
|
+
title: string;
|
|
144
|
+
updated_at: ReturnType<typeof Date.toString>;
|
|
145
|
+
payment_method: string;
|
|
146
|
+
order_bundle_id: number | string;
|
|
147
|
+
product_id: number | string;
|
|
148
|
+
uuid: string;
|
|
149
|
+
photos: {
|
|
150
|
+
_links: PhotoLinks;
|
|
151
|
+
}[];
|
|
152
|
+
selling_fee: Price;
|
|
153
|
+
bump_fee: Price;
|
|
154
|
+
direct_checkout_fee: Price;
|
|
155
|
+
tax_on_fees: Price;
|
|
156
|
+
tax_responsible_party: OrderTaxResponsibleParty;
|
|
157
|
+
direct_checkout_payout: Price;
|
|
158
|
+
order_notes: any[];
|
|
159
|
+
_links: OrderLinks;
|
|
160
|
+
};
|
|
161
|
+
type OrderLinks = {
|
|
162
|
+
photo: Link;
|
|
163
|
+
feedback_for_buyer: Link;
|
|
164
|
+
feedback_for_seller: Link;
|
|
165
|
+
listing: Link;
|
|
166
|
+
start_conversation: Link;
|
|
167
|
+
web_tracking: Link;
|
|
168
|
+
web: Link;
|
|
169
|
+
web_listing: Link;
|
|
170
|
+
self: Link;
|
|
171
|
+
mark_picked_up: Link;
|
|
172
|
+
payments: Link;
|
|
173
|
+
contact_buyer: {
|
|
174
|
+
web: Link;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
type ShippingAddress = {
|
|
178
|
+
region: string;
|
|
179
|
+
locality: string;
|
|
180
|
+
country_code: string;
|
|
181
|
+
display_location: string;
|
|
182
|
+
id: number | string;
|
|
183
|
+
primary: boolean;
|
|
184
|
+
name: string;
|
|
185
|
+
street_address: string;
|
|
186
|
+
extended_address: string;
|
|
187
|
+
postal_code: string;
|
|
188
|
+
phone: string;
|
|
189
|
+
unformatted_phone: string;
|
|
190
|
+
complete_shipping_address: boolean;
|
|
191
|
+
_links: {
|
|
192
|
+
self: Link;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
100
195
|
|
|
101
196
|
interface GetMyListingsOptions {
|
|
102
197
|
page?: number;
|
|
103
198
|
perPage?: number;
|
|
104
199
|
query?: string;
|
|
105
|
-
sku?: string;
|
|
106
200
|
state?: string;
|
|
107
201
|
}
|
|
202
|
+
interface GetAllMyListingsOptions {
|
|
203
|
+
query?: string;
|
|
204
|
+
state?: string;
|
|
205
|
+
}
|
|
206
|
+
interface GetOneListingOptions {
|
|
207
|
+
id: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
interface GetMyOrdersOptions {
|
|
211
|
+
page?: number;
|
|
212
|
+
}
|
|
108
213
|
|
|
109
214
|
type PaginatedReverbResponse<T> = T & {
|
|
110
215
|
total: number;
|
|
@@ -115,6 +220,12 @@ type PaginatedReverbResponse<T> = T & {
|
|
|
115
220
|
prev?: Link;
|
|
116
221
|
};
|
|
117
222
|
};
|
|
223
|
+
type GetArbitraryEndpointOptions = {
|
|
224
|
+
url: string;
|
|
225
|
+
params?: {
|
|
226
|
+
[key: string]: string;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
118
229
|
|
|
119
230
|
type ApiVersion = string;
|
|
120
231
|
type ApiKey = string;
|
|
@@ -165,9 +276,40 @@ declare class Reverb {
|
|
|
165
276
|
get version(): ApiVersion;
|
|
166
277
|
set rootEndpoint(rootEndpoint: RootEndpoint);
|
|
167
278
|
get rootEndpoint(): RootEndpoint;
|
|
279
|
+
/**
|
|
280
|
+
* Retrieves the current user's listings.
|
|
281
|
+
* @param options - Optional parameters for the request.
|
|
282
|
+
* @returns A Promise that resolves to the user's listings. Structured as an axios response
|
|
283
|
+
*/
|
|
168
284
|
getMyListings(options?: GetMyListingsOptions): Promise<axios.AxiosResponse<PaginatedReverbResponse<{
|
|
169
285
|
listings: Listing[];
|
|
170
286
|
}>, any>>;
|
|
287
|
+
/**
|
|
288
|
+
* Retrieves the orders for the current user.
|
|
289
|
+
* @param options - An optional object containing options for the request.
|
|
290
|
+
* @returns A Promise that resolves with the user's orders. Structured as an axios response
|
|
291
|
+
*/
|
|
292
|
+
getMyOrders(options?: GetMyOrdersOptions): Promise<axios.AxiosResponse<PaginatedReverbResponse<{
|
|
293
|
+
orders: Order[];
|
|
294
|
+
}>, any>>;
|
|
295
|
+
/**
|
|
296
|
+
* Retrieves an arbitrary endpoint using the provided options.
|
|
297
|
+
* @param options - The options to use when retrieving the endpoint.
|
|
298
|
+
* @returns A Promise that resolves with the retrieved endpoint. Structured as an axios response
|
|
299
|
+
*/
|
|
300
|
+
getArbitraryEndpoint(options: GetArbitraryEndpointOptions): Promise<axios.AxiosResponse<any, any>>;
|
|
301
|
+
/**
|
|
302
|
+
* Retrieves a single listing based on the provided options.
|
|
303
|
+
* @param options - The options to use when retrieving the listing.
|
|
304
|
+
* @returns A Promise that resolves with the retrieved listing.
|
|
305
|
+
*/
|
|
306
|
+
getOneListing(options: GetOneListingOptions): Promise<axios.AxiosResponse<Listing, any>>;
|
|
307
|
+
/**
|
|
308
|
+
* Retrieves all listings associated with the current user.
|
|
309
|
+
* @param options - An optional object containing options for the request.
|
|
310
|
+
* @returns A Promise that resolves with an array of listings.
|
|
311
|
+
*/
|
|
312
|
+
getAllMyListings(options?: GetAllMyListingsOptions): Promise<axios.AxiosResponse<Listing[], any>>;
|
|
171
313
|
}
|
|
172
314
|
|
|
173
315
|
export { ApiKey, ApiVersion, AuthReverbHeaders, DisplayCurrency, Locale, ReverbHeaders, ReverbOptions, RootEndpoint, ShippingRegion, Reverb as default };
|
package/dist/index.js
CHANGED
|
@@ -1,98 +1,72 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
-
var __export = (target, all) => {
|
|
26
|
-
for (var name in all)
|
|
27
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
-
};
|
|
29
|
-
var __copyProps = (to, from, except, desc) => {
|
|
30
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
31
|
-
for (let key of __getOwnPropNames(from))
|
|
32
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
33
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
34
|
-
}
|
|
35
|
-
return to;
|
|
36
|
-
};
|
|
37
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
38
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
39
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
40
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
41
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
42
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
43
|
-
mod
|
|
44
|
-
));
|
|
45
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
|
-
var __async = (__this, __arguments, generator) => {
|
|
47
|
-
return new Promise((resolve, reject) => {
|
|
48
|
-
var fulfilled = (value) => {
|
|
49
|
-
try {
|
|
50
|
-
step(generator.next(value));
|
|
51
|
-
} catch (e) {
|
|
52
|
-
reject(e);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
var rejected = (value) => {
|
|
56
|
-
try {
|
|
57
|
-
step(generator.throw(value));
|
|
58
|
-
} catch (e) {
|
|
59
|
-
reject(e);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
63
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// src/index.ts
|
|
68
|
-
var src_exports = {};
|
|
69
|
-
__export(src_exports, {
|
|
70
|
-
default: () => src_default
|
|
71
|
-
});
|
|
72
|
-
module.exports = __toCommonJS(src_exports);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
73
3
|
|
|
74
4
|
// src/methods/listings/getListings.ts
|
|
75
|
-
var
|
|
76
|
-
var getMyListings = (reverb, options) =>
|
|
77
|
-
const { page, perPage, query,
|
|
5
|
+
var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);
|
|
6
|
+
var getMyListings = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
7
|
+
const { page, perPage, query, state } = options;
|
|
78
8
|
const baseUrl = `${reverb.rootEndpoint}/my/listings`;
|
|
79
9
|
const pageString = page ? `&page=${page}` : "";
|
|
80
10
|
const perPageString = perPage ? `&per_page=${perPage}` : "";
|
|
81
11
|
const queryString = query ? `&query=${query}` : "";
|
|
82
|
-
const skuString = sku ? `&sku=${sku}` : "";
|
|
83
12
|
const stateString = state ? `&state=${state}` : "";
|
|
84
|
-
const url = `${baseUrl}?${pageString}${perPageString}${queryString}${
|
|
85
|
-
const response =
|
|
13
|
+
const url = `${baseUrl}?${pageString}${perPageString}${queryString}${stateString}`;
|
|
14
|
+
const response = await _axios2.default.get(url, {
|
|
15
|
+
headers: reverb.headers
|
|
16
|
+
});
|
|
17
|
+
return response;
|
|
18
|
+
}, "getMyListings");
|
|
19
|
+
var getAllMyListings = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
20
|
+
let page = 1;
|
|
21
|
+
const perPage = 50;
|
|
22
|
+
const { query, state } = options;
|
|
23
|
+
let listings = [];
|
|
24
|
+
let response;
|
|
25
|
+
do {
|
|
26
|
+
response = await getMyListings(reverb, { page, perPage, query, state });
|
|
27
|
+
listings = listings.concat(response.data.listings);
|
|
28
|
+
page++;
|
|
29
|
+
} while (response.data.listings.length === perPage);
|
|
30
|
+
return { ...response, data: listings };
|
|
31
|
+
}, "getAllMyListings");
|
|
32
|
+
var getOneListing = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
33
|
+
const { id } = options;
|
|
34
|
+
const baseUrl = `${reverb.rootEndpoint}/listings/${id}`;
|
|
35
|
+
const response = await _axios2.default.get(baseUrl, {
|
|
86
36
|
headers: reverb.headers
|
|
87
37
|
});
|
|
88
38
|
return response;
|
|
89
|
-
});
|
|
39
|
+
}, "getOneListing");
|
|
40
|
+
|
|
41
|
+
// src/methods/orders/getOrders.ts
|
|
42
|
+
|
|
43
|
+
var getMyOrders = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
44
|
+
const { page } = options;
|
|
45
|
+
const baseUrl = `${reverb.rootEndpoint}/my/orders/selling/all`;
|
|
46
|
+
const pageString = page ? `&page=${page}` : "";
|
|
47
|
+
const url = `${baseUrl}?${pageString}`;
|
|
48
|
+
const response = await _axios2.default.get(url, {
|
|
49
|
+
headers: reverb.headers
|
|
50
|
+
});
|
|
51
|
+
return response;
|
|
52
|
+
}, "getMyOrders");
|
|
90
53
|
|
|
91
54
|
// src/methods/index.ts
|
|
92
|
-
|
|
55
|
+
|
|
56
|
+
var getArbitraryEndpoint = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
57
|
+
const { url, ...requestConfig } = options;
|
|
58
|
+
const isAbsoluteUrl = url.startsWith("http");
|
|
59
|
+
const hasSlash = url.startsWith("/");
|
|
60
|
+
const requestUrl = isAbsoluteUrl ? url : `${reverb.rootEndpoint}${hasSlash ? "" : "/"}${url}`;
|
|
61
|
+
const response = await _axios2.default.get(requestUrl, {
|
|
62
|
+
headers: reverb.headers,
|
|
63
|
+
...requestConfig
|
|
64
|
+
});
|
|
65
|
+
return response;
|
|
66
|
+
}, "getArbitraryEndpoint");
|
|
93
67
|
|
|
94
68
|
// src/Reverb.ts
|
|
95
|
-
var _Reverb = class {
|
|
69
|
+
var _Reverb = class _Reverb {
|
|
96
70
|
constructor(options) {
|
|
97
71
|
this._rootEndpoint = "https://api.reverb.com/api";
|
|
98
72
|
this._version = _Reverb.defaultHeaders["Accept-Version"];
|
|
@@ -125,21 +99,24 @@ var _Reverb = class {
|
|
|
125
99
|
this._locale = locale;
|
|
126
100
|
}
|
|
127
101
|
this.apiKey = apiKey;
|
|
128
|
-
this._headers =
|
|
102
|
+
this._headers = {
|
|
103
|
+
..._Reverb.defaultHeaders,
|
|
129
104
|
Authorization: `Bearer ${this.apiKey}`
|
|
130
|
-
}
|
|
105
|
+
};
|
|
131
106
|
this.updateHeaders();
|
|
132
107
|
}
|
|
133
108
|
updateHeaders() {
|
|
134
109
|
const optionalHeaders = {};
|
|
135
110
|
if (this._shippingRegion)
|
|
136
111
|
optionalHeaders["X-Shipping-Region"] = this._shippingRegion;
|
|
137
|
-
this._headers =
|
|
112
|
+
this._headers = {
|
|
113
|
+
...this._headers,
|
|
138
114
|
Authorization: `Bearer ${this.apiKey}`,
|
|
139
115
|
"Accept-Version": this._version,
|
|
140
116
|
"X-Display-Currency": this._displayCurrency,
|
|
141
|
-
"Accept-Language": this._locale
|
|
142
|
-
|
|
117
|
+
"Accept-Language": this._locale,
|
|
118
|
+
...optionalHeaders
|
|
119
|
+
};
|
|
143
120
|
}
|
|
144
121
|
set locale(locale) {
|
|
145
122
|
this._locale = locale;
|
|
@@ -178,14 +155,49 @@ var _Reverb = class {
|
|
|
178
155
|
get rootEndpoint() {
|
|
179
156
|
return this._rootEndpoint;
|
|
180
157
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Retrieves the current user's listings.
|
|
160
|
+
* @param options - Optional parameters for the request.
|
|
161
|
+
* @returns A Promise that resolves to the user's listings. Structured as an axios response
|
|
162
|
+
*/
|
|
163
|
+
async getMyListings(options) {
|
|
164
|
+
return await getMyListings(this, _nullishCoalesce(options, () => ( {})));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Retrieves the orders for the current user.
|
|
168
|
+
* @param options - An optional object containing options for the request.
|
|
169
|
+
* @returns A Promise that resolves with the user's orders. Structured as an axios response
|
|
170
|
+
*/
|
|
171
|
+
async getMyOrders(options) {
|
|
172
|
+
return await getMyOrders(this, _nullishCoalesce(options, () => ( {})));
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Retrieves an arbitrary endpoint using the provided options.
|
|
176
|
+
* @param options - The options to use when retrieving the endpoint.
|
|
177
|
+
* @returns A Promise that resolves with the retrieved endpoint. Structured as an axios response
|
|
178
|
+
*/
|
|
179
|
+
async getArbitraryEndpoint(options) {
|
|
180
|
+
return await getArbitraryEndpoint(this, options);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Retrieves a single listing based on the provided options.
|
|
184
|
+
* @param options - The options to use when retrieving the listing.
|
|
185
|
+
* @returns A Promise that resolves with the retrieved listing.
|
|
186
|
+
*/
|
|
187
|
+
async getOneListing(options) {
|
|
188
|
+
return await getOneListing(this, options);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Retrieves all listings associated with the current user.
|
|
192
|
+
* @param options - An optional object containing options for the request.
|
|
193
|
+
* @returns A Promise that resolves with an array of listings.
|
|
194
|
+
*/
|
|
195
|
+
async getAllMyListings(options) {
|
|
196
|
+
return await getAllMyListings(this, _nullishCoalesce(options, () => ( {})));
|
|
185
197
|
}
|
|
186
198
|
};
|
|
187
|
-
|
|
188
|
-
|
|
199
|
+
__name(_Reverb, "Reverb");
|
|
200
|
+
_Reverb.defaultHeaders = {
|
|
189
201
|
"Content-Type": "application/hal+json",
|
|
190
202
|
"Accept-Version": "3.0",
|
|
191
203
|
Accept: "application/hal+json",
|
|
@@ -194,8 +206,11 @@ Reverb.defaultHeaders = {
|
|
|
194
206
|
// 'X-Shipping-Region': undefined
|
|
195
207
|
"User-Agent": "Reverb Node SDK"
|
|
196
208
|
};
|
|
209
|
+
var Reverb = _Reverb;
|
|
197
210
|
|
|
198
211
|
// src/index.ts
|
|
199
212
|
var src_default = Reverb;
|
|
200
|
-
|
|
201
|
-
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
exports.default = src_default;
|
|
216
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/methods/listings/getListings.ts","../src/methods/orders/getOrders.ts","../src/methods/index.ts","../src/Reverb.ts","../src/index.ts"],"names":["axios"],"mappings":";;;;AAEA,OAAO,WAA8B;AAqB9B,IAAM,gBAAgB,8BAC3B,QACA,YACG;AACH,QAAM,EAAE,MAAM,SAAS,OAAO,MAAM,IAAI;AAExC,QAAM,UAAU,GAAG,OAAO,YAAY;AACtC,QAAM,aAAa,OAAO,SAAS,IAAI,KAAK;AAC5C,QAAM,gBAAgB,UAAU,aAAa,OAAO,KAAK;AACzD,QAAM,cAAc,QAAQ,UAAU,KAAK,KAAK;AAEhD,QAAM,cAAc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AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,cAAc,SAAuC;AACzD,WAAO,MAAc,cAAc,MAAM,OAAO;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,iBAAiB,SAA2C;AAChE,WAAO,MAAc,iBAAiB,MAAM,WAAW,CAAC,CAAC;AAAA,EAC3D;AACF;AAvK4B;AAAP,QACZ,iBAAgC;AAAA,EACrC,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EACR,mBAAmB;AAAA,EACnB,sBAAsB;AAAA;AAAA,EAEtB,cAAc;AAChB;AATF,IAAqB,SAArB;;;AChCA,IAAO,cAAQ","sourcesContent":["// import type { } from '~/Reverb';\n\nimport axios, { AxiosResponse } from 'axios';\n\nimport { Listing } from '~/types';\nimport { PaginatedReverbResponse } from '..';\nimport Reverb from '~/Reverb';\n\nexport interface GetMyListingsOptions {\n page?: number;\n perPage?: number;\n query?: string;\n // sku?: string;\n state?: string;\n}\n\n/**\n * Retrieves a paginated list of the authenticated user's listings on Reverb.\n *\n * @param reverb - The Reverb client instance.\n * @param options - The options to use when fetching the listings.\n * @returns A Promise that resolves to the paginated response containing the user's listings.\n */\nexport const getMyListings = async (\n reverb: Reverb,\n options: GetMyListingsOptions,\n) => {\n const { page, perPage, query, state } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/my/listings`;\n const pageString = page ? `&page=${page}` : '';\n const perPageString = perPage ? `&per_page=${perPage}` : '';\n const queryString = query ? `&query=${query}` : '';\n // const skuString = sku ? `&sku=${sku}` : '';\n const stateString = state ? `&state=${state}` : '';\n\n const url = `${baseUrl}?${pageString}${perPageString}${queryString}${stateString}`;\n\n const response = await axios.get<\n PaginatedReverbResponse<{ listings: Listing[] }>\n >(url, {\n headers: reverb.headers,\n });\n\n return response;\n};\n\nexport interface GetAllMyListingsOptions {\n query?: string;\n // sku?: string;\n state?: string;\n}\n\nexport const getAllMyListings = async (\n reverb: Reverb,\n options: GetAllMyListingsOptions,\n): Promise<AxiosResponse<Listing[]>> => {\n let page = 1;\n const perPage = 50;\n\n const { query, state } = options;\n\n let listings: Listing[] = [];\n let response;\n\n do {\n response = await getMyListings(reverb, { page, perPage, query, state });\n listings = listings.concat(response.data.listings);\n page++;\n } while (response.data.listings.length === perPage);\n\n return { ...response, data: listings };\n};\n\nexport interface GetOneListingOptions {\n id: string;\n}\n\n/**\n * Retrieves a single Reverb listing by ID.\n * @param reverb - The Reverb instance to use for the API request.\n * @param options - The options for the API request, including the ID of the listing to retrieve.\n * @returns A Promise that resolves with the retrieved listing. Structured as an axios response\n */\nexport const getOneListing = async (\n reverb: Reverb,\n options: GetOneListingOptions,\n) => {\n const { id } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/listings/${id}`;\n\n const response = await axios.get<Listing>(baseUrl, {\n headers: reverb.headers,\n });\n\n return response;\n};\n","// import type { } from '~/Reverb';\n\nimport { Order } from '~/types';\nimport { PaginatedReverbResponse } from '..';\nimport Reverb from '~/Reverb';\nimport axios from 'axios';\n\nexport interface GetMyOrdersOptions {\n page?: number;\n // perPage?: number;\n // status?: Order['status'] | 'all';\n}\n\n/**\n * Retrieves a paginated list of orders for the authenticated user.\n * @param reverb - The Reverb instance to use for the API request.\n * @param options - The options to use for the API request.\n * @returns A Promise that resolves to the API response containing the list of orders.\n */\nexport const getMyOrders = async (\n reverb: Reverb,\n options: GetMyOrdersOptions,\n) => {\n const { page } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/my/orders/selling/all`;\n const pageString = page ? `&page=${page}` : '';\n\n const url = `${baseUrl}?${pageString}`;\n\n const response = await axios.get<\n PaginatedReverbResponse<{ orders: Order[] }>\n >(url, {\n headers: reverb.headers,\n });\n\n return response;\n};\n","export * from './listings/getListings';\nexport * from './orders/getOrders';\n\nimport { Link } from '~/types';\nimport Reverb from '~/Reverb';\nimport axios from 'axios';\n\nexport const getMyRoot = async <T = any>(reverb: Reverb) => {\n const url = `${reverb.rootEndpoint}/`;\n const response = await axios.get<T>(url, {\n headers: reverb.headers,\n });\n return response;\n};\n\nexport type PaginatedReverbResponse<T> = T & {\n total: number;\n current_page: number;\n total_pages: number;\n _links: {\n next?: Link;\n prev?: Link;\n };\n};\n\nexport type GetArbitraryEndpointOptions = {\n url: string;\n params?: {\n [key: string]: string;\n };\n};\n\n/**\n * Makes a GET request to an arbitrary endpoint.\n * @param reverb - The Reverb instance to use for the request.\n * @param options - The options for the request, including the URL and any additional request configuration.\n * @returns A Promise that resolves with the response data.\n * @template T - The type of the response data.\n */\nexport const getArbitraryEndpoint = async <T = any>(\n reverb: Reverb,\n options: GetArbitraryEndpointOptions,\n) => {\n const { url, ...requestConfig } = options;\n\n // check if url is absolute\n const isAbsoluteUrl = url.startsWith('http');\n //check if url has / at the beginning\n const hasSlash = url.startsWith('/');\n const requestUrl = isAbsoluteUrl\n ? url\n : `${reverb.rootEndpoint}${hasSlash ? '' : '/'}${url}`;\n\n const response = await axios.get<T>(requestUrl, {\n headers: reverb.headers,\n ...requestConfig,\n });\n\n return response;\n};\n","import * as methods from './methods';\n\nimport { Axios } from 'axios';\n\nexport type ApiVersion = string;\nexport type ApiKey = string;\nexport type Locale = string;\nexport type ShippingRegion = string;\nexport type DisplayCurrency = string;\nexport type RootEndpoint = Domain;\n\ntype Domain = `${string}.${string}` | `${string}.${string}.${string}`;\n\nexport interface ReverbOptions {\n apiKey: ApiKey;\n version?: ApiVersion | undefined;\n rootEndpoint?: RootEndpoint | undefined;\n displayCurrency?: DisplayCurrency | undefined;\n shippingRegion?: ShippingRegion | undefined;\n locale?: Locale | undefined;\n}\n\nexport type ReverbHeaders = Axios['get']['arguments'][1] & {\n 'Content-Type': string;\n 'Accept-Version': ApiVersion;\n Accept: string;\n 'Accept-Language': Locale;\n 'X-Display-Currency': DisplayCurrency;\n 'X-Shipping-Region'?: ShippingRegion | undefined;\n 'User-Agent'?: string;\n};\n\nexport interface AuthReverbHeaders extends ReverbHeaders {\n Authorization: `Bearer ${ApiKey}`;\n}\n\nexport default class Reverb {\n static defaultHeaders: ReverbHeaders = {\n 'Content-Type': 'application/hal+json',\n 'Accept-Version': '3.0',\n Accept: 'application/hal+json',\n 'Accept-Language': 'en',\n 'X-Display-Currency': 'USD',\n // 'X-Shipping-Region': undefined\n 'User-Agent': 'Reverb Node SDK',\n };\n\n private _rootEndpoint: RootEndpoint = 'https://api.reverb.com/api';\n private _version: ApiVersion = Reverb.defaultHeaders['Accept-Version'];\n private apiKey: string;\n private _headers: AuthReverbHeaders;\n private _displayCurrency: DisplayCurrency =\n Reverb.defaultHeaders['X-Display-Currency'];\n private _shippingRegion: ShippingRegion | undefined;\n private _locale: Locale = Reverb.defaultHeaders['Accept-Language'];\n\n constructor(options: ReverbOptions) {\n const {\n apiKey,\n version,\n rootEndpoint: defaultEndpoint,\n displayCurrency,\n shippingRegion,\n locale,\n } = options;\n\n // throw if no api key\n if (!apiKey || apiKey === '') {\n throw new Error('Reverb: apiKey is required');\n }\n\n // set version and default endpoint if provided\n if (version) {\n this._version = version;\n }\n if (defaultEndpoint) {\n this._rootEndpoint = defaultEndpoint;\n }\n if (displayCurrency) {\n this._displayCurrency = displayCurrency;\n }\n if (shippingRegion) {\n this._shippingRegion = shippingRegion;\n }\n if (locale) {\n this._locale = locale;\n }\n\n // set api key\n this.apiKey = apiKey;\n\n this._headers = {\n ...Reverb.defaultHeaders,\n Authorization: `Bearer ${this.apiKey}`,\n };\n\n this.updateHeaders();\n }\n\n private updateHeaders() {\n const optionalHeaders = {} as any;\n\n if (this._shippingRegion)\n optionalHeaders['X-Shipping-Region'] = this._shippingRegion;\n\n this._headers = {\n ...this._headers,\n Authorization: `Bearer ${this.apiKey}`,\n 'Accept-Version': this._version,\n 'X-Display-Currency': this._displayCurrency,\n 'Accept-Language': this._locale,\n ...optionalHeaders,\n };\n }\n\n set locale(locale: Locale) {\n this._locale = locale;\n this.updateHeaders();\n }\n get locale() {\n return this._locale;\n }\n\n set shippingRegion(shippingRegion: ShippingRegion | undefined) {\n this._shippingRegion = shippingRegion;\n this.updateHeaders();\n }\n get shippingRegion(): ShippingRegion | undefined {\n return this._shippingRegion;\n }\n\n get headers(): AuthReverbHeaders {\n return this._headers;\n }\n\n set displayCurrency(displayCurrency: DisplayCurrency) {\n this._displayCurrency = displayCurrency;\n this.updateHeaders();\n }\n get displayCurrency(): DisplayCurrency {\n return this._displayCurrency;\n }\n\n set version(version: ApiVersion) {\n this._version = version;\n this.updateHeaders();\n }\n get version(): ApiVersion {\n return this._version;\n }\n\n set rootEndpoint(rootEndpoint: RootEndpoint) {\n this._rootEndpoint = rootEndpoint;\n // this.updateHeaders();\n }\n get rootEndpoint(): RootEndpoint {\n return this._rootEndpoint;\n }\n\n /**\n * Retrieves the current user's listings.\n * @param options - Optional parameters for the request.\n * @returns A Promise that resolves to the user's listings. Structured as an axios response\n */\n async getMyListings(options?: methods.GetMyListingsOptions) {\n return await methods.getMyListings(this, options ?? {});\n }\n\n /**\n * Retrieves the orders for the current user.\n * @param options - An optional object containing options for the request.\n * @returns A Promise that resolves with the user's orders. Structured as an axios response\n */\n async getMyOrders(options?: methods.GetMyOrdersOptions) {\n return await methods.getMyOrders(this, options ?? {});\n }\n\n /**\n * Retrieves an arbitrary endpoint using the provided options.\n * @param options - The options to use when retrieving the endpoint.\n * @returns A Promise that resolves with the retrieved endpoint. Structured as an axios response\n */\n async getArbitraryEndpoint(options: methods.GetArbitraryEndpointOptions) {\n return await methods.getArbitraryEndpoint(this, options);\n }\n\n /**\n * Retrieves a single listing based on the provided options.\n * @param options - The options to use when retrieving the listing.\n * @returns A Promise that resolves with the retrieved listing.\n */\n async getOneListing(options: methods.GetOneListingOptions) {\n return await methods.getOneListing(this, options);\n }\n\n /**\n * Retrieves all listings associated with the current user.\n * @param options - An optional object containing options for the request.\n * @returns A Promise that resolves with an array of listings.\n */\n async getAllMyListings(options?: methods.GetAllMyListingsOptions) {\n return await methods.getAllMyListings(this, options ?? {});\n }\n}\n","export * from './Reverb';\n\nimport Reverb from './Reverb';\n\nexport default Reverb;\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,65 +1,72 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __async = (__this, __arguments, generator) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
var fulfilled = (value) => {
|
|
23
|
-
try {
|
|
24
|
-
step(generator.next(value));
|
|
25
|
-
} catch (e) {
|
|
26
|
-
reject(e);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
var rejected = (value) => {
|
|
30
|
-
try {
|
|
31
|
-
step(generator.throw(value));
|
|
32
|
-
} catch (e) {
|
|
33
|
-
reject(e);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
40
3
|
|
|
41
4
|
// src/methods/listings/getListings.ts
|
|
42
5
|
import axios from "axios";
|
|
43
|
-
var getMyListings = (reverb, options) =>
|
|
44
|
-
const { page, perPage, query,
|
|
6
|
+
var getMyListings = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
7
|
+
const { page, perPage, query, state } = options;
|
|
45
8
|
const baseUrl = `${reverb.rootEndpoint}/my/listings`;
|
|
46
9
|
const pageString = page ? `&page=${page}` : "";
|
|
47
10
|
const perPageString = perPage ? `&per_page=${perPage}` : "";
|
|
48
11
|
const queryString = query ? `&query=${query}` : "";
|
|
49
|
-
const skuString = sku ? `&sku=${sku}` : "";
|
|
50
12
|
const stateString = state ? `&state=${state}` : "";
|
|
51
|
-
const url = `${baseUrl}?${pageString}${perPageString}${queryString}${
|
|
52
|
-
const response =
|
|
13
|
+
const url = `${baseUrl}?${pageString}${perPageString}${queryString}${stateString}`;
|
|
14
|
+
const response = await axios.get(url, {
|
|
53
15
|
headers: reverb.headers
|
|
54
16
|
});
|
|
55
17
|
return response;
|
|
56
|
-
});
|
|
18
|
+
}, "getMyListings");
|
|
19
|
+
var getAllMyListings = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
20
|
+
let page = 1;
|
|
21
|
+
const perPage = 50;
|
|
22
|
+
const { query, state } = options;
|
|
23
|
+
let listings = [];
|
|
24
|
+
let response;
|
|
25
|
+
do {
|
|
26
|
+
response = await getMyListings(reverb, { page, perPage, query, state });
|
|
27
|
+
listings = listings.concat(response.data.listings);
|
|
28
|
+
page++;
|
|
29
|
+
} while (response.data.listings.length === perPage);
|
|
30
|
+
return { ...response, data: listings };
|
|
31
|
+
}, "getAllMyListings");
|
|
32
|
+
var getOneListing = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
33
|
+
const { id } = options;
|
|
34
|
+
const baseUrl = `${reverb.rootEndpoint}/listings/${id}`;
|
|
35
|
+
const response = await axios.get(baseUrl, {
|
|
36
|
+
headers: reverb.headers
|
|
37
|
+
});
|
|
38
|
+
return response;
|
|
39
|
+
}, "getOneListing");
|
|
57
40
|
|
|
58
|
-
// src/methods/
|
|
41
|
+
// src/methods/orders/getOrders.ts
|
|
59
42
|
import axios2 from "axios";
|
|
43
|
+
var getMyOrders = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
44
|
+
const { page } = options;
|
|
45
|
+
const baseUrl = `${reverb.rootEndpoint}/my/orders/selling/all`;
|
|
46
|
+
const pageString = page ? `&page=${page}` : "";
|
|
47
|
+
const url = `${baseUrl}?${pageString}`;
|
|
48
|
+
const response = await axios2.get(url, {
|
|
49
|
+
headers: reverb.headers
|
|
50
|
+
});
|
|
51
|
+
return response;
|
|
52
|
+
}, "getMyOrders");
|
|
53
|
+
|
|
54
|
+
// src/methods/index.ts
|
|
55
|
+
import axios3 from "axios";
|
|
56
|
+
var getArbitraryEndpoint = /* @__PURE__ */ __name(async (reverb, options) => {
|
|
57
|
+
const { url, ...requestConfig } = options;
|
|
58
|
+
const isAbsoluteUrl = url.startsWith("http");
|
|
59
|
+
const hasSlash = url.startsWith("/");
|
|
60
|
+
const requestUrl = isAbsoluteUrl ? url : `${reverb.rootEndpoint}${hasSlash ? "" : "/"}${url}`;
|
|
61
|
+
const response = await axios3.get(requestUrl, {
|
|
62
|
+
headers: reverb.headers,
|
|
63
|
+
...requestConfig
|
|
64
|
+
});
|
|
65
|
+
return response;
|
|
66
|
+
}, "getArbitraryEndpoint");
|
|
60
67
|
|
|
61
68
|
// src/Reverb.ts
|
|
62
|
-
var _Reverb = class {
|
|
69
|
+
var _Reverb = class _Reverb {
|
|
63
70
|
constructor(options) {
|
|
64
71
|
this._rootEndpoint = "https://api.reverb.com/api";
|
|
65
72
|
this._version = _Reverb.defaultHeaders["Accept-Version"];
|
|
@@ -92,21 +99,24 @@ var _Reverb = class {
|
|
|
92
99
|
this._locale = locale;
|
|
93
100
|
}
|
|
94
101
|
this.apiKey = apiKey;
|
|
95
|
-
this._headers =
|
|
102
|
+
this._headers = {
|
|
103
|
+
..._Reverb.defaultHeaders,
|
|
96
104
|
Authorization: `Bearer ${this.apiKey}`
|
|
97
|
-
}
|
|
105
|
+
};
|
|
98
106
|
this.updateHeaders();
|
|
99
107
|
}
|
|
100
108
|
updateHeaders() {
|
|
101
109
|
const optionalHeaders = {};
|
|
102
110
|
if (this._shippingRegion)
|
|
103
111
|
optionalHeaders["X-Shipping-Region"] = this._shippingRegion;
|
|
104
|
-
this._headers =
|
|
112
|
+
this._headers = {
|
|
113
|
+
...this._headers,
|
|
105
114
|
Authorization: `Bearer ${this.apiKey}`,
|
|
106
115
|
"Accept-Version": this._version,
|
|
107
116
|
"X-Display-Currency": this._displayCurrency,
|
|
108
|
-
"Accept-Language": this._locale
|
|
109
|
-
|
|
117
|
+
"Accept-Language": this._locale,
|
|
118
|
+
...optionalHeaders
|
|
119
|
+
};
|
|
110
120
|
}
|
|
111
121
|
set locale(locale) {
|
|
112
122
|
this._locale = locale;
|
|
@@ -145,14 +155,49 @@ var _Reverb = class {
|
|
|
145
155
|
get rootEndpoint() {
|
|
146
156
|
return this._rootEndpoint;
|
|
147
157
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Retrieves the current user's listings.
|
|
160
|
+
* @param options - Optional parameters for the request.
|
|
161
|
+
* @returns A Promise that resolves to the user's listings. Structured as an axios response
|
|
162
|
+
*/
|
|
163
|
+
async getMyListings(options) {
|
|
164
|
+
return await getMyListings(this, options ?? {});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Retrieves the orders for the current user.
|
|
168
|
+
* @param options - An optional object containing options for the request.
|
|
169
|
+
* @returns A Promise that resolves with the user's orders. Structured as an axios response
|
|
170
|
+
*/
|
|
171
|
+
async getMyOrders(options) {
|
|
172
|
+
return await getMyOrders(this, options ?? {});
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Retrieves an arbitrary endpoint using the provided options.
|
|
176
|
+
* @param options - The options to use when retrieving the endpoint.
|
|
177
|
+
* @returns A Promise that resolves with the retrieved endpoint. Structured as an axios response
|
|
178
|
+
*/
|
|
179
|
+
async getArbitraryEndpoint(options) {
|
|
180
|
+
return await getArbitraryEndpoint(this, options);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Retrieves a single listing based on the provided options.
|
|
184
|
+
* @param options - The options to use when retrieving the listing.
|
|
185
|
+
* @returns A Promise that resolves with the retrieved listing.
|
|
186
|
+
*/
|
|
187
|
+
async getOneListing(options) {
|
|
188
|
+
return await getOneListing(this, options);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Retrieves all listings associated with the current user.
|
|
192
|
+
* @param options - An optional object containing options for the request.
|
|
193
|
+
* @returns A Promise that resolves with an array of listings.
|
|
194
|
+
*/
|
|
195
|
+
async getAllMyListings(options) {
|
|
196
|
+
return await getAllMyListings(this, options ?? {});
|
|
152
197
|
}
|
|
153
198
|
};
|
|
154
|
-
|
|
155
|
-
|
|
199
|
+
__name(_Reverb, "Reverb");
|
|
200
|
+
_Reverb.defaultHeaders = {
|
|
156
201
|
"Content-Type": "application/hal+json",
|
|
157
202
|
"Accept-Version": "3.0",
|
|
158
203
|
Accept: "application/hal+json",
|
|
@@ -161,9 +206,11 @@ Reverb.defaultHeaders = {
|
|
|
161
206
|
// 'X-Shipping-Region': undefined
|
|
162
207
|
"User-Agent": "Reverb Node SDK"
|
|
163
208
|
};
|
|
209
|
+
var Reverb = _Reverb;
|
|
164
210
|
|
|
165
211
|
// src/index.ts
|
|
166
212
|
var src_default = Reverb;
|
|
167
213
|
export {
|
|
168
214
|
src_default as default
|
|
169
215
|
};
|
|
216
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/methods/listings/getListings.ts","../src/methods/orders/getOrders.ts","../src/methods/index.ts","../src/Reverb.ts","../src/index.ts"],"sourcesContent":["// import type { } from '~/Reverb';\n\nimport axios, { AxiosResponse } from 'axios';\n\nimport { Listing } from '~/types';\nimport { PaginatedReverbResponse } from '..';\nimport Reverb from '~/Reverb';\n\nexport interface GetMyListingsOptions {\n page?: number;\n perPage?: number;\n query?: string;\n // sku?: string;\n state?: string;\n}\n\n/**\n * Retrieves a paginated list of the authenticated user's listings on Reverb.\n *\n * @param reverb - The Reverb client instance.\n * @param options - The options to use when fetching the listings.\n * @returns A Promise that resolves to the paginated response containing the user's listings.\n */\nexport const getMyListings = async (\n reverb: Reverb,\n options: GetMyListingsOptions,\n) => {\n const { page, perPage, query, state } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/my/listings`;\n const pageString = page ? `&page=${page}` : '';\n const perPageString = perPage ? `&per_page=${perPage}` : '';\n const queryString = query ? `&query=${query}` : '';\n // const skuString = sku ? `&sku=${sku}` : '';\n const stateString = state ? `&state=${state}` : '';\n\n const url = `${baseUrl}?${pageString}${perPageString}${queryString}${stateString}`;\n\n const response = await axios.get<\n PaginatedReverbResponse<{ listings: Listing[] }>\n >(url, {\n headers: reverb.headers,\n });\n\n return response;\n};\n\nexport interface GetAllMyListingsOptions {\n query?: string;\n // sku?: string;\n state?: string;\n}\n\nexport const getAllMyListings = async (\n reverb: Reverb,\n options: GetAllMyListingsOptions,\n): Promise<AxiosResponse<Listing[]>> => {\n let page = 1;\n const perPage = 50;\n\n const { query, state } = options;\n\n let listings: Listing[] = [];\n let response;\n\n do {\n response = await getMyListings(reverb, { page, perPage, query, state });\n listings = listings.concat(response.data.listings);\n page++;\n } while (response.data.listings.length === perPage);\n\n return { ...response, data: listings };\n};\n\nexport interface GetOneListingOptions {\n id: string;\n}\n\n/**\n * Retrieves a single Reverb listing by ID.\n * @param reverb - The Reverb instance to use for the API request.\n * @param options - The options for the API request, including the ID of the listing to retrieve.\n * @returns A Promise that resolves with the retrieved listing. Structured as an axios response\n */\nexport const getOneListing = async (\n reverb: Reverb,\n options: GetOneListingOptions,\n) => {\n const { id } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/listings/${id}`;\n\n const response = await axios.get<Listing>(baseUrl, {\n headers: reverb.headers,\n });\n\n return response;\n};\n","// import type { } from '~/Reverb';\n\nimport { Order } from '~/types';\nimport { PaginatedReverbResponse } from '..';\nimport Reverb from '~/Reverb';\nimport axios from 'axios';\n\nexport interface GetMyOrdersOptions {\n page?: number;\n // perPage?: number;\n // status?: Order['status'] | 'all';\n}\n\n/**\n * Retrieves a paginated list of orders for the authenticated user.\n * @param reverb - The Reverb instance to use for the API request.\n * @param options - The options to use for the API request.\n * @returns A Promise that resolves to the API response containing the list of orders.\n */\nexport const getMyOrders = async (\n reverb: Reverb,\n options: GetMyOrdersOptions,\n) => {\n const { page } = options;\n\n const baseUrl = `${reverb.rootEndpoint}/my/orders/selling/all`;\n const pageString = page ? `&page=${page}` : '';\n\n const url = `${baseUrl}?${pageString}`;\n\n const response = await axios.get<\n PaginatedReverbResponse<{ orders: Order[] }>\n >(url, {\n headers: reverb.headers,\n });\n\n return response;\n};\n","export * from './listings/getListings';\nexport * from './orders/getOrders';\n\nimport { Link } from '~/types';\nimport Reverb from '~/Reverb';\nimport axios from 'axios';\n\nexport const getMyRoot = async <T = any>(reverb: Reverb) => {\n const url = `${reverb.rootEndpoint}/`;\n const response = await axios.get<T>(url, {\n headers: reverb.headers,\n });\n return response;\n};\n\nexport type PaginatedReverbResponse<T> = T & {\n total: number;\n current_page: number;\n total_pages: number;\n _links: {\n next?: Link;\n prev?: Link;\n };\n};\n\nexport type GetArbitraryEndpointOptions = {\n url: string;\n params?: {\n [key: string]: string;\n };\n};\n\n/**\n * Makes a GET request to an arbitrary endpoint.\n * @param reverb - The Reverb instance to use for the request.\n * @param options - The options for the request, including the URL and any additional request configuration.\n * @returns A Promise that resolves with the response data.\n * @template T - The type of the response data.\n */\nexport const getArbitraryEndpoint = async <T = any>(\n reverb: Reverb,\n options: GetArbitraryEndpointOptions,\n) => {\n const { url, ...requestConfig } = options;\n\n // check if url is absolute\n const isAbsoluteUrl = url.startsWith('http');\n //check if url has / at the beginning\n const hasSlash = url.startsWith('/');\n const requestUrl = isAbsoluteUrl\n ? url\n : `${reverb.rootEndpoint}${hasSlash ? '' : '/'}${url}`;\n\n const response = await axios.get<T>(requestUrl, {\n headers: reverb.headers,\n ...requestConfig,\n });\n\n return response;\n};\n","import * as methods from './methods';\n\nimport { Axios } from 'axios';\n\nexport type ApiVersion = string;\nexport type ApiKey = string;\nexport type Locale = string;\nexport type ShippingRegion = string;\nexport type DisplayCurrency = string;\nexport type RootEndpoint = Domain;\n\ntype Domain = `${string}.${string}` | `${string}.${string}.${string}`;\n\nexport interface ReverbOptions {\n apiKey: ApiKey;\n version?: ApiVersion | undefined;\n rootEndpoint?: RootEndpoint | undefined;\n displayCurrency?: DisplayCurrency | undefined;\n shippingRegion?: ShippingRegion | undefined;\n locale?: Locale | undefined;\n}\n\nexport type ReverbHeaders = Axios['get']['arguments'][1] & {\n 'Content-Type': string;\n 'Accept-Version': ApiVersion;\n Accept: string;\n 'Accept-Language': Locale;\n 'X-Display-Currency': DisplayCurrency;\n 'X-Shipping-Region'?: ShippingRegion | undefined;\n 'User-Agent'?: string;\n};\n\nexport interface AuthReverbHeaders extends ReverbHeaders {\n Authorization: `Bearer ${ApiKey}`;\n}\n\nexport default class Reverb {\n static defaultHeaders: ReverbHeaders = {\n 'Content-Type': 'application/hal+json',\n 'Accept-Version': '3.0',\n Accept: 'application/hal+json',\n 'Accept-Language': 'en',\n 'X-Display-Currency': 'USD',\n // 'X-Shipping-Region': undefined\n 'User-Agent': 'Reverb Node SDK',\n };\n\n private _rootEndpoint: RootEndpoint = 'https://api.reverb.com/api';\n private _version: ApiVersion = Reverb.defaultHeaders['Accept-Version'];\n private apiKey: string;\n private _headers: AuthReverbHeaders;\n private _displayCurrency: DisplayCurrency =\n Reverb.defaultHeaders['X-Display-Currency'];\n private _shippingRegion: ShippingRegion | undefined;\n private _locale: Locale = Reverb.defaultHeaders['Accept-Language'];\n\n constructor(options: ReverbOptions) {\n const {\n apiKey,\n version,\n rootEndpoint: defaultEndpoint,\n displayCurrency,\n shippingRegion,\n locale,\n } = options;\n\n // throw if no api key\n if (!apiKey || apiKey === '') {\n throw new Error('Reverb: apiKey is required');\n }\n\n // set version and default endpoint if provided\n if (version) {\n this._version = version;\n }\n if (defaultEndpoint) {\n this._rootEndpoint = defaultEndpoint;\n }\n if (displayCurrency) {\n this._displayCurrency = displayCurrency;\n }\n if (shippingRegion) {\n this._shippingRegion = shippingRegion;\n }\n if (locale) {\n this._locale = locale;\n }\n\n // set api key\n this.apiKey = apiKey;\n\n this._headers = {\n ...Reverb.defaultHeaders,\n Authorization: `Bearer ${this.apiKey}`,\n };\n\n this.updateHeaders();\n }\n\n private updateHeaders() {\n const optionalHeaders = {} as any;\n\n if (this._shippingRegion)\n optionalHeaders['X-Shipping-Region'] = this._shippingRegion;\n\n this._headers = {\n ...this._headers,\n Authorization: `Bearer ${this.apiKey}`,\n 'Accept-Version': this._version,\n 'X-Display-Currency': this._displayCurrency,\n 'Accept-Language': this._locale,\n ...optionalHeaders,\n };\n }\n\n set locale(locale: Locale) {\n this._locale = locale;\n this.updateHeaders();\n }\n get locale() {\n return this._locale;\n }\n\n set shippingRegion(shippingRegion: ShippingRegion | undefined) {\n this._shippingRegion = shippingRegion;\n this.updateHeaders();\n }\n get shippingRegion(): ShippingRegion | undefined {\n return this._shippingRegion;\n }\n\n get headers(): AuthReverbHeaders {\n return this._headers;\n }\n\n set displayCurrency(displayCurrency: DisplayCurrency) {\n this._displayCurrency = displayCurrency;\n this.updateHeaders();\n }\n get displayCurrency(): DisplayCurrency {\n return this._displayCurrency;\n }\n\n set version(version: ApiVersion) {\n this._version = version;\n this.updateHeaders();\n }\n get version(): ApiVersion {\n return this._version;\n }\n\n set rootEndpoint(rootEndpoint: RootEndpoint) {\n this._rootEndpoint = rootEndpoint;\n // this.updateHeaders();\n }\n get rootEndpoint(): RootEndpoint {\n return this._rootEndpoint;\n }\n\n /**\n * Retrieves the current user's listings.\n * @param options - Optional parameters for the request.\n * @returns A Promise that resolves to the user's listings. Structured as an axios response\n */\n async getMyListings(options?: methods.GetMyListingsOptions) {\n return await methods.getMyListings(this, options ?? {});\n }\n\n /**\n * Retrieves the orders for the current user.\n * @param options - An optional object containing options for the request.\n * @returns A Promise that resolves with the user's orders. Structured as an axios response\n */\n async getMyOrders(options?: methods.GetMyOrdersOptions) {\n return await methods.getMyOrders(this, options ?? {});\n }\n\n /**\n * Retrieves an arbitrary endpoint using the provided options.\n * @param options - The options to use when retrieving the endpoint.\n * @returns A Promise that resolves with the retrieved endpoint. Structured as an axios response\n */\n async getArbitraryEndpoint(options: methods.GetArbitraryEndpointOptions) {\n return await methods.getArbitraryEndpoint(this, options);\n }\n\n /**\n * Retrieves a single listing based on the provided options.\n * @param options - The options to use when retrieving the listing.\n * @returns A Promise that resolves with the retrieved listing.\n */\n async getOneListing(options: methods.GetOneListingOptions) {\n return await methods.getOneListing(this, options);\n }\n\n /**\n * Retrieves all listings associated with the current user.\n * @param options - An optional object containing options for the request.\n * @returns A Promise that resolves with an array of listings.\n */\n async getAllMyListings(options?: methods.GetAllMyListingsOptions) {\n return await methods.getAllMyListings(this, options ?? {});\n }\n}\n","export * from './Reverb';\n\nimport Reverb from './Reverb';\n\nexport default Reverb;\n"],"mappings":";;;;AAEA,OAAO,WAA8B;AAqB9B,IAAM,gBAAgB,8BAC3B,QACA,YACG;AACH,QAAM,EAAE,MAAM,SAAS,OAAO,MAAM,IAAI;AAExC,QAAM,UAAU,GAAG,OAAO,YAAY;AACtC,QAAM,aAAa,OAAO,SAAS,IAAI,KAAK;AAC5C,QAAM,gBAAgB,UAAU,aAAa,OAAO,KAAK;AACzD,QAAM,cAAc,QAAQ,UAAU,KAAK,KAAK;AAEhD,QAAM,cAAc,QAAQ,UAAU,KAAK,KAAK;AAEhD,QAAM,MAAM,GAAG,OAAO,IAAI,UAAU,GA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,cAAc,MAAM,OAAO;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,iBAAiB,SAA2C;AAChE,WAAO,MAAc,iBAAiB,MAAM,WAAW,CAAC,CAAC;AAAA,EAC3D;AACF;AAvK4B;AAAP,QACZ,iBAAgC;AAAA,EACrC,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EACR,mBAAmB;AAAA,EACnB,sBAAsB;AAAA;AAAA,EAEtB,cAAc;AAChB;AATF,IAAqB,SAArB;;;AChCA,IAAO,cAAQ;","names":["axios","axios","axios","axios"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sound-tank",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A library for interacting with the Reverb Marketplace API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -8,25 +8,29 @@
|
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"author": "Zachary Eggert <Eggert.Zachary@gmail.com>",
|
|
10
10
|
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/ZacharyEggert/sound-tank.git"
|
|
14
|
+
},
|
|
11
15
|
"scripts": {
|
|
12
16
|
"dev": "vitest",
|
|
13
17
|
"test": "vitest run",
|
|
14
|
-
"build": "tsup
|
|
18
|
+
"build": "tsup --config tsup.config.ts",
|
|
15
19
|
"lint": "tsc",
|
|
16
20
|
"ci": "yarn install --frozen-lockfile && yarn lint && yarn test && yarn build",
|
|
17
21
|
"release": "yarn lint && yarn test && yarn build && changeset publish"
|
|
18
22
|
},
|
|
19
23
|
"devDependencies": {
|
|
20
|
-
"@changesets/cli": "^2.26.
|
|
21
|
-
"@types/node": "^20.2
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"vitest": "^0.31.1"
|
|
24
|
+
"@changesets/cli": "^2.26.2",
|
|
25
|
+
"@types/node": "^20.4.2",
|
|
26
|
+
"dotenv": "^16.3.1",
|
|
27
|
+
"prettier": "^3.0.0",
|
|
28
|
+
"tsup": "^7.1.0",
|
|
29
|
+
"typescript": "^5.1.6",
|
|
30
|
+
"vitest": "^0.33.0"
|
|
28
31
|
},
|
|
29
32
|
"dependencies": {
|
|
33
|
+
"@vitest/coverage-v8": "^0.34.6",
|
|
30
34
|
"axios": "^1.4.0"
|
|
31
35
|
}
|
|
32
36
|
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: ['src/index.ts'],
|
|
5
|
+
splitting: true,
|
|
6
|
+
format: ['cjs', 'esm'],
|
|
7
|
+
dts: true,
|
|
8
|
+
sourcemap: true,
|
|
9
|
+
tsconfig: 'tsconfig.json',
|
|
10
|
+
clean: true,
|
|
11
|
+
// target: 'es2015',
|
|
12
|
+
platform: 'node',
|
|
13
|
+
external: ['axios'],
|
|
14
|
+
bundle: true,
|
|
15
|
+
outDir: 'dist',
|
|
16
|
+
keepNames: true,
|
|
17
|
+
});
|