sound-tank 1.0.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 +2 -0
- package/LICENSE +21 -0
- package/README.md +19 -0
- package/dist/index.d.ts +173 -0
- package/dist/index.js +201 -0
- package/dist/index.mjs +169 -0
- package/package.json +32 -0
package/.env.example
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Zachary Eggert
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Library Template
|
|
2
|
+
|
|
3
|
+
This is a template for a typescript library.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
- Use this template to create a new repository
|
|
8
|
+
- Clone the repository
|
|
9
|
+
- Run `yarn install`
|
|
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
|
|
14
|
+
|
|
15
|
+
## Links
|
|
16
|
+
|
|
17
|
+
- [Github](https://github.com/ZacharyEggert/library-template)
|
|
18
|
+
|
|
19
|
+
- [NPM](https://www.npmjs.com/package/@zacharyeggert/library-template)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
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
|
+
|
|
101
|
+
interface GetMyListingsOptions {
|
|
102
|
+
page?: number;
|
|
103
|
+
perPage?: number;
|
|
104
|
+
query?: string;
|
|
105
|
+
sku?: string;
|
|
106
|
+
state?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
type PaginatedReverbResponse<T> = T & {
|
|
110
|
+
total: number;
|
|
111
|
+
current_page: number;
|
|
112
|
+
total_pages: number;
|
|
113
|
+
_links: {
|
|
114
|
+
next?: Link;
|
|
115
|
+
prev?: Link;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
type ApiVersion = string;
|
|
120
|
+
type ApiKey = string;
|
|
121
|
+
type Locale = string;
|
|
122
|
+
type ShippingRegion = string;
|
|
123
|
+
type DisplayCurrency = string;
|
|
124
|
+
type RootEndpoint = Domain;
|
|
125
|
+
type Domain = `${string}.${string}` | `${string}.${string}.${string}`;
|
|
126
|
+
interface ReverbOptions {
|
|
127
|
+
apiKey: ApiKey;
|
|
128
|
+
version?: ApiVersion | undefined;
|
|
129
|
+
rootEndpoint?: RootEndpoint | undefined;
|
|
130
|
+
displayCurrency?: DisplayCurrency | undefined;
|
|
131
|
+
shippingRegion?: ShippingRegion | undefined;
|
|
132
|
+
locale?: Locale | undefined;
|
|
133
|
+
}
|
|
134
|
+
type ReverbHeaders = Axios['get']['arguments'][1] & {
|
|
135
|
+
'Content-Type': string;
|
|
136
|
+
'Accept-Version': ApiVersion;
|
|
137
|
+
Accept: string;
|
|
138
|
+
'Accept-Language': Locale;
|
|
139
|
+
'X-Display-Currency': DisplayCurrency;
|
|
140
|
+
'X-Shipping-Region'?: ShippingRegion | undefined;
|
|
141
|
+
'User-Agent'?: string;
|
|
142
|
+
};
|
|
143
|
+
interface AuthReverbHeaders extends ReverbHeaders {
|
|
144
|
+
Authorization: `Bearer ${ApiKey}`;
|
|
145
|
+
}
|
|
146
|
+
declare class Reverb {
|
|
147
|
+
static defaultHeaders: ReverbHeaders;
|
|
148
|
+
private _rootEndpoint;
|
|
149
|
+
private _version;
|
|
150
|
+
private apiKey;
|
|
151
|
+
private _headers;
|
|
152
|
+
private _displayCurrency;
|
|
153
|
+
private _shippingRegion;
|
|
154
|
+
private _locale;
|
|
155
|
+
constructor(options: ReverbOptions);
|
|
156
|
+
private updateHeaders;
|
|
157
|
+
set locale(locale: Locale);
|
|
158
|
+
get locale(): Locale;
|
|
159
|
+
set shippingRegion(shippingRegion: ShippingRegion | undefined);
|
|
160
|
+
get shippingRegion(): ShippingRegion | undefined;
|
|
161
|
+
get headers(): AuthReverbHeaders;
|
|
162
|
+
set displayCurrency(displayCurrency: DisplayCurrency);
|
|
163
|
+
get displayCurrency(): DisplayCurrency;
|
|
164
|
+
set version(version: ApiVersion);
|
|
165
|
+
get version(): ApiVersion;
|
|
166
|
+
set rootEndpoint(rootEndpoint: RootEndpoint);
|
|
167
|
+
get rootEndpoint(): RootEndpoint;
|
|
168
|
+
getMyListings(options?: GetMyListingsOptions): Promise<axios.AxiosResponse<PaginatedReverbResponse<{
|
|
169
|
+
listings: Listing[];
|
|
170
|
+
}>, any>>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export { ApiKey, ApiVersion, AuthReverbHeaders, DisplayCurrency, Locale, ReverbHeaders, ReverbOptions, RootEndpoint, ShippingRegion, Reverb as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
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);
|
|
73
|
+
|
|
74
|
+
// src/methods/listings/getListings.ts
|
|
75
|
+
var import_axios = __toESM(require("axios"));
|
|
76
|
+
var getMyListings = (reverb, options) => __async(void 0, null, function* () {
|
|
77
|
+
const { page, perPage, query, sku, state } = options;
|
|
78
|
+
const baseUrl = `${reverb.rootEndpoint}/my/listings`;
|
|
79
|
+
const pageString = page ? `&page=${page}` : "";
|
|
80
|
+
const perPageString = perPage ? `&per_page=${perPage}` : "";
|
|
81
|
+
const queryString = query ? `&query=${query}` : "";
|
|
82
|
+
const skuString = sku ? `&sku=${sku}` : "";
|
|
83
|
+
const stateString = state ? `&state=${state}` : "";
|
|
84
|
+
const url = `${baseUrl}?${pageString}${perPageString}${queryString}${skuString}${stateString}`;
|
|
85
|
+
const response = yield import_axios.default.get(url, {
|
|
86
|
+
headers: reverb.headers
|
|
87
|
+
});
|
|
88
|
+
return response;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// src/methods/index.ts
|
|
92
|
+
var import_axios2 = __toESM(require("axios"));
|
|
93
|
+
|
|
94
|
+
// src/Reverb.ts
|
|
95
|
+
var _Reverb = class {
|
|
96
|
+
constructor(options) {
|
|
97
|
+
this._rootEndpoint = "https://api.reverb.com/api";
|
|
98
|
+
this._version = _Reverb.defaultHeaders["Accept-Version"];
|
|
99
|
+
this._displayCurrency = _Reverb.defaultHeaders["X-Display-Currency"];
|
|
100
|
+
this._locale = _Reverb.defaultHeaders["Accept-Language"];
|
|
101
|
+
const {
|
|
102
|
+
apiKey,
|
|
103
|
+
version,
|
|
104
|
+
rootEndpoint: defaultEndpoint,
|
|
105
|
+
displayCurrency,
|
|
106
|
+
shippingRegion,
|
|
107
|
+
locale
|
|
108
|
+
} = options;
|
|
109
|
+
if (!apiKey || apiKey === "") {
|
|
110
|
+
throw new Error("Reverb: apiKey is required");
|
|
111
|
+
}
|
|
112
|
+
if (version) {
|
|
113
|
+
this._version = version;
|
|
114
|
+
}
|
|
115
|
+
if (defaultEndpoint) {
|
|
116
|
+
this._rootEndpoint = defaultEndpoint;
|
|
117
|
+
}
|
|
118
|
+
if (displayCurrency) {
|
|
119
|
+
this._displayCurrency = displayCurrency;
|
|
120
|
+
}
|
|
121
|
+
if (shippingRegion) {
|
|
122
|
+
this._shippingRegion = shippingRegion;
|
|
123
|
+
}
|
|
124
|
+
if (locale) {
|
|
125
|
+
this._locale = locale;
|
|
126
|
+
}
|
|
127
|
+
this.apiKey = apiKey;
|
|
128
|
+
this._headers = __spreadProps(__spreadValues({}, _Reverb.defaultHeaders), {
|
|
129
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
130
|
+
});
|
|
131
|
+
this.updateHeaders();
|
|
132
|
+
}
|
|
133
|
+
updateHeaders() {
|
|
134
|
+
const optionalHeaders = {};
|
|
135
|
+
if (this._shippingRegion)
|
|
136
|
+
optionalHeaders["X-Shipping-Region"] = this._shippingRegion;
|
|
137
|
+
this._headers = __spreadValues(__spreadProps(__spreadValues({}, this._headers), {
|
|
138
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
139
|
+
"Accept-Version": this._version,
|
|
140
|
+
"X-Display-Currency": this._displayCurrency,
|
|
141
|
+
"Accept-Language": this._locale
|
|
142
|
+
}), optionalHeaders);
|
|
143
|
+
}
|
|
144
|
+
set locale(locale) {
|
|
145
|
+
this._locale = locale;
|
|
146
|
+
this.updateHeaders();
|
|
147
|
+
}
|
|
148
|
+
get locale() {
|
|
149
|
+
return this._locale;
|
|
150
|
+
}
|
|
151
|
+
set shippingRegion(shippingRegion) {
|
|
152
|
+
this._shippingRegion = shippingRegion;
|
|
153
|
+
this.updateHeaders();
|
|
154
|
+
}
|
|
155
|
+
get shippingRegion() {
|
|
156
|
+
return this._shippingRegion;
|
|
157
|
+
}
|
|
158
|
+
get headers() {
|
|
159
|
+
return this._headers;
|
|
160
|
+
}
|
|
161
|
+
set displayCurrency(displayCurrency) {
|
|
162
|
+
this._displayCurrency = displayCurrency;
|
|
163
|
+
this.updateHeaders();
|
|
164
|
+
}
|
|
165
|
+
get displayCurrency() {
|
|
166
|
+
return this._displayCurrency;
|
|
167
|
+
}
|
|
168
|
+
set version(version) {
|
|
169
|
+
this._version = version;
|
|
170
|
+
this.updateHeaders();
|
|
171
|
+
}
|
|
172
|
+
get version() {
|
|
173
|
+
return this._version;
|
|
174
|
+
}
|
|
175
|
+
set rootEndpoint(rootEndpoint) {
|
|
176
|
+
this._rootEndpoint = rootEndpoint;
|
|
177
|
+
}
|
|
178
|
+
get rootEndpoint() {
|
|
179
|
+
return this._rootEndpoint;
|
|
180
|
+
}
|
|
181
|
+
getMyListings(options) {
|
|
182
|
+
return __async(this, null, function* () {
|
|
183
|
+
return yield getMyListings(this, options != null ? options : {});
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
var Reverb = _Reverb;
|
|
188
|
+
Reverb.defaultHeaders = {
|
|
189
|
+
"Content-Type": "application/hal+json",
|
|
190
|
+
"Accept-Version": "3.0",
|
|
191
|
+
Accept: "application/hal+json",
|
|
192
|
+
"Accept-Language": "en",
|
|
193
|
+
"X-Display-Currency": "USD",
|
|
194
|
+
// 'X-Shipping-Region': undefined
|
|
195
|
+
"User-Agent": "Reverb Node SDK"
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// src/index.ts
|
|
199
|
+
var src_default = Reverb;
|
|
200
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
201
|
+
0 && (module.exports = {});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
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
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/methods/listings/getListings.ts
|
|
42
|
+
import axios from "axios";
|
|
43
|
+
var getMyListings = (reverb, options) => __async(void 0, null, function* () {
|
|
44
|
+
const { page, perPage, query, sku, state } = options;
|
|
45
|
+
const baseUrl = `${reverb.rootEndpoint}/my/listings`;
|
|
46
|
+
const pageString = page ? `&page=${page}` : "";
|
|
47
|
+
const perPageString = perPage ? `&per_page=${perPage}` : "";
|
|
48
|
+
const queryString = query ? `&query=${query}` : "";
|
|
49
|
+
const skuString = sku ? `&sku=${sku}` : "";
|
|
50
|
+
const stateString = state ? `&state=${state}` : "";
|
|
51
|
+
const url = `${baseUrl}?${pageString}${perPageString}${queryString}${skuString}${stateString}`;
|
|
52
|
+
const response = yield axios.get(url, {
|
|
53
|
+
headers: reverb.headers
|
|
54
|
+
});
|
|
55
|
+
return response;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// src/methods/index.ts
|
|
59
|
+
import axios2 from "axios";
|
|
60
|
+
|
|
61
|
+
// src/Reverb.ts
|
|
62
|
+
var _Reverb = class {
|
|
63
|
+
constructor(options) {
|
|
64
|
+
this._rootEndpoint = "https://api.reverb.com/api";
|
|
65
|
+
this._version = _Reverb.defaultHeaders["Accept-Version"];
|
|
66
|
+
this._displayCurrency = _Reverb.defaultHeaders["X-Display-Currency"];
|
|
67
|
+
this._locale = _Reverb.defaultHeaders["Accept-Language"];
|
|
68
|
+
const {
|
|
69
|
+
apiKey,
|
|
70
|
+
version,
|
|
71
|
+
rootEndpoint: defaultEndpoint,
|
|
72
|
+
displayCurrency,
|
|
73
|
+
shippingRegion,
|
|
74
|
+
locale
|
|
75
|
+
} = options;
|
|
76
|
+
if (!apiKey || apiKey === "") {
|
|
77
|
+
throw new Error("Reverb: apiKey is required");
|
|
78
|
+
}
|
|
79
|
+
if (version) {
|
|
80
|
+
this._version = version;
|
|
81
|
+
}
|
|
82
|
+
if (defaultEndpoint) {
|
|
83
|
+
this._rootEndpoint = defaultEndpoint;
|
|
84
|
+
}
|
|
85
|
+
if (displayCurrency) {
|
|
86
|
+
this._displayCurrency = displayCurrency;
|
|
87
|
+
}
|
|
88
|
+
if (shippingRegion) {
|
|
89
|
+
this._shippingRegion = shippingRegion;
|
|
90
|
+
}
|
|
91
|
+
if (locale) {
|
|
92
|
+
this._locale = locale;
|
|
93
|
+
}
|
|
94
|
+
this.apiKey = apiKey;
|
|
95
|
+
this._headers = __spreadProps(__spreadValues({}, _Reverb.defaultHeaders), {
|
|
96
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
97
|
+
});
|
|
98
|
+
this.updateHeaders();
|
|
99
|
+
}
|
|
100
|
+
updateHeaders() {
|
|
101
|
+
const optionalHeaders = {};
|
|
102
|
+
if (this._shippingRegion)
|
|
103
|
+
optionalHeaders["X-Shipping-Region"] = this._shippingRegion;
|
|
104
|
+
this._headers = __spreadValues(__spreadProps(__spreadValues({}, this._headers), {
|
|
105
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
106
|
+
"Accept-Version": this._version,
|
|
107
|
+
"X-Display-Currency": this._displayCurrency,
|
|
108
|
+
"Accept-Language": this._locale
|
|
109
|
+
}), optionalHeaders);
|
|
110
|
+
}
|
|
111
|
+
set locale(locale) {
|
|
112
|
+
this._locale = locale;
|
|
113
|
+
this.updateHeaders();
|
|
114
|
+
}
|
|
115
|
+
get locale() {
|
|
116
|
+
return this._locale;
|
|
117
|
+
}
|
|
118
|
+
set shippingRegion(shippingRegion) {
|
|
119
|
+
this._shippingRegion = shippingRegion;
|
|
120
|
+
this.updateHeaders();
|
|
121
|
+
}
|
|
122
|
+
get shippingRegion() {
|
|
123
|
+
return this._shippingRegion;
|
|
124
|
+
}
|
|
125
|
+
get headers() {
|
|
126
|
+
return this._headers;
|
|
127
|
+
}
|
|
128
|
+
set displayCurrency(displayCurrency) {
|
|
129
|
+
this._displayCurrency = displayCurrency;
|
|
130
|
+
this.updateHeaders();
|
|
131
|
+
}
|
|
132
|
+
get displayCurrency() {
|
|
133
|
+
return this._displayCurrency;
|
|
134
|
+
}
|
|
135
|
+
set version(version) {
|
|
136
|
+
this._version = version;
|
|
137
|
+
this.updateHeaders();
|
|
138
|
+
}
|
|
139
|
+
get version() {
|
|
140
|
+
return this._version;
|
|
141
|
+
}
|
|
142
|
+
set rootEndpoint(rootEndpoint) {
|
|
143
|
+
this._rootEndpoint = rootEndpoint;
|
|
144
|
+
}
|
|
145
|
+
get rootEndpoint() {
|
|
146
|
+
return this._rootEndpoint;
|
|
147
|
+
}
|
|
148
|
+
getMyListings(options) {
|
|
149
|
+
return __async(this, null, function* () {
|
|
150
|
+
return yield getMyListings(this, options != null ? options : {});
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var Reverb = _Reverb;
|
|
155
|
+
Reverb.defaultHeaders = {
|
|
156
|
+
"Content-Type": "application/hal+json",
|
|
157
|
+
"Accept-Version": "3.0",
|
|
158
|
+
Accept: "application/hal+json",
|
|
159
|
+
"Accept-Language": "en",
|
|
160
|
+
"X-Display-Currency": "USD",
|
|
161
|
+
// 'X-Shipping-Region': undefined
|
|
162
|
+
"User-Agent": "Reverb Node SDK"
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// src/index.ts
|
|
166
|
+
var src_default = Reverb;
|
|
167
|
+
export {
|
|
168
|
+
src_default as default
|
|
169
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sound-tank",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A library for interacting with the Reverb Marketplace API",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"private": false,
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"author": "Zachary Eggert <Eggert.Zachary@gmail.com>",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev": "vitest",
|
|
13
|
+
"test": "vitest run",
|
|
14
|
+
"build": "tsup src/index.ts --dts --format cjs,esm",
|
|
15
|
+
"lint": "tsc",
|
|
16
|
+
"ci": "yarn install --frozen-lockfile && yarn lint && yarn test && yarn build",
|
|
17
|
+
"release": "yarn lint && yarn test && yarn build && changeset publish"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@changesets/cli": "^2.26.1",
|
|
21
|
+
"@types/node": "^20.2.1",
|
|
22
|
+
"@vitest/coverage-c8": "^0.31.1",
|
|
23
|
+
"dotenv": "^16.0.3",
|
|
24
|
+
"prettier": "^2.8.8",
|
|
25
|
+
"tsup": "^6.7.0",
|
|
26
|
+
"typescript": "^5.0.4",
|
|
27
|
+
"vitest": "^0.31.1"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"axios": "^1.4.0"
|
|
31
|
+
}
|
|
32
|
+
}
|