sound-tank 1.0.0 → 1.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/CHANGELOG.md +7 -0
- package/README.md +31 -13
- package/dist/index.d.ts +111 -0
- package/dist/index.js +33 -1
- package/dist/index.mjs +33 -1
- package/package.json +5 -1
package/CHANGELOG.md
ADDED
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/dist/index.d.ts
CHANGED
|
@@ -97,6 +97,101 @@ type Listing = {
|
|
|
97
97
|
}[];
|
|
98
98
|
_links: ListingLinks;
|
|
99
99
|
};
|
|
100
|
+
type OrderStatus = 'unpaid' | '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;
|
|
@@ -106,6 +201,12 @@ interface GetMyListingsOptions {
|
|
|
106
201
|
state?: string;
|
|
107
202
|
}
|
|
108
203
|
|
|
204
|
+
interface GetMyOrdersOptions {
|
|
205
|
+
page?: number;
|
|
206
|
+
perPage?: number;
|
|
207
|
+
status?: Order['status'] | 'all';
|
|
208
|
+
}
|
|
209
|
+
|
|
109
210
|
type PaginatedReverbResponse<T> = T & {
|
|
110
211
|
total: number;
|
|
111
212
|
current_page: number;
|
|
@@ -115,6 +216,12 @@ type PaginatedReverbResponse<T> = T & {
|
|
|
115
216
|
prev?: Link;
|
|
116
217
|
};
|
|
117
218
|
};
|
|
219
|
+
type GetArbitraryEndpointOptions = {
|
|
220
|
+
url: string;
|
|
221
|
+
params?: {
|
|
222
|
+
[key: string]: string;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
118
225
|
|
|
119
226
|
type ApiVersion = string;
|
|
120
227
|
type ApiKey = string;
|
|
@@ -168,6 +275,10 @@ declare class Reverb {
|
|
|
168
275
|
getMyListings(options?: GetMyListingsOptions): Promise<axios.AxiosResponse<PaginatedReverbResponse<{
|
|
169
276
|
listings: Listing[];
|
|
170
277
|
}>, any>>;
|
|
278
|
+
getMyOrders(options?: GetMyOrdersOptions): Promise<axios.AxiosResponse<PaginatedReverbResponse<{
|
|
279
|
+
orders: Order[];
|
|
280
|
+
}>, any>>;
|
|
281
|
+
getArbitraryEndpoint(options: GetArbitraryEndpointOptions): Promise<axios.AxiosResponse<any, any>>;
|
|
171
282
|
}
|
|
172
283
|
|
|
173
284
|
export { ApiKey, ApiVersion, AuthReverbHeaders, DisplayCurrency, Locale, ReverbHeaders, ReverbOptions, RootEndpoint, ShippingRegion, Reverb as default };
|
package/dist/index.js
CHANGED
|
@@ -88,8 +88,30 @@ var getMyListings = (reverb, options) => __async(void 0, null, function* () {
|
|
|
88
88
|
return response;
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
-
// src/methods/
|
|
91
|
+
// src/methods/orders/getOrders.ts
|
|
92
92
|
var import_axios2 = __toESM(require("axios"));
|
|
93
|
+
var getMyOrders = (reverb, options) => __async(void 0, null, function* () {
|
|
94
|
+
const { page, perPage, status } = options;
|
|
95
|
+
const baseUrl = `${reverb.rootEndpoint}/my/orders/selling/${status || "all"}`;
|
|
96
|
+
const pageString = page ? `&page=${page}` : "";
|
|
97
|
+
const perPageString = perPage ? `&per_page=${perPage}` : "";
|
|
98
|
+
const url = `${baseUrl}?${pageString}${perPageString}`;
|
|
99
|
+
const response = yield import_axios2.default.get(url, {
|
|
100
|
+
headers: reverb.headers
|
|
101
|
+
});
|
|
102
|
+
return response;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// src/methods/index.ts
|
|
106
|
+
var import_axios3 = __toESM(require("axios"));
|
|
107
|
+
var getArbitraryEndpoint = (reverb, options) => __async(void 0, null, function* () {
|
|
108
|
+
const { url, params } = options;
|
|
109
|
+
const response = yield import_axios3.default.get(url, {
|
|
110
|
+
headers: reverb.headers,
|
|
111
|
+
params
|
|
112
|
+
});
|
|
113
|
+
return response;
|
|
114
|
+
});
|
|
93
115
|
|
|
94
116
|
// src/Reverb.ts
|
|
95
117
|
var _Reverb = class {
|
|
@@ -183,6 +205,16 @@ var _Reverb = class {
|
|
|
183
205
|
return yield getMyListings(this, options != null ? options : {});
|
|
184
206
|
});
|
|
185
207
|
}
|
|
208
|
+
getMyOrders(options) {
|
|
209
|
+
return __async(this, null, function* () {
|
|
210
|
+
return yield getMyOrders(this, options != null ? options : {});
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
getArbitraryEndpoint(options) {
|
|
214
|
+
return __async(this, null, function* () {
|
|
215
|
+
return yield getArbitraryEndpoint(this, options);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
186
218
|
};
|
|
187
219
|
var Reverb = _Reverb;
|
|
188
220
|
Reverb.defaultHeaders = {
|
package/dist/index.mjs
CHANGED
|
@@ -55,8 +55,30 @@ var getMyListings = (reverb, options) => __async(void 0, null, function* () {
|
|
|
55
55
|
return response;
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
// src/methods/
|
|
58
|
+
// src/methods/orders/getOrders.ts
|
|
59
59
|
import axios2 from "axios";
|
|
60
|
+
var getMyOrders = (reverb, options) => __async(void 0, null, function* () {
|
|
61
|
+
const { page, perPage, status } = options;
|
|
62
|
+
const baseUrl = `${reverb.rootEndpoint}/my/orders/selling/${status || "all"}`;
|
|
63
|
+
const pageString = page ? `&page=${page}` : "";
|
|
64
|
+
const perPageString = perPage ? `&per_page=${perPage}` : "";
|
|
65
|
+
const url = `${baseUrl}?${pageString}${perPageString}`;
|
|
66
|
+
const response = yield axios2.get(url, {
|
|
67
|
+
headers: reverb.headers
|
|
68
|
+
});
|
|
69
|
+
return response;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// src/methods/index.ts
|
|
73
|
+
import axios3 from "axios";
|
|
74
|
+
var getArbitraryEndpoint = (reverb, options) => __async(void 0, null, function* () {
|
|
75
|
+
const { url, params } = options;
|
|
76
|
+
const response = yield axios3.get(url, {
|
|
77
|
+
headers: reverb.headers,
|
|
78
|
+
params
|
|
79
|
+
});
|
|
80
|
+
return response;
|
|
81
|
+
});
|
|
60
82
|
|
|
61
83
|
// src/Reverb.ts
|
|
62
84
|
var _Reverb = class {
|
|
@@ -150,6 +172,16 @@ var _Reverb = class {
|
|
|
150
172
|
return yield getMyListings(this, options != null ? options : {});
|
|
151
173
|
});
|
|
152
174
|
}
|
|
175
|
+
getMyOrders(options) {
|
|
176
|
+
return __async(this, null, function* () {
|
|
177
|
+
return yield getMyOrders(this, options != null ? options : {});
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
getArbitraryEndpoint(options) {
|
|
181
|
+
return __async(this, null, function* () {
|
|
182
|
+
return yield getArbitraryEndpoint(this, options);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
153
185
|
};
|
|
154
186
|
var Reverb = _Reverb;
|
|
155
187
|
Reverb.defaultHeaders = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sound-tank",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.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,6 +8,10 @@
|
|
|
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",
|