ebay-api 8.7.2-RC.0 → 9.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/README.md +8 -7
- package/dist/api/digitalSignature.js +3 -2
- package/dist/api/restful/index.js +2 -2
- package/dist/api/restful/sell/metadata/index.d.ts +2 -0
- package/dist/api/restful/sell/metadata/index.js +12 -0
- package/dist/api/traditional/XMLRequest.js +4 -4
- package/dist/api/traditional/index.js +2 -2
- package/dist/auth/oAuth2.d.ts +8 -8
- package/dist/auth/oAuth2.js +12 -12
- package/dist/ebay-api.min.mjs +1 -1
- package/dist/errors/index.d.ts +105 -25
- package/dist/errors/index.js +143 -123
- package/dist/request.d.ts +6 -6
- package/dist/types/restful/specs/sell_metadata_v1_oas3.d.ts +107 -22
- package/lib/api/digitalSignature.js +3 -2
- package/lib/api/restful/index.js +2 -2
- package/lib/api/restful/sell/metadata/index.d.ts +2 -0
- package/lib/api/restful/sell/metadata/index.js +12 -0
- package/lib/api/traditional/XMLRequest.js +3 -3
- package/lib/api/traditional/index.js +2 -2
- package/lib/auth/oAuth2.d.ts +8 -8
- package/lib/auth/oAuth2.js +12 -12
- package/lib/ebay-api.min.js +1 -1
- package/lib/errors/index.d.ts +105 -25
- package/lib/errors/index.js +148 -129
- package/lib/request.d.ts +6 -6
- package/lib/types/restful/specs/sell_metadata_v1_oas3.d.ts +107 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@ It supports `client credentials grant` and `authorization code grant` \(Auth'N'A
|
|
|
18
18
|
|
|
19
19
|
* [eBay API Explorer](https://developer.ebay.com/my/api_test_tool)
|
|
20
20
|
* [eBay API Docs](https://developer.ebay.com/docs)
|
|
21
|
+
* [eBay API Status](https://entwickler.ebay.de/support/api-status/production)
|
|
21
22
|
|
|
22
23
|
## Changelog
|
|
23
24
|
|
|
@@ -34,7 +35,7 @@ It supports `client credentials grant` and `authorization code grant` \(Auth'N'A
|
|
|
34
35
|
| **Commerce API** | ✔ Catalog API `v1_beta.3.1`<br>✔ Charity API `v1.2.0`<br>✔ Identity API `v1.0.0`<br>✔ Notification API `v1.2.0`<br>✔ Taxonomy API `v1.0.0`<br>✔ Translation API `v1_beta.1.4`<br>✔ Media API `v1_beta.1.0` |
|
|
35
36
|
| **Developer API** | ✔ Analytics API |
|
|
36
37
|
| **Post Order API** | ✔ Cancellation API<br>✔ Case Management API<br>✔ Inquiry API<br>✔ Return API |
|
|
37
|
-
| **Sell API** | ✔ Account API `v1.9.0`<br>✔ Analytics API `v1.3.0`<br>✔ Compliance API `v1.4.1`<br>✔ Feed API `v1.3.1`<br>✔ Finance API `v1.9.0`<br>✔ Fulfillment API `v1.19.10`<br>✔ Inventory API `v1.14.0`<br>✔ Listing API `v1_beta.2.1`<br>✔ Logistics API `v1_beta.0.0`<br>✔ Marketing API `v1.17.0`<br>✔ Metadata API `v1.
|
|
38
|
+
| **Sell API** | ✔ Account API `v1.9.0`<br>✔ Analytics API `v1.3.0`<br>✔ Compliance API `v1.4.1`<br>✔ Feed API `v1.3.1`<br>✔ Finance API `v1.9.0`<br>✔ Fulfillment API `v1.19.10`<br>✔ Inventory API `v1.14.0`<br>✔ Listing API `v1_beta.2.1`<br>✔ Logistics API `v1_beta.0.0`<br>✔ Marketing API `v1.17.0`<br>✔ Metadata API `v1.7.1`<br>✔ Negotiation API `v1.1.0`<br>✔ Recommendation API `v1.1.0` |
|
|
38
39
|
|
|
39
40
|
### Traditional API
|
|
40
41
|
|
|
@@ -270,8 +271,8 @@ app.get('/success', async function (req, res) {
|
|
|
270
271
|
// 5. Start using the API
|
|
271
272
|
const orders = await eBay.sell.fulfillment.getOrders()
|
|
272
273
|
res.send(orders);
|
|
273
|
-
} catch (
|
|
274
|
-
console.error(
|
|
274
|
+
} catch (error) {
|
|
275
|
+
console.error(error)
|
|
275
276
|
res.sendStatus(400)
|
|
276
277
|
}
|
|
277
278
|
});
|
|
@@ -301,8 +302,8 @@ app.get('/orders/:id', async function (req, res) {
|
|
|
301
302
|
// 5. Start using the API
|
|
302
303
|
const order = await eBay.sell.fulfillment.getOrder(id);
|
|
303
304
|
res.send(order);
|
|
304
|
-
} catch (
|
|
305
|
-
console.error(
|
|
305
|
+
} catch (error) {
|
|
306
|
+
console.error(error)
|
|
306
307
|
res.sendStatus(400)
|
|
307
308
|
}
|
|
308
309
|
});
|
|
@@ -492,8 +493,8 @@ try {
|
|
|
492
493
|
const result = await toString(data);
|
|
493
494
|
|
|
494
495
|
console.log(result)
|
|
495
|
-
} catch (
|
|
496
|
-
console.error(
|
|
496
|
+
} catch (error) {
|
|
497
|
+
console.error(error);
|
|
497
498
|
}
|
|
498
499
|
```
|
|
499
500
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash, sign } from 'crypto';
|
|
2
|
+
import { EBayError } from '../errors/index.js';
|
|
2
3
|
const beginPrivateKey = '-----BEGIN PRIVATE KEY-----';
|
|
3
4
|
const endPrivateKey = '-----END PRIVATE KEY-----';
|
|
4
5
|
export const getUnixTimestamp = () => Math.floor(Date.now() / 1000);
|
|
@@ -48,8 +49,8 @@ export function generateBaseString(headers, signatureComponents, payload, timest
|
|
|
48
49
|
baseString += `"@signature-params": (${getSignatureParamsValue(payload)});created=${timestamp}`;
|
|
49
50
|
return baseString;
|
|
50
51
|
}
|
|
51
|
-
catch (
|
|
52
|
-
throw new
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new EBayError(`Error calculating signature base: ${error.message}`);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
export const generateSignatureInput = (payload, timestamp = getUnixTimestamp()) => `sig1=(${getSignatureParamsValue(payload)});created=${timestamp}`;
|
|
@@ -5,9 +5,11 @@ export default class Metadata extends Restful implements OpenApi<operations> {
|
|
|
5
5
|
get basePath(): string;
|
|
6
6
|
getSalesTaxJurisdictions(countryCode: string): Promise<any>;
|
|
7
7
|
getAutomotivePartsCompatibilityPolicies(marketplaceId: string, filter?: string): Promise<any>;
|
|
8
|
+
getExtendedProducerResponsibilityPolicies(marketplaceId: string, filter?: string): Promise<any>;
|
|
8
9
|
getItemConditionPolicies(marketplaceId: string, filter?: string): Promise<any>;
|
|
9
10
|
getListingStructurePolicies(marketplaceId: string, filter?: string): Promise<any>;
|
|
10
11
|
getNegotiatedPricePolicies(marketplaceId: string, filter?: string): Promise<any>;
|
|
11
12
|
getProductAdoptionPolicies(marketplaceId: string, filter?: string): Promise<any>;
|
|
12
13
|
getReturnPolicies(marketplaceId: string, filter?: string): Promise<any>;
|
|
14
|
+
getHazardousMaterialsLabels(marketplaceId: string): Promise<any>;
|
|
13
15
|
}
|
|
@@ -15,6 +15,14 @@ class Metadata extends Restful {
|
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
+
getExtendedProducerResponsibilityPolicies(marketplaceId, filter) {
|
|
19
|
+
marketplaceId = encodeURIComponent(marketplaceId);
|
|
20
|
+
return this.get(`/marketplace/${marketplaceId}/get_extended_producer_responsibility_policies`, {
|
|
21
|
+
params: {
|
|
22
|
+
filter
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
18
26
|
getItemConditionPolicies(marketplaceId, filter) {
|
|
19
27
|
marketplaceId = encodeURIComponent(marketplaceId);
|
|
20
28
|
return this.get(`/marketplace/${marketplaceId}/get_item_condition_policies`, {
|
|
@@ -55,6 +63,10 @@ class Metadata extends Restful {
|
|
|
55
63
|
}
|
|
56
64
|
});
|
|
57
65
|
}
|
|
66
|
+
getHazardousMaterialsLabels(marketplaceId) {
|
|
67
|
+
marketplaceId = encodeURIComponent(marketplaceId);
|
|
68
|
+
return this.get(`/marketplace/${marketplaceId}/get_hazardous_materials_labels`);
|
|
69
|
+
}
|
|
58
70
|
}
|
|
59
71
|
Metadata.id = 'Metadata';
|
|
60
72
|
export default Metadata;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import debug from 'debug';
|
|
2
2
|
import { XMLBuilder, XMLParser } from 'fast-xml-parser';
|
|
3
|
-
import {
|
|
3
|
+
import { checkEBayTraditionalResponse, EBayNoCallError } from '../../errors/index.js';
|
|
4
4
|
const log = debug('ebay:xml:request');
|
|
5
5
|
export const defaultJSON2XMLOptions = {
|
|
6
6
|
attributeNamePrefix: '@_',
|
|
@@ -42,7 +42,7 @@ export const defaultHeaders = {
|
|
|
42
42
|
class XMLRequest {
|
|
43
43
|
constructor(callName, fields, config, req) {
|
|
44
44
|
if (!callName) {
|
|
45
|
-
throw new
|
|
45
|
+
throw new EBayNoCallError();
|
|
46
46
|
}
|
|
47
47
|
this.callName = callName;
|
|
48
48
|
this.fields = fields || {};
|
|
@@ -109,14 +109,14 @@ class XMLRequest {
|
|
|
109
109
|
return data;
|
|
110
110
|
}
|
|
111
111
|
const json = this.xml2JSON(data);
|
|
112
|
-
|
|
112
|
+
checkEBayTraditionalResponse(response, json);
|
|
113
113
|
return json;
|
|
114
114
|
}
|
|
115
115
|
catch (error) {
|
|
116
116
|
log('error', error);
|
|
117
117
|
if (error.response?.data) {
|
|
118
118
|
const json = this.toJSON(error.response.data);
|
|
119
|
-
|
|
119
|
+
checkEBayTraditionalResponse(error.response, json);
|
|
120
120
|
}
|
|
121
121
|
throw error;
|
|
122
122
|
}
|
|
@@ -157,8 +157,8 @@ export default class Traditional extends Api {
|
|
|
157
157
|
const xmlRequest = new XMLRequest(callName, fields, config, this.req);
|
|
158
158
|
return await xmlRequest.request();
|
|
159
159
|
}
|
|
160
|
-
catch (
|
|
161
|
-
handleEBayError(
|
|
160
|
+
catch (error) {
|
|
161
|
+
handleEBayError(error);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
async getConfig(api, callName, apiConfig) {
|
package/dist/auth/oAuth2.d.ts
CHANGED
|
@@ -4,13 +4,13 @@ import { IEBayApiRequest } from '../request.js';
|
|
|
4
4
|
import { AppConfig, Scope } from '../types/index.js';
|
|
5
5
|
export type Token = {
|
|
6
6
|
access_token: string;
|
|
7
|
-
expires_in
|
|
8
|
-
token_type
|
|
7
|
+
expires_in?: number;
|
|
8
|
+
token_type?: string;
|
|
9
9
|
};
|
|
10
10
|
export type ClientToken = Token;
|
|
11
11
|
export type AuthToken = Token & {
|
|
12
12
|
refresh_token: string;
|
|
13
|
-
refresh_token_expires_in
|
|
13
|
+
refresh_token_expires_in?: number;
|
|
14
14
|
};
|
|
15
15
|
export default class OAuth2 extends Base {
|
|
16
16
|
static readonly IDENTITY_ENDPOINT: Record<string, string>;
|
|
@@ -22,19 +22,19 @@ export default class OAuth2 extends Base {
|
|
|
22
22
|
private _authToken?;
|
|
23
23
|
constructor(config: AppConfig, req: IEBayApiRequest);
|
|
24
24
|
on(event: string, callback: EventCallback): () => void;
|
|
25
|
-
static generateAuthUrl(sandbox: boolean, appId: string, ruName: string, scope: string[], state?: string): string;
|
|
26
25
|
get identityEndpoint(): string;
|
|
26
|
+
static generateAuthUrl(sandbox: boolean, appId: string, ruName: string, scope: string[], state?: string): string;
|
|
27
|
+
generateAuthUrl(ruName?: string, scope?: string[], state?: string): string;
|
|
27
28
|
getAccessToken(): Promise<string>;
|
|
28
29
|
getUserAccessToken(): string | null;
|
|
29
30
|
getApplicationAccessToken(): Promise<string>;
|
|
31
|
+
getScope(): string[];
|
|
30
32
|
setClientToken(clientToken?: Token): void;
|
|
31
33
|
setScope(scope: Scope): void;
|
|
32
|
-
getScope(): string[];
|
|
33
34
|
mintApplicationAccessToken(): Promise<ClientToken>;
|
|
34
35
|
obtainApplicationAccessToken(): Promise<ClientToken>;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
getToken(code: string, ruName?: string | undefined): Promise<any>;
|
|
36
|
+
mintUserAccessToken(code: string, ruName?: string | undefined): Promise<AuthToken>;
|
|
37
|
+
getToken(code: string, ruName?: string | undefined): Promise<AuthToken>;
|
|
38
38
|
refreshUserAccessToken(): Promise<AuthToken>;
|
|
39
39
|
obtainToken(code: string): Promise<AuthToken>;
|
|
40
40
|
getCredentials(): AuthToken | ClientToken | null;
|
package/dist/auth/oAuth2.js
CHANGED
|
@@ -11,6 +11,9 @@ class OAuth2 extends Base {
|
|
|
11
11
|
on(event, callback) {
|
|
12
12
|
return this.emitter.on(event, callback);
|
|
13
13
|
}
|
|
14
|
+
get identityEndpoint() {
|
|
15
|
+
return this.config.sandbox ? OAuth2.IDENTITY_ENDPOINT.sandbox : OAuth2.IDENTITY_ENDPOINT.production;
|
|
16
|
+
}
|
|
14
17
|
static generateAuthUrl(sandbox, appId, ruName, scope, state = '') {
|
|
15
18
|
return [
|
|
16
19
|
sandbox ? OAuth2.AUTHORIZE_ENDPOINT.sandbox : OAuth2.AUTHORIZE_ENDPOINT.production,
|
|
@@ -21,8 +24,12 @@ class OAuth2 extends Base {
|
|
|
21
24
|
'&scope=', encodeURIComponent(scope.join(' '))
|
|
22
25
|
].join('');
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
generateAuthUrl(ruName, scope = this.scope, state = '') {
|
|
28
|
+
ruName = ruName || this.config.ruName;
|
|
29
|
+
if (!ruName) {
|
|
30
|
+
throw new Error('RuName is required.');
|
|
31
|
+
}
|
|
32
|
+
return OAuth2.generateAuthUrl(this.config.sandbox, this.config.appId, ruName, scope, state);
|
|
26
33
|
}
|
|
27
34
|
async getAccessToken() {
|
|
28
35
|
return this.getUserAccessToken() || this.getApplicationAccessToken();
|
|
@@ -43,15 +50,15 @@ class OAuth2 extends Base {
|
|
|
43
50
|
throw error;
|
|
44
51
|
}
|
|
45
52
|
}
|
|
53
|
+
getScope() {
|
|
54
|
+
return [...this.scope];
|
|
55
|
+
}
|
|
46
56
|
setClientToken(clientToken) {
|
|
47
57
|
this._clientToken = clientToken;
|
|
48
58
|
}
|
|
49
59
|
setScope(scope) {
|
|
50
60
|
this.scope = scope;
|
|
51
61
|
}
|
|
52
|
-
getScope() {
|
|
53
|
-
return [...this.scope];
|
|
54
|
-
}
|
|
55
62
|
async mintApplicationAccessToken() {
|
|
56
63
|
if (!this.config.appId) {
|
|
57
64
|
throw new Error('Missing App ID (Client Id)');
|
|
@@ -90,13 +97,6 @@ class OAuth2 extends Base {
|
|
|
90
97
|
throw error;
|
|
91
98
|
}
|
|
92
99
|
}
|
|
93
|
-
generateAuthUrl(ruName, scope = this.scope, state = '') {
|
|
94
|
-
ruName = ruName || this.config.ruName;
|
|
95
|
-
if (!ruName) {
|
|
96
|
-
throw new Error('RuName is required.');
|
|
97
|
-
}
|
|
98
|
-
return OAuth2.generateAuthUrl(this.config.sandbox, this.config.appId, ruName, scope, state);
|
|
99
|
-
}
|
|
100
100
|
async mintUserAccessToken(code, ruName = this.config.ruName) {
|
|
101
101
|
if (!this.config.appId) {
|
|
102
102
|
throw new Error('Missing App ID (Client Id)');
|