ebay-mcp 1.8.9 → 1.9.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 +88 -504
- package/build/api/account-management/account.js +50 -49
- package/build/api/analytics-and-report/analytics.js +5 -24
- package/build/api/client-trading.js +25 -15
- package/build/api/client.js +158 -185
- package/build/api/communication/feedback.js +9 -23
- package/build/api/communication/message.js +4 -18
- package/build/api/communication/negotiation.js +3 -13
- package/build/api/communication/shared.js +1 -2
- package/build/api/developer/developer.js +7 -6
- package/build/api/listing-management/inventory.js +1 -2
- package/build/api/listing-metadata/taxonomy.js +14 -9
- package/build/api/marketing-and-promotions/marketing.js +149 -177
- package/build/api/marketing-and-promotions/recommendation.js +3 -2
- package/build/api/order-management/dispute.js +10 -9
- package/build/api/order-management/fulfillment.js +12 -11
- package/build/api/other/compliance.js +5 -4
- package/build/api/other/edelivery.js +30 -29
- package/build/api/other/identity.js +3 -2
- package/build/api/other/translation.js +3 -2
- package/build/api/other/vero.js +6 -5
- package/build/api/shared/query-params.js +0 -5
- package/build/api/shared/request.js +1 -6
- package/build/auth/oauth-middleware.js +2 -1
- package/build/auth/oauth.js +29 -20
- package/build/auth/token-verifier.js +13 -7
- package/build/config/environment.js +88 -15
- package/build/index.js +6 -1
- package/build/mcp/http-transport.js +218 -0
- package/build/mcp/runtime.js +72 -0
- package/build/scripts/dev-sync.js +56 -15
- package/build/scripts/diagnostics.js +3 -2
- package/build/scripts/download-specs.js +2 -2
- package/build/scripts/interactive-setup.js +2 -1
- package/build/scripts/setup-shared.js +30 -9
- package/build/scripts/setup.js +266 -169
- package/build/server-http.js +3 -0
- package/build/tools/{definitions → categories}/account.js +124 -83
- package/build/tools/{definitions → categories}/analytics.js +14 -9
- package/build/tools/categories/communication.js +497 -0
- package/build/tools/categories/connector.js +126 -0
- package/build/tools/{definitions → categories}/developer.js +31 -15
- package/build/tools/{definitions → categories}/fulfillment.js +59 -31
- package/build/tools/categories/index.js +42 -0
- package/build/tools/{definitions → categories}/inventory.js +111 -74
- package/build/tools/categories/marketing.js +39 -0
- package/build/tools/{definitions → categories}/metadata.js +72 -48
- package/build/tools/{definitions → categories}/other.js +138 -83
- package/build/tools/{definitions → categories}/taxonomy.js +14 -9
- package/build/tools/categories/token-management.js +367 -0
- package/build/tools/{definitions → categories}/trading.js +20 -13
- package/build/tools/define-tool.js +61 -0
- package/build/tools/definitions/marketing.js +87 -200
- package/build/tools/definitions/types.js +1 -0
- package/build/tools/registry.js +9 -25
- package/build/tools/tool-handlers/marketing.js +15 -87
- package/build/utils/api-status-feed.js +6 -5
- package/build/utils/errors.js +16 -0
- package/build/utils/http.js +215 -0
- package/build/utils/oauth-helper.js +131 -150
- package/build/utils/setup-validator.js +4 -3
- package/build/utils/setup-wizard.js +55 -51
- package/package.json +25 -24
- package/build/tools/definitions/communication.js +0 -395
- package/build/tools/definitions/index.js +0 -41
- package/build/tools/definitions/token-management.js +0 -149
- package/build/tools/tool-definitions.js +0 -3545
- package/build/tools/tool-handlers/account.js +0 -123
- package/build/tools/tool-handlers/analytics.js +0 -15
- package/build/tools/tool-handlers/chat.js +0 -76
- package/build/tools/tool-handlers/communication.js +0 -161
- package/build/tools/tool-handlers/developer.js +0 -40
- package/build/tools/tool-handlers/fulfillment.js +0 -54
- package/build/tools/tool-handlers/index.js +0 -29
- package/build/tools/tool-handlers/inventory.js +0 -111
- package/build/tools/tool-handlers/metadata.js +0 -72
- package/build/tools/tool-handlers/other.js +0 -120
- package/build/tools/tool-handlers/taxonomy.js +0 -15
- package/build/tools/tool-handlers/token-management.js +0 -246
- package/build/tools/tool-handlers/trading.js +0 -21
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withApiError } from '../../api/shared/request.js';
|
|
1
2
|
/**
|
|
2
3
|
* Account API - Seller account configuration, policies, programs
|
|
3
4
|
* Based on: docs/sell-apps/account-management/sell_account_v1_oas3.json
|
|
@@ -13,46 +14,46 @@ export class AccountApi {
|
|
|
13
14
|
*/
|
|
14
15
|
async getCustomPolicies(policyTypes) {
|
|
15
16
|
const params = policyTypes ? { policy_types: policyTypes } : undefined;
|
|
16
|
-
return await this.client.get(`${this.basePath}/custom_policy`, params);
|
|
17
|
+
return await withApiError('Failed to get custom policies', () => this.client.get(`${this.basePath}/custom_policy`, params));
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* Get a specific custom policy
|
|
20
21
|
*/
|
|
21
22
|
async getCustomPolicy(customPolicyId) {
|
|
22
|
-
return await this.client.get(`${this.basePath}/custom_policy/${customPolicyId}`);
|
|
23
|
+
return await withApiError('Failed to get custom policy', () => this.client.get(`${this.basePath}/custom_policy/${customPolicyId}`));
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Get fulfillment policies
|
|
26
27
|
* @param marketplaceId - Required: The eBay marketplace ID
|
|
27
28
|
*/
|
|
28
29
|
async getFulfillmentPolicies(marketplaceId) {
|
|
29
|
-
return await this.client.get(`${this.basePath}/fulfillment_policy`, {
|
|
30
|
+
return await withApiError('Failed to get fulfillment policies', () => this.client.get(`${this.basePath}/fulfillment_policy`, {
|
|
30
31
|
marketplace_id: marketplaceId,
|
|
31
|
-
});
|
|
32
|
+
}));
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
34
35
|
* Get payment policies
|
|
35
36
|
* @param marketplaceId - Required: The eBay marketplace ID
|
|
36
37
|
*/
|
|
37
38
|
async getPaymentPolicies(marketplaceId) {
|
|
38
|
-
return await this.client.get(`${this.basePath}/payment_policy`, {
|
|
39
|
+
return await withApiError('Failed to get payment policies', () => this.client.get(`${this.basePath}/payment_policy`, {
|
|
39
40
|
marketplace_id: marketplaceId,
|
|
40
|
-
});
|
|
41
|
+
}));
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
44
|
* Get return policies
|
|
44
45
|
* @param marketplaceId - Required: The eBay marketplace ID
|
|
45
46
|
*/
|
|
46
47
|
async getReturnPolicies(marketplaceId) {
|
|
47
|
-
return await this.client.get(`${this.basePath}/return_policy`, {
|
|
48
|
+
return await withApiError('Failed to get return policies', () => this.client.get(`${this.basePath}/return_policy`, {
|
|
48
49
|
marketplace_id: marketplaceId,
|
|
49
|
-
});
|
|
50
|
+
}));
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
52
53
|
* Get seller account privileges
|
|
53
54
|
*/
|
|
54
55
|
async getPrivileges() {
|
|
55
|
-
return await this.client.get(`${this.basePath}/privilege`);
|
|
56
|
+
return await withApiError('Failed to get privileges', () => this.client.get(`${this.basePath}/privilege`));
|
|
56
57
|
}
|
|
57
58
|
// ============================================================
|
|
58
59
|
// Fulfillment Policy Methods
|
|
@@ -61,34 +62,34 @@ export class AccountApi {
|
|
|
61
62
|
* Create a new fulfillment policy
|
|
62
63
|
*/
|
|
63
64
|
async createFulfillmentPolicy(policy) {
|
|
64
|
-
return await this.client.post(`${this.basePath}/fulfillment_policy`, policy);
|
|
65
|
+
return await withApiError('Failed to create fulfillment policy', () => this.client.post(`${this.basePath}/fulfillment_policy`, policy));
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
67
68
|
* Get a specific fulfillment policy by ID
|
|
68
69
|
*/
|
|
69
70
|
async getFulfillmentPolicy(fulfillmentPolicyId) {
|
|
70
|
-
return await this.client.get(`${this.basePath}/fulfillment_policy/${fulfillmentPolicyId}`);
|
|
71
|
+
return await withApiError('Failed to get fulfillment policy', () => this.client.get(`${this.basePath}/fulfillment_policy/${fulfillmentPolicyId}`));
|
|
71
72
|
}
|
|
72
73
|
/**
|
|
73
74
|
* Get a fulfillment policy by name
|
|
74
75
|
*/
|
|
75
76
|
async getFulfillmentPolicyByName(marketplaceId, name) {
|
|
76
|
-
return await this.client.get(`${this.basePath}/fulfillment_policy_by_name`, {
|
|
77
|
+
return await withApiError('Failed to get fulfillment policy by name', () => this.client.get(`${this.basePath}/fulfillment_policy_by_name`, {
|
|
77
78
|
marketplace_id: marketplaceId,
|
|
78
79
|
name,
|
|
79
|
-
});
|
|
80
|
+
}));
|
|
80
81
|
}
|
|
81
82
|
/**
|
|
82
83
|
* Update a fulfillment policy
|
|
83
84
|
*/
|
|
84
85
|
async updateFulfillmentPolicy(fulfillmentPolicyId, policy) {
|
|
85
|
-
return await this.client.put(`${this.basePath}/fulfillment_policy/${fulfillmentPolicyId}`, policy);
|
|
86
|
+
return await withApiError('Failed to update fulfillment policy', () => this.client.put(`${this.basePath}/fulfillment_policy/${fulfillmentPolicyId}`, policy));
|
|
86
87
|
}
|
|
87
88
|
/**
|
|
88
89
|
* Delete a fulfillment policy
|
|
89
90
|
*/
|
|
90
91
|
async deleteFulfillmentPolicy(fulfillmentPolicyId) {
|
|
91
|
-
return await this.client.delete(`${this.basePath}/fulfillment_policy/${fulfillmentPolicyId}`);
|
|
92
|
+
return await withApiError('Failed to delete fulfillment policy', () => this.client.delete(`${this.basePath}/fulfillment_policy/${fulfillmentPolicyId}`));
|
|
92
93
|
}
|
|
93
94
|
// ============================================================
|
|
94
95
|
// Payment Policy Methods
|
|
@@ -97,34 +98,34 @@ export class AccountApi {
|
|
|
97
98
|
* Create a new payment policy
|
|
98
99
|
*/
|
|
99
100
|
async createPaymentPolicy(policy) {
|
|
100
|
-
return await this.client.post(`${this.basePath}/payment_policy`, policy);
|
|
101
|
+
return await withApiError('Failed to create payment policy', () => this.client.post(`${this.basePath}/payment_policy`, policy));
|
|
101
102
|
}
|
|
102
103
|
/**
|
|
103
104
|
* Get a specific payment policy by ID
|
|
104
105
|
*/
|
|
105
106
|
async getPaymentPolicy(paymentPolicyId) {
|
|
106
|
-
return await this.client.get(`${this.basePath}/payment_policy/${paymentPolicyId}`);
|
|
107
|
+
return await withApiError('Failed to get payment policy', () => this.client.get(`${this.basePath}/payment_policy/${paymentPolicyId}`));
|
|
107
108
|
}
|
|
108
109
|
/**
|
|
109
110
|
* Get a payment policy by name
|
|
110
111
|
*/
|
|
111
112
|
async getPaymentPolicyByName(marketplaceId, name) {
|
|
112
|
-
return await this.client.get(`${this.basePath}/payment_policy_by_name`, {
|
|
113
|
+
return await withApiError('Failed to get payment policy by name', () => this.client.get(`${this.basePath}/payment_policy_by_name`, {
|
|
113
114
|
marketplace_id: marketplaceId,
|
|
114
115
|
name,
|
|
115
|
-
});
|
|
116
|
+
}));
|
|
116
117
|
}
|
|
117
118
|
/**
|
|
118
119
|
* Update a payment policy
|
|
119
120
|
*/
|
|
120
121
|
async updatePaymentPolicy(paymentPolicyId, policy) {
|
|
121
|
-
return await this.client.put(`${this.basePath}/payment_policy/${paymentPolicyId}`, policy);
|
|
122
|
+
return await withApiError('Failed to update payment policy', () => this.client.put(`${this.basePath}/payment_policy/${paymentPolicyId}`, policy));
|
|
122
123
|
}
|
|
123
124
|
/**
|
|
124
125
|
* Delete a payment policy
|
|
125
126
|
*/
|
|
126
127
|
async deletePaymentPolicy(paymentPolicyId) {
|
|
127
|
-
return await this.client.delete(`${this.basePath}/payment_policy/${paymentPolicyId}`);
|
|
128
|
+
return await withApiError('Failed to delete payment policy', () => this.client.delete(`${this.basePath}/payment_policy/${paymentPolicyId}`));
|
|
128
129
|
}
|
|
129
130
|
// ============================================================
|
|
130
131
|
// Return Policy Methods
|
|
@@ -133,34 +134,34 @@ export class AccountApi {
|
|
|
133
134
|
* Create a new return policy
|
|
134
135
|
*/
|
|
135
136
|
async createReturnPolicy(policy) {
|
|
136
|
-
return await this.client.post(`${this.basePath}/return_policy`, policy);
|
|
137
|
+
return await withApiError('Failed to create return policy', () => this.client.post(`${this.basePath}/return_policy`, policy));
|
|
137
138
|
}
|
|
138
139
|
/**
|
|
139
140
|
* Get a specific return policy by ID
|
|
140
141
|
*/
|
|
141
142
|
async getReturnPolicy(returnPolicyId) {
|
|
142
|
-
return await this.client.get(`${this.basePath}/return_policy/${returnPolicyId}`);
|
|
143
|
+
return await withApiError('Failed to get return policy', () => this.client.get(`${this.basePath}/return_policy/${returnPolicyId}`));
|
|
143
144
|
}
|
|
144
145
|
/**
|
|
145
146
|
* Get a return policy by name
|
|
146
147
|
*/
|
|
147
148
|
async getReturnPolicyByName(marketplaceId, name) {
|
|
148
|
-
return await this.client.get(`${this.basePath}/return_policy_by_name`, {
|
|
149
|
+
return await withApiError('Failed to get return policy by name', () => this.client.get(`${this.basePath}/return_policy_by_name`, {
|
|
149
150
|
marketplace_id: marketplaceId,
|
|
150
151
|
name,
|
|
151
|
-
});
|
|
152
|
+
}));
|
|
152
153
|
}
|
|
153
154
|
/**
|
|
154
155
|
* Update a return policy
|
|
155
156
|
*/
|
|
156
157
|
async updateReturnPolicy(returnPolicyId, policy) {
|
|
157
|
-
return await this.client.put(`${this.basePath}/return_policy/${returnPolicyId}`, policy);
|
|
158
|
+
return await withApiError('Failed to update return policy', () => this.client.put(`${this.basePath}/return_policy/${returnPolicyId}`, policy));
|
|
158
159
|
}
|
|
159
160
|
/**
|
|
160
161
|
* Delete a return policy
|
|
161
162
|
*/
|
|
162
163
|
async deleteReturnPolicy(returnPolicyId) {
|
|
163
|
-
return await this.client.delete(`${this.basePath}/return_policy/${returnPolicyId}`);
|
|
164
|
+
return await withApiError('Failed to delete return policy', () => this.client.delete(`${this.basePath}/return_policy/${returnPolicyId}`));
|
|
164
165
|
}
|
|
165
166
|
// ============================================================
|
|
166
167
|
// Custom Policy Methods
|
|
@@ -169,19 +170,19 @@ export class AccountApi {
|
|
|
169
170
|
* Create a new custom policy
|
|
170
171
|
*/
|
|
171
172
|
async createCustomPolicy(policy) {
|
|
172
|
-
return await this.client.post(`${this.basePath}/custom_policy`, policy);
|
|
173
|
+
return await withApiError('Failed to create custom policy', () => this.client.post(`${this.basePath}/custom_policy`, policy));
|
|
173
174
|
}
|
|
174
175
|
/**
|
|
175
176
|
* Update a custom policy
|
|
176
177
|
*/
|
|
177
178
|
async updateCustomPolicy(customPolicyId, policy) {
|
|
178
|
-
return await this.client.put(`${this.basePath}/custom_policy/${customPolicyId}`, policy);
|
|
179
|
+
return await withApiError('Failed to update custom policy', () => this.client.put(`${this.basePath}/custom_policy/${customPolicyId}`, policy));
|
|
179
180
|
}
|
|
180
181
|
/**
|
|
181
182
|
* Delete a custom policy
|
|
182
183
|
*/
|
|
183
184
|
async deleteCustomPolicy(customPolicyId) {
|
|
184
|
-
return await this.client.delete(`${this.basePath}/custom_policy/${customPolicyId}`);
|
|
185
|
+
return await withApiError('Failed to delete custom policy', () => this.client.delete(`${this.basePath}/custom_policy/${customPolicyId}`));
|
|
185
186
|
}
|
|
186
187
|
// ============================================================
|
|
187
188
|
// KYC, Payments Program, Rate Tables, Sales Tax, Subscription, Programs
|
|
@@ -190,85 +191,85 @@ export class AccountApi {
|
|
|
190
191
|
* Get KYC status
|
|
191
192
|
*/
|
|
192
193
|
async getKyc() {
|
|
193
|
-
return await this.client.get(`${this.basePath}/kyc`);
|
|
194
|
+
return await withApiError('Failed to get kyc', () => this.client.get(`${this.basePath}/kyc`));
|
|
194
195
|
}
|
|
195
196
|
/**
|
|
196
197
|
* Opt-in to a payments program
|
|
197
198
|
*/
|
|
198
199
|
async optInToPaymentsProgram(marketplaceId, paymentsProgramType) {
|
|
199
|
-
return await this.client.post(`${this.basePath}/payments_program/${marketplaceId}/${paymentsProgramType}`, {});
|
|
200
|
+
return await withApiError('Failed to opt in to payments program', () => this.client.post(`${this.basePath}/payments_program/${marketplaceId}/${paymentsProgramType}`, {}));
|
|
200
201
|
}
|
|
201
202
|
/**
|
|
202
203
|
* Get payments program status
|
|
203
204
|
*/
|
|
204
205
|
async getPaymentsProgramStatus(marketplaceId, paymentsProgramType) {
|
|
205
|
-
return await this.client.get(`${this.basePath}/payments_program/${marketplaceId}/${paymentsProgramType}`);
|
|
206
|
+
return await withApiError('Failed to get payments program status', () => this.client.get(`${this.basePath}/payments_program/${marketplaceId}/${paymentsProgramType}`));
|
|
206
207
|
}
|
|
207
208
|
/**
|
|
208
209
|
* Get rate tables
|
|
209
210
|
*/
|
|
210
211
|
async getRateTables() {
|
|
211
|
-
return await this.client.get(`${this.basePath}/rate_table`);
|
|
212
|
+
return await withApiError('Failed to get rate tables', () => this.client.get(`${this.basePath}/rate_table`));
|
|
212
213
|
}
|
|
213
214
|
/**
|
|
214
215
|
* Create or replace sales tax table
|
|
215
216
|
*/
|
|
216
217
|
async createOrReplaceSalesTax(countryCode, jurisdictionId, salesTaxBase) {
|
|
217
|
-
return await this.client.put(`${this.basePath}/sales_tax/${countryCode}/${jurisdictionId}`, salesTaxBase);
|
|
218
|
+
return await withApiError('Failed to create or replace sales tax', () => this.client.put(`${this.basePath}/sales_tax/${countryCode}/${jurisdictionId}`, salesTaxBase));
|
|
218
219
|
}
|
|
219
220
|
/**
|
|
220
221
|
* Bulk create or replace sales tax tables
|
|
221
222
|
*/
|
|
222
223
|
async bulkCreateOrReplaceSalesTax(requests) {
|
|
223
|
-
return await this.client.post(`${this.basePath}/sales_tax/bulk_create_or_replace`, {
|
|
224
|
+
return await withApiError('Failed to bulk create or replace sales tax', () => this.client.post(`${this.basePath}/sales_tax/bulk_create_or_replace`, {
|
|
224
225
|
requests,
|
|
225
|
-
});
|
|
226
|
+
}));
|
|
226
227
|
}
|
|
227
228
|
/**
|
|
228
229
|
* Delete sales tax table
|
|
229
230
|
*/
|
|
230
231
|
async deleteSalesTax(countryCode, jurisdictionId) {
|
|
231
|
-
return await this.client.delete(`${this.basePath}/sales_tax/${countryCode}/${jurisdictionId}`);
|
|
232
|
+
return await withApiError('Failed to delete sales tax', () => this.client.delete(`${this.basePath}/sales_tax/${countryCode}/${jurisdictionId}`));
|
|
232
233
|
}
|
|
233
234
|
/**
|
|
234
235
|
* Get sales tax table
|
|
235
236
|
*/
|
|
236
237
|
async getSalesTax(countryCode, jurisdictionId) {
|
|
237
|
-
return await this.client.get(`${this.basePath}/sales_tax/${countryCode}/${jurisdictionId}`);
|
|
238
|
+
return await withApiError('Failed to get sales tax', () => this.client.get(`${this.basePath}/sales_tax/${countryCode}/${jurisdictionId}`));
|
|
238
239
|
}
|
|
239
240
|
/**
|
|
240
241
|
* Get all sales tax tables
|
|
241
242
|
* @param countryCode - Required: Two-letter ISO 3166-1 country code
|
|
242
243
|
*/
|
|
243
244
|
async getSalesTaxes(countryCode) {
|
|
244
|
-
return await this.client.get(`${this.basePath}/sales_tax`, {
|
|
245
|
+
return await withApiError('Failed to get sales taxes', () => this.client.get(`${this.basePath}/sales_tax`, {
|
|
245
246
|
country_code: countryCode,
|
|
246
|
-
});
|
|
247
|
+
}));
|
|
247
248
|
}
|
|
248
249
|
/**
|
|
249
250
|
* Get subscription information
|
|
250
251
|
*/
|
|
251
252
|
async getSubscription(limitType) {
|
|
252
253
|
const params = limitType ? { limit: limitType } : undefined;
|
|
253
|
-
return await this.client.get(`${this.basePath}/subscription`, params);
|
|
254
|
+
return await withApiError('Failed to get subscription', () => this.client.get(`${this.basePath}/subscription`, params));
|
|
254
255
|
}
|
|
255
256
|
/**
|
|
256
257
|
* Opt-in to a program
|
|
257
258
|
*/
|
|
258
259
|
async optInToProgram(request) {
|
|
259
|
-
return await this.client.post(`${this.basePath}/program/opt_in`, request);
|
|
260
|
+
return await withApiError('Failed to opt in to program', () => this.client.post(`${this.basePath}/program/opt_in`, request));
|
|
260
261
|
}
|
|
261
262
|
/**
|
|
262
263
|
* Opt-out of a program
|
|
263
264
|
*/
|
|
264
265
|
async optOutOfProgram(request) {
|
|
265
|
-
return await this.client.post(`${this.basePath}/program/opt_out`, request);
|
|
266
|
+
return await withApiError('Failed to opt out of program', () => this.client.post(`${this.basePath}/program/opt_out`, request));
|
|
266
267
|
}
|
|
267
268
|
/**
|
|
268
269
|
* Get opted-in programs
|
|
269
270
|
*/
|
|
270
271
|
async getOptedInPrograms() {
|
|
271
|
-
return await this.client.get(`${this.basePath}/program`);
|
|
272
|
+
return await withApiError('Failed to get opted in programs', () => this.client.get(`${this.basePath}/program`));
|
|
272
273
|
}
|
|
273
274
|
/**
|
|
274
275
|
* Get seller eligibility for advertising programs
|
|
@@ -278,11 +279,11 @@ export class AccountApi {
|
|
|
278
279
|
*/
|
|
279
280
|
async getAdvertisingEligibility(marketplaceId, programTypes) {
|
|
280
281
|
const params = programTypes ? { program_types: programTypes } : undefined;
|
|
281
|
-
return await this.client.get(`${this.basePath}/advertising_eligibility`, params, {
|
|
282
|
+
return await withApiError('Failed to get advertising eligibility', () => this.client.get(`${this.basePath}/advertising_eligibility`, params, {
|
|
282
283
|
headers: {
|
|
283
284
|
'X-EBAY-C-MARKETPLACE-ID': marketplaceId,
|
|
284
285
|
},
|
|
285
|
-
});
|
|
286
|
+
}));
|
|
286
287
|
}
|
|
287
288
|
/**
|
|
288
289
|
* Get payments program status for a marketplace
|
|
@@ -291,7 +292,7 @@ export class AccountApi {
|
|
|
291
292
|
* @param paymentsProgramType - The type of payments program
|
|
292
293
|
*/
|
|
293
294
|
async getPaymentsProgram(marketplaceId, paymentsProgramType) {
|
|
294
|
-
return await this.client.get(`${this.basePath}/payments_program/${marketplaceId}/${paymentsProgramType}`);
|
|
295
|
+
return await withApiError('Failed to get payments program', () => this.client.get(`${this.basePath}/payments_program/${marketplaceId}/${paymentsProgramType}`));
|
|
295
296
|
}
|
|
296
297
|
/**
|
|
297
298
|
* Get payments program onboarding information
|
|
@@ -300,6 +301,6 @@ export class AccountApi {
|
|
|
300
301
|
* @param paymentsProgramType - The type of payments program
|
|
301
302
|
*/
|
|
302
303
|
async getPaymentsProgramOnboarding(marketplaceId, paymentsProgramType) {
|
|
303
|
-
return await this.client.get(`${this.basePath}/payments_program/${marketplaceId}/${paymentsProgramType}/onboarding`);
|
|
304
|
+
return await withApiError('Failed to get payments program onboarding', () => this.client.get(`${this.basePath}/payments_program/${marketplaceId}/${paymentsProgramType}/onboarding`));
|
|
304
305
|
}
|
|
305
306
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withApiError } from '../../api/shared/request.js';
|
|
1
2
|
/**
|
|
2
3
|
* Analytics API - Sales and traffic analytics
|
|
3
4
|
* Based on: docs/sell-apps/analytics-and-report/sell_analytics_v1_oas3.json
|
|
@@ -33,12 +34,7 @@ export class AnalyticsApi {
|
|
|
33
34
|
};
|
|
34
35
|
if (sort)
|
|
35
36
|
params.sort = sort;
|
|
36
|
-
|
|
37
|
-
return await this.client.get(`${this.basePath}/traffic_report`, params);
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
throw new Error(`Failed to get traffic report: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
41
|
-
}
|
|
37
|
+
return await withApiError('Failed to get traffic report', () => this.client.get(`${this.basePath}/traffic_report`, params));
|
|
42
38
|
}
|
|
43
39
|
/**
|
|
44
40
|
* Find all seller standards profiles
|
|
@@ -46,12 +42,7 @@ export class AnalyticsApi {
|
|
|
46
42
|
* @throws Error if the request fails
|
|
47
43
|
*/
|
|
48
44
|
async findSellerStandardsProfiles() {
|
|
49
|
-
|
|
50
|
-
return await this.client.get(`${this.basePath}/seller_standards_profile`);
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
throw new Error(`Failed to find seller standards profiles: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
54
|
-
}
|
|
45
|
+
return await withApiError('Failed to find seller standards profiles', () => this.client.get(`${this.basePath}/seller_standards_profile`));
|
|
55
46
|
}
|
|
56
47
|
/**
|
|
57
48
|
* Get a specific seller standards profile
|
|
@@ -66,12 +57,7 @@ export class AnalyticsApi {
|
|
|
66
57
|
if (!cycle || typeof cycle !== 'string') {
|
|
67
58
|
throw new Error('cycle is required and must be a string');
|
|
68
59
|
}
|
|
69
|
-
|
|
70
|
-
return await this.client.get(`${this.basePath}/seller_standards_profile/${program}/${cycle}`);
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
throw new Error(`Failed to get seller standards profile: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
74
|
-
}
|
|
60
|
+
return await withApiError('Failed to get seller standards profile', () => this.client.get(`${this.basePath}/seller_standards_profile/${program}/${cycle}`));
|
|
75
61
|
}
|
|
76
62
|
/**
|
|
77
63
|
* Get customer service metrics
|
|
@@ -92,11 +78,6 @@ export class AnalyticsApi {
|
|
|
92
78
|
const params = {
|
|
93
79
|
evaluation_marketplace_id: evaluationMarketplaceId,
|
|
94
80
|
};
|
|
95
|
-
|
|
96
|
-
return await this.client.get(`${this.basePath}/customer_service_metric/${customerServiceMetricType}/${evaluationType}`, params);
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
throw new Error(`Failed to get customer service metric: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
100
|
-
}
|
|
81
|
+
return await withApiError('Failed to get customer service metric', () => this.client.get(`${this.basePath}/customer_service_metric/${customerServiceMetricType}/${evaluationType}`, params));
|
|
101
82
|
}
|
|
102
83
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
1
|
import { XMLBuilder, XMLParser } from 'fast-xml-parser';
|
|
2
|
+
import { getBaseUrl } from '../config/environment.js';
|
|
3
|
+
import { httpRequest } from '../utils/http.js';
|
|
3
4
|
import { apiLogger } from '../utils/logger.js';
|
|
4
5
|
import { isRecord } from '../utils/type-guards.js';
|
|
5
6
|
const COMPAT_LEVEL = '1451';
|
|
@@ -14,8 +15,8 @@ export class TradingApiClient {
|
|
|
14
15
|
builder;
|
|
15
16
|
constructor(restClient) {
|
|
16
17
|
this.restClient = restClient;
|
|
17
|
-
const
|
|
18
|
-
this.baseUrl =
|
|
18
|
+
const config = restClient.getConfig();
|
|
19
|
+
this.baseUrl = getBaseUrl(config.environment, config.apiBaseUrl);
|
|
19
20
|
this.parser = new XMLParser({
|
|
20
21
|
ignoreAttributes: false,
|
|
21
22
|
removeNSPrefix: true,
|
|
@@ -53,7 +54,6 @@ export class TradingApiClient {
|
|
|
53
54
|
* Execute a named Trading API call with XML request/response conversion.
|
|
54
55
|
*/
|
|
55
56
|
async execute(callName, params) {
|
|
56
|
-
const token = await this.restClient.getOAuthClient().getAccessToken();
|
|
57
57
|
const requestTag = `${callName}Request`;
|
|
58
58
|
const responseTag = `${callName}Response`;
|
|
59
59
|
const xmlObj = {};
|
|
@@ -63,18 +63,28 @@ export class TradingApiClient {
|
|
|
63
63
|
};
|
|
64
64
|
const xmlBody = `<?xml version="1.0" encoding="utf-8"?>\n${this.builder.build(xmlObj)}`;
|
|
65
65
|
apiLogger.debug(`Trading API ${callName}`, { xmlBody });
|
|
66
|
-
|
|
66
|
+
const headers = {
|
|
67
|
+
'X-EBAY-API-SITEID': SITE_ID,
|
|
68
|
+
'X-EBAY-API-COMPATIBILITY-LEVEL': COMPAT_LEVEL,
|
|
69
|
+
'X-EBAY-API-CALL-NAME': callName,
|
|
70
|
+
'Content-Type': 'text/xml',
|
|
71
|
+
};
|
|
72
|
+
// Proxy auth mode: omit the IAF token and skip token acquisition — the proxy
|
|
73
|
+
// injects the credential the Trading API requires.
|
|
74
|
+
if (!this.restClient.getConfig().disableAuthHeader) {
|
|
75
|
+
headers['X-EBAY-API-IAF-TOKEN'] = await this.restClient.getOAuthClient().getAccessToken();
|
|
76
|
+
}
|
|
77
|
+
let responseXml;
|
|
67
78
|
try {
|
|
68
|
-
response = await
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
timeout: 30000,
|
|
79
|
+
const response = await httpRequest({
|
|
80
|
+
method: 'POST',
|
|
81
|
+
url: `${this.baseUrl}/ws/api.dll`,
|
|
82
|
+
headers,
|
|
83
|
+
body: xmlBody,
|
|
84
|
+
timeoutMs: 30000,
|
|
85
|
+
responseType: 'text',
|
|
77
86
|
});
|
|
87
|
+
responseXml = response.data;
|
|
78
88
|
}
|
|
79
89
|
catch (error) {
|
|
80
90
|
const message = error instanceof Error ? error.message : 'Unknown HTTP error';
|
|
@@ -82,7 +92,7 @@ export class TradingApiClient {
|
|
|
82
92
|
}
|
|
83
93
|
let parsed;
|
|
84
94
|
try {
|
|
85
|
-
const parsedValue = this.parser.parse(
|
|
95
|
+
const parsedValue = this.parser.parse(responseXml);
|
|
86
96
|
if (!isRecord(parsedValue)) {
|
|
87
97
|
throw new Error('Trading API response must be an object');
|
|
88
98
|
}
|