ebay-api 8.2.0 → 8.4.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 +37 -2
- package/dist/api/digitalSignature.d.ts +43 -0
- package/dist/api/digitalSignature.js +105 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +18 -0
- package/dist/api/restful/developer/keyManagement/index.d.ts +2 -4
- package/dist/api/restful/developer/keyManagement/index.js +5 -3
- package/dist/api/restful/index.d.ts +12 -7
- package/dist/api/restful/index.js +30 -17
- package/dist/api/restful/sell/marketing/index.d.ts +184 -1
- package/dist/api/restful/sell/marketing/index.js +260 -0
- package/dist/api/traditional/XMLRequest.d.ts +3 -1
- package/dist/api/traditional/XMLRequest.js +3 -1
- package/dist/api/traditional/index.d.ts +1 -1
- package/dist/api/traditional/index.js +25 -15
- package/dist/eBayApi.d.ts +2 -1
- package/dist/eBayApi.js +12 -1
- package/dist/ebay-api.min.mjs +1 -1
- package/dist/errors/index.js +5 -0
- package/dist/types/apiTypes.d.ts +7 -0
- package/dist/types/restfulTypes.d.ts +90 -0
- package/dist/types/traditonalTypes.d.ts +2 -1
- package/lib/api/digitalSignature.d.ts +43 -0
- package/lib/api/digitalSignature.js +112 -0
- package/lib/api/index.d.ts +2 -0
- package/lib/api/index.js +18 -0
- package/lib/api/restful/developer/keyManagement/index.d.ts +2 -4
- package/lib/api/restful/developer/keyManagement/index.js +5 -3
- package/lib/api/restful/index.d.ts +12 -7
- package/lib/api/restful/index.js +34 -21
- package/lib/api/restful/sell/marketing/index.d.ts +184 -1
- package/lib/api/restful/sell/marketing/index.js +260 -0
- package/lib/api/traditional/XMLRequest.d.ts +3 -1
- package/lib/api/traditional/XMLRequest.js +2 -0
- package/lib/api/traditional/index.d.ts +1 -1
- package/lib/api/traditional/index.js +29 -19
- package/lib/eBayApi.d.ts +2 -1
- package/lib/eBayApi.js +12 -1
- package/lib/ebay-api.min.js +1 -1
- package/lib/errors/index.js +5 -0
- package/lib/types/apiTypes.d.ts +7 -0
- package/lib/types/restfulTypes.d.ts +90 -0
- package/lib/types/traditonalTypes.d.ts +2 -1
- package/package.json +2 -1
|
@@ -79,6 +79,28 @@ export default class Marketing extends Restful {
|
|
|
79
79
|
campaignId = encodeURIComponent(campaignId);
|
|
80
80
|
return this.post(`/ad_campaign/${campaignId}/bulk_update_ads_bid_by_listing_id`, body);
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* This method is only available for select partners who have been approved for the eBay Promoted Listings Advanced (PLA) program.
|
|
84
|
+
*
|
|
85
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get
|
|
86
|
+
* a seller's campaign IDs by calling getCampaigns.
|
|
87
|
+
* @param body The bulk request to update the ads.
|
|
88
|
+
*/
|
|
89
|
+
bulkUpdateAdsStatus(campaignId, body) {
|
|
90
|
+
campaignId = encodeURIComponent(campaignId);
|
|
91
|
+
return this.post(`/ad_campaign/${campaignId}/bulk_update_ads_status`, body);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* This method is only available for select partners who have been approved for the eBay Promoted Listings Advanced (PLA) program.
|
|
95
|
+
*
|
|
96
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get
|
|
97
|
+
* a seller's campaign IDs by calling getCampaigns.
|
|
98
|
+
* @param body The bulk request to update ads.
|
|
99
|
+
*/
|
|
100
|
+
bulkUpdateAdsStatusByListingId(campaignId, body) {
|
|
101
|
+
campaignId = encodeURIComponent(campaignId);
|
|
102
|
+
return this.post(`/ad_campaign/${campaignId}/bulk_update_ads_status_by_listing_id`, body);
|
|
103
|
+
}
|
|
82
104
|
/**
|
|
83
105
|
* This method retrieves all the ads for the specified campaign.
|
|
84
106
|
*
|
|
@@ -192,6 +214,81 @@ export default class Marketing extends Restful {
|
|
|
192
214
|
adId = encodeURIComponent(adId);
|
|
193
215
|
return this.post(`/ad_campaign/${campaignId}/ad/${adId}/update_bid`, body);
|
|
194
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
*
|
|
219
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get
|
|
220
|
+
* a seller's campaign IDs by calling getCampaigns.
|
|
221
|
+
* @param adGroupStatus A comma-separated list of ad group statuses.
|
|
222
|
+
* @param limit The number of results, from the current result set, to be returned in a single page.
|
|
223
|
+
* @param offset The number of results that will be skipped in the result set.
|
|
224
|
+
*/
|
|
225
|
+
getAdGroups(campaignId, { adGroupStatus, limit, offset } = {}) {
|
|
226
|
+
campaignId = encodeURIComponent(campaignId);
|
|
227
|
+
return this.get(`/ad_campaign/${campaignId}/ad_group`, {
|
|
228
|
+
params: {
|
|
229
|
+
ad_group_status: adGroupStatus,
|
|
230
|
+
limit,
|
|
231
|
+
offset
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
*
|
|
237
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get
|
|
238
|
+
* a seller's campaign IDs by calling getCampaigns.
|
|
239
|
+
* @param body This type defines the fields for the <b>createAdGroup</b> request.
|
|
240
|
+
*/
|
|
241
|
+
createAdGroup(campaignId, body) {
|
|
242
|
+
campaignId = encodeURIComponent(campaignId);
|
|
243
|
+
return this.post(`/ad_campaign/${campaignId}/ad_group`, body);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
*
|
|
247
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get
|
|
248
|
+
* a seller's campaign IDs by calling getCampaigns.
|
|
249
|
+
* @param adGroupId The ID of the ad group that shall be retrieved.
|
|
250
|
+
*/
|
|
251
|
+
getAdGroup(campaignId, adGroupId) {
|
|
252
|
+
adGroupId = encodeURIComponent(adGroupId);
|
|
253
|
+
campaignId = encodeURIComponent(campaignId);
|
|
254
|
+
return this.get(`/ad_campaign/${campaignId}/ad_group/${adGroupId}`);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
*
|
|
258
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get
|
|
259
|
+
* a seller's campaign IDs by calling getCampaigns.
|
|
260
|
+
* @param adGroupId The ID of the ad group that shall be retrieved.
|
|
261
|
+
* @param body This type defines the fields for the <b>UpdateAdGroup</b> request.
|
|
262
|
+
*/
|
|
263
|
+
updateAdGroup(campaignId, adGroupId, body) {
|
|
264
|
+
adGroupId = encodeURIComponent(adGroupId);
|
|
265
|
+
campaignId = encodeURIComponent(campaignId);
|
|
266
|
+
return this.put(`/ad_campaign/${campaignId}/ad_group/${adGroupId}`, body);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
*
|
|
270
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get
|
|
271
|
+
* a seller's campaign IDs by calling getCampaigns.
|
|
272
|
+
* @param adGroupId The ID of the ad group that shall be retrieved.
|
|
273
|
+
* @param body The data requested to retrieve the suggested bids.
|
|
274
|
+
*/
|
|
275
|
+
suggestBids(campaignId, adGroupId, body) {
|
|
276
|
+
adGroupId = encodeURIComponent(adGroupId);
|
|
277
|
+
campaignId = encodeURIComponent(campaignId);
|
|
278
|
+
return this.post(`/ad_campaign/${campaignId}/ad_group/${adGroupId}/suggest_bids`, body);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
*
|
|
282
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get
|
|
283
|
+
* a seller's campaign IDs by calling getCampaigns.
|
|
284
|
+
* @param adGroupId The ID of the ad group that shall be retrieved.
|
|
285
|
+
* @param body The required data to retrieve suggested keywords.
|
|
286
|
+
*/
|
|
287
|
+
suggestKeywords(campaignId, adGroupId, body) {
|
|
288
|
+
adGroupId = encodeURIComponent(adGroupId);
|
|
289
|
+
campaignId = encodeURIComponent(campaignId);
|
|
290
|
+
return this.post(`/ad_campaign/${campaignId}/ad_group/${adGroupId}/suggest_keywords`, body);
|
|
291
|
+
}
|
|
195
292
|
/**
|
|
196
293
|
* This method clones (makes a copy of) the specified campaign.
|
|
197
294
|
*
|
|
@@ -322,6 +419,41 @@ export default class Marketing extends Restful {
|
|
|
322
419
|
campaignId = encodeURIComponent(campaignId);
|
|
323
420
|
return this.post(`/ad_campaign/${campaignId}/resume`);
|
|
324
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
*
|
|
424
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.
|
|
425
|
+
* @param categoryIds Specifies the category ID that is used to limit the results.
|
|
426
|
+
* @param limit Specifies the maximum number of campaigns to return on a page in the paginated response.
|
|
427
|
+
* @param offset Specifies the number of campaigns to skip in the result set before returning the first report in the paginated response.
|
|
428
|
+
*/
|
|
429
|
+
suggestItems(campaignId, { categoryIds, limit, offset } = {}) {
|
|
430
|
+
campaignId = encodeURIComponent(campaignId);
|
|
431
|
+
return this.get(`/ad_campaign/${campaignId}/suggest_items`, {
|
|
432
|
+
params: {
|
|
433
|
+
category_ids: categoryIds,
|
|
434
|
+
limit,
|
|
435
|
+
offset
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
*
|
|
441
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.
|
|
442
|
+
* @param body This type defines the request fields for the ad rate strategy that shall be updated.
|
|
443
|
+
*/
|
|
444
|
+
updateAdRateStrategy(campaignId, body) {
|
|
445
|
+
campaignId = encodeURIComponent(campaignId);
|
|
446
|
+
return this.post(`/ad_campaign/${campaignId}/update_ad_rate_strategy`, body);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
*
|
|
450
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.
|
|
451
|
+
* @param body This type defines the request fields for the budget details that shall be updated.
|
|
452
|
+
*/
|
|
453
|
+
updateCampaignBudget(campaignId, body) {
|
|
454
|
+
campaignId = encodeURIComponent(campaignId);
|
|
455
|
+
return this.post(`/ad_campaign/${campaignId}/update_campaign_budget`, body);
|
|
456
|
+
}
|
|
325
457
|
/**
|
|
326
458
|
* This method replaces the name and the start and end dates of a campaign.
|
|
327
459
|
*
|
|
@@ -333,6 +465,134 @@ export default class Marketing extends Restful {
|
|
|
333
465
|
campaignId = encodeURIComponent(campaignId);
|
|
334
466
|
return this.post(`/ad_campaign/${campaignId}/update_campaign_identification`, body);
|
|
335
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
*
|
|
470
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get
|
|
471
|
+
* a seller's campaign IDs by calling getCampaigns.
|
|
472
|
+
* @param body A type that defines the fields for the bulk request to create keywords.
|
|
473
|
+
*/
|
|
474
|
+
bulkCreateKeyword(campaignId, body) {
|
|
475
|
+
campaignId = encodeURIComponent(campaignId);
|
|
476
|
+
return this.post(`/ad_campaign/${campaignId}/bulk_create_keyword`, body);
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
*
|
|
480
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get
|
|
481
|
+
* a seller's campaign IDs by calling getCampaigns.
|
|
482
|
+
* @param body A type that defines the fields for the bulk request to update keywords.
|
|
483
|
+
*/
|
|
484
|
+
bulkUpdateKeyword(campaignId, body) {
|
|
485
|
+
campaignId = encodeURIComponent(campaignId);
|
|
486
|
+
return this.post(`/ad_campaign/${campaignId}/bulk_update_keyword`, body);
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
*
|
|
490
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get
|
|
491
|
+
* a seller's campaign IDs by calling getCampaigns.
|
|
492
|
+
* @param adGroupIds A comma-separated list of ad group IDs.
|
|
493
|
+
* @param keywordStatus A comma-separated list of keyword statuses.
|
|
494
|
+
* @param limit Specifies the maximum number of results to return on a page in the paginated response.
|
|
495
|
+
* @param offset Specifies the number of results to skip in the result set before returning the first report in the paginated response.
|
|
496
|
+
*/
|
|
497
|
+
getKeywords(campaignId, { adGroupIds, keywordStatus, limit, offset } = {}) {
|
|
498
|
+
campaignId = encodeURIComponent(campaignId);
|
|
499
|
+
return this.get(`/ad_campaign/${campaignId}/keyword`, {
|
|
500
|
+
params: {
|
|
501
|
+
ad_group_ids: adGroupIds,
|
|
502
|
+
keyword_status: keywordStatus,
|
|
503
|
+
limit,
|
|
504
|
+
offset
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
*
|
|
510
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get
|
|
511
|
+
* a seller's campaign IDs by calling getCampaigns.
|
|
512
|
+
* @param body A type that defines the fields for the request to create a keyword.
|
|
513
|
+
*/
|
|
514
|
+
createKeyword(campaignId, body) {
|
|
515
|
+
campaignId = encodeURIComponent(campaignId);
|
|
516
|
+
return this.post(`/ad_campaign/${campaignId}/keyword`, body);
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
*
|
|
520
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get
|
|
521
|
+
* a seller's campaign IDs by calling getCampaigns.
|
|
522
|
+
* @param keywordId This path parameter is used to identify the keyword to retrieve.
|
|
523
|
+
*/
|
|
524
|
+
getKeyword(campaignId, keywordId) {
|
|
525
|
+
campaignId = encodeURIComponent(campaignId);
|
|
526
|
+
keywordId = encodeURIComponent(keywordId);
|
|
527
|
+
return this.get(`/ad_campaign/${campaignId}/keyword/${keywordId}`);
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
*
|
|
531
|
+
* @param campaignId A unique eBay-assigned ID for an ad campaign that's generated when a campaign is created. Get
|
|
532
|
+
* a seller's campaign IDs by calling getCampaigns.
|
|
533
|
+
* @param keywordId This path parameter is used to identify the keyword to retrieve.
|
|
534
|
+
* @param body A type that defines the fields for the request to update a keyword.
|
|
535
|
+
*/
|
|
536
|
+
updateKeyword(campaignId, keywordId, body) {
|
|
537
|
+
campaignId = encodeURIComponent(campaignId);
|
|
538
|
+
keywordId = encodeURIComponent(keywordId);
|
|
539
|
+
return this.put(`/ad_campaign/${campaignId}/keyword/${keywordId}`, body);
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
*
|
|
543
|
+
* @param body A type that defines the fields for the bulk request to create negative keywords.
|
|
544
|
+
*/
|
|
545
|
+
bulkCreateNegativeKeyword(body) {
|
|
546
|
+
return this.post(`/bulk_create_negative_keyword`, body);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
*
|
|
550
|
+
* @param body A type that defines the fields for the bulk request to create negative keywords.
|
|
551
|
+
*/
|
|
552
|
+
bulkUpdateNegativeKeyword(body) {
|
|
553
|
+
return this.post(`/bulk_update_negative_keyword`, body);
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
*
|
|
557
|
+
* @param adGroupIds A comma-separated list of ad group IDs.
|
|
558
|
+
* @param campaignIds A unique eBay-assigned ID for an ad campaign that is generated when a campaign is created.
|
|
559
|
+
* @param limit The number of results, from the current result set, to be returned in a single page.
|
|
560
|
+
* @param negativeKeywordStatus A comma-separated list of negative keyword statuses.
|
|
561
|
+
* @param offset The number of results that will be skipped in the result set.
|
|
562
|
+
*/
|
|
563
|
+
getNegativeKeywords({ adGroupIds, campaignIds, limit, negativeKeywordStatus, offset } = {}) {
|
|
564
|
+
return this.get(`/negative_keyword`, {
|
|
565
|
+
params: {
|
|
566
|
+
ad_group_ids: adGroupIds,
|
|
567
|
+
campaign_ids: campaignIds, limit,
|
|
568
|
+
negative_keyword_status: negativeKeywordStatus, offset
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
*
|
|
574
|
+
* @param body A type that defines the fields for the request to create a negative keyword.
|
|
575
|
+
*/
|
|
576
|
+
createNegativeKeyword(body) {
|
|
577
|
+
return this.post(`/negative_keyword`, body);
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
*
|
|
581
|
+
* @param negativeKeywordId The unique identifier for the negative keyword.
|
|
582
|
+
*/
|
|
583
|
+
getNegativeKeyword(negativeKeywordId) {
|
|
584
|
+
negativeKeywordId = encodeURIComponent(negativeKeywordId);
|
|
585
|
+
return this.get(`/negative_keyword/${negativeKeywordId}`);
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
*
|
|
589
|
+
* @param negativeKeywordId The unique identifier for the negative keyword.
|
|
590
|
+
* @param body A type that defines the fields for the request to update a negative keyword.
|
|
591
|
+
*/
|
|
592
|
+
updateNegativeKeyword(negativeKeywordId, body) {
|
|
593
|
+
negativeKeywordId = encodeURIComponent(negativeKeywordId);
|
|
594
|
+
return this.put(`/negative_keyword/${negativeKeywordId}`, body);
|
|
595
|
+
}
|
|
336
596
|
/**
|
|
337
597
|
* This call downloads the report as specified by the report_id path parameter.
|
|
338
598
|
*
|
|
@@ -34,12 +34,14 @@ export type TraditionalApiConfig = {
|
|
|
34
34
|
raw?: boolean;
|
|
35
35
|
parseOptions?: object;
|
|
36
36
|
useIaf?: boolean;
|
|
37
|
+
sign?: boolean;
|
|
37
38
|
hook?: (xml: string) => BodyHeaders;
|
|
38
39
|
} & ApiRequestConfig;
|
|
39
40
|
export type XMLReqConfig = TraditionalApiConfig & {
|
|
40
41
|
endpoint: string;
|
|
41
42
|
xmlns: string;
|
|
42
43
|
eBayAuthToken?: string | null;
|
|
44
|
+
digitalSignatureHeaders?: (payload: any) => Headers;
|
|
43
45
|
};
|
|
44
46
|
export declare const defaultApiConfig: Required<Omit<TraditionalApiConfig, 'hook'>>;
|
|
45
47
|
export declare const defaultHeaders: {
|
|
@@ -63,7 +65,7 @@ export default class XMLRequest {
|
|
|
63
65
|
* @param {Object} req the request
|
|
64
66
|
* @param {XMLReqConfig} config
|
|
65
67
|
*/
|
|
66
|
-
constructor(callName: string, fields: Fields, config: XMLReqConfig, req: IEBayApiRequest);
|
|
68
|
+
constructor(callName: string, fields: Fields | null, config: XMLReqConfig, req: IEBayApiRequest);
|
|
67
69
|
/**
|
|
68
70
|
* returns the expected name of XML node of a Request
|
|
69
71
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import debug from 'debug';
|
|
2
|
-
import {
|
|
2
|
+
import { XMLBuilder, XMLParser } from 'fast-xml-parser';
|
|
3
3
|
import { checkEBayResponse, EbayNoCallError } from '../../errors/index.js';
|
|
4
4
|
const log = debug('ebay:xml:request');
|
|
5
5
|
export const defaultJSON2XMLOptions = {
|
|
@@ -32,6 +32,7 @@ export const defaultApiConfig = {
|
|
|
32
32
|
raw: false,
|
|
33
33
|
parseOptions: defaultXML2JSONParseOptions,
|
|
34
34
|
useIaf: true,
|
|
35
|
+
sign: false,
|
|
35
36
|
headers: {},
|
|
36
37
|
returnResponse: false
|
|
37
38
|
};
|
|
@@ -137,6 +138,7 @@ export default class XMLRequest {
|
|
|
137
138
|
const config = {
|
|
138
139
|
headers: {
|
|
139
140
|
...this.getHeaders(),
|
|
141
|
+
...this.config.digitalSignatureHeaders ? this.config.digitalSignatureHeaders(body) : {},
|
|
140
142
|
...(headers ? headers : {})
|
|
141
143
|
}
|
|
142
144
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { stringify } from 'qs';
|
|
2
|
-
import Api from '../index.js';
|
|
3
2
|
import { EBayIAFTokenExpired, EBayIAFTokenInvalid, handleEBayError } from '../../errors/index.js';
|
|
3
|
+
import Api from '../index.js';
|
|
4
4
|
import ClientAlertsCalls from './clientAlerts/index.js';
|
|
5
5
|
import FindingCalls from './finding/index.js';
|
|
6
6
|
import MerchandisingCalls from './merchandising/index.js';
|
|
@@ -28,17 +28,15 @@ export default class Traditional extends Api {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
createTradingApi() {
|
|
31
|
-
if (!this.config.devId) {
|
|
32
|
-
throw new Error('devId is required for trading API.');
|
|
33
|
-
}
|
|
34
31
|
if (typeof this.config.siteId !== 'number') {
|
|
35
32
|
throw new Error('siteId is required for trading API.');
|
|
36
33
|
}
|
|
37
34
|
return this.createTraditionalXMLApi({
|
|
38
35
|
endpoint: {
|
|
39
|
-
production: '
|
|
40
|
-
sandbox: '
|
|
36
|
+
production: 'api.ebay.com',
|
|
37
|
+
sandbox: 'api.sandbox.ebay.com'
|
|
41
38
|
},
|
|
39
|
+
path: '/ws/api.dll',
|
|
42
40
|
calls: TradingCalls,
|
|
43
41
|
xmlns: 'urn:ebay:apis:eBLBaseComponents',
|
|
44
42
|
headers: (callName, accessToken) => ({
|
|
@@ -58,9 +56,10 @@ export default class Traditional extends Api {
|
|
|
58
56
|
}
|
|
59
57
|
return this.createTraditionalXMLApi({
|
|
60
58
|
endpoint: {
|
|
61
|
-
production: '
|
|
62
|
-
sandbox: '
|
|
59
|
+
production: 'open.api.ebay.com',
|
|
60
|
+
sandbox: 'open.api.sandbox.ebay.com'
|
|
63
61
|
},
|
|
62
|
+
path: '/shopping',
|
|
64
63
|
xmlns: 'urn:ebay:apis:eBLBaseComponents',
|
|
65
64
|
calls: ShoppingCalls,
|
|
66
65
|
headers: (callName, accessToken) => ({
|
|
@@ -76,9 +75,10 @@ export default class Traditional extends Api {
|
|
|
76
75
|
createFindingApi() {
|
|
77
76
|
return this.createTraditionalXMLApi({
|
|
78
77
|
endpoint: {
|
|
79
|
-
production: '
|
|
80
|
-
sandbox: '
|
|
78
|
+
production: 'svcs.ebay.com',
|
|
79
|
+
sandbox: 'svcs.sandbox.ebay.com'
|
|
81
80
|
},
|
|
81
|
+
path: '/services/search/FindingService/v1',
|
|
82
82
|
xmlns: 'http://www.ebay.com/marketplace/search/v1/services',
|
|
83
83
|
calls: FindingCalls,
|
|
84
84
|
headers: (callName) => ({
|
|
@@ -93,9 +93,10 @@ export default class Traditional extends Api {
|
|
|
93
93
|
}
|
|
94
94
|
const api = {
|
|
95
95
|
endpoint: {
|
|
96
|
-
production: '
|
|
97
|
-
sandbox: '
|
|
96
|
+
production: 'clientalerts.ebay.com',
|
|
97
|
+
sandbox: 'clientalerts.sandbox.ebay.com'
|
|
98
98
|
},
|
|
99
|
+
path: '/ws/ecasvc/ClientAlerts',
|
|
99
100
|
calls: ClientAlertsCalls
|
|
100
101
|
};
|
|
101
102
|
const endpoint = api.endpoint[this.config.sandbox ? 'sandbox' : 'production'];
|
|
@@ -129,9 +130,10 @@ export default class Traditional extends Api {
|
|
|
129
130
|
createMerchandisingApi() {
|
|
130
131
|
return this.createTraditionalXMLApi({
|
|
131
132
|
endpoint: {
|
|
132
|
-
production: '
|
|
133
|
-
sandbox: '
|
|
133
|
+
production: 'svcs.ebay.com',
|
|
134
|
+
sandbox: 'svcs.sandbox.ebay.com'
|
|
134
135
|
},
|
|
136
|
+
path: '/MerchandisingService',
|
|
135
137
|
xmlns: 'http://www.ebay.com/marketplace/services',
|
|
136
138
|
calls: MerchandisingCalls,
|
|
137
139
|
headers: (callName) => ({
|
|
@@ -160,14 +162,22 @@ export default class Traditional extends Api {
|
|
|
160
162
|
const eBayAuthToken = this.auth.authNAuth.eBayAuthToken;
|
|
161
163
|
const accessToken = !eBayAuthToken && apiConfig.useIaf ? (await this.auth.OAuth2.getAccessToken()) : null;
|
|
162
164
|
const useIaf = !eBayAuthToken && accessToken;
|
|
165
|
+
const host = this.config.sandbox ? api.endpoint.sandbox : api.endpoint.production;
|
|
163
166
|
return {
|
|
164
167
|
...apiConfig,
|
|
165
168
|
xmlns: api.xmlns,
|
|
166
|
-
endpoint: api.
|
|
169
|
+
endpoint: `https://${host}${api.path}`,
|
|
167
170
|
headers: {
|
|
168
171
|
...api.headers(callName, useIaf ? accessToken : null),
|
|
169
172
|
...apiConfig.headers
|
|
170
173
|
},
|
|
174
|
+
digitalSignatureHeaders: payload => {
|
|
175
|
+
return apiConfig.sign ? this.getDigitalSignatureHeaders({
|
|
176
|
+
method: 'POST',
|
|
177
|
+
authority: host,
|
|
178
|
+
path: api.path
|
|
179
|
+
}, payload) : {};
|
|
180
|
+
},
|
|
171
181
|
...(!useIaf ? { eBayAuthToken } : {})
|
|
172
182
|
};
|
|
173
183
|
}
|
package/dist/eBayApi.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { ContentLanguage, Locale, MarketplaceId, SiteId } from './enums/index.js
|
|
|
11
11
|
import * as errors from './errors/index.js';
|
|
12
12
|
import { IEBayApiRequest } from './request.js';
|
|
13
13
|
import * as types from './types/index.js';
|
|
14
|
-
import { AppConfig, ClientAlerts, Finding, Merchandising, Shopping, Trading } from './types/index.js';
|
|
14
|
+
import { AppConfig, ClientAlerts, Finding, Merchandising, Shopping, Signature, Trading } from './types/index.js';
|
|
15
15
|
export default class eBayApi extends Api {
|
|
16
16
|
static readonly SiteId: typeof enums.SiteId;
|
|
17
17
|
static readonly MarketplaceId: typeof enums.MarketplaceId;
|
|
@@ -54,5 +54,6 @@ export default class eBayApi extends Api {
|
|
|
54
54
|
get shopping(): Shopping;
|
|
55
55
|
get merchandising(): Merchandising;
|
|
56
56
|
get clientAlerts(): ClientAlerts;
|
|
57
|
+
setSignature(signature: Signature): void;
|
|
57
58
|
}
|
|
58
59
|
export { eBayApi, SiteId, MarketplaceId, ContentLanguage, Locale, enums, errors, types };
|
package/dist/eBayApi.js
CHANGED
|
@@ -29,6 +29,13 @@ export default class eBayApi extends Api {
|
|
|
29
29
|
if (!process.env.EBAY_CERT_ID) {
|
|
30
30
|
throw new ApiEnvError('EBAY_CERT_ID');
|
|
31
31
|
}
|
|
32
|
+
let signature = null;
|
|
33
|
+
if (process.env.EBAY_JWE && process.env.EBAY_PRIVATE_KEY) {
|
|
34
|
+
signature = {
|
|
35
|
+
jwe: process.env.EBAY_JWE,
|
|
36
|
+
privateKey: process.env.EBAY_PRIVATE_KEY
|
|
37
|
+
};
|
|
38
|
+
}
|
|
32
39
|
return new eBayApi({
|
|
33
40
|
appId: process.env.EBAY_APP_ID,
|
|
34
41
|
certId: process.env.EBAY_CERT_ID,
|
|
@@ -39,7 +46,8 @@ export default class eBayApi extends Api {
|
|
|
39
46
|
MarketplaceId[process.env.EBAY_MARKETPLACE_ID] :
|
|
40
47
|
MarketplaceId.EBAY_US,
|
|
41
48
|
ruName: process.env.EBAY_RU_NAME,
|
|
42
|
-
sandbox: (process.env.EBAY_SANDBOX === 'true')
|
|
49
|
+
sandbox: (process.env.EBAY_SANDBOX === 'true'),
|
|
50
|
+
signature
|
|
43
51
|
}, req);
|
|
44
52
|
}
|
|
45
53
|
/**
|
|
@@ -85,6 +93,9 @@ export default class eBayApi extends Api {
|
|
|
85
93
|
get clientAlerts() {
|
|
86
94
|
return this._clientAlerts || (this._clientAlerts = this.factory.createClientAlertsApi());
|
|
87
95
|
}
|
|
96
|
+
setSignature(signature) {
|
|
97
|
+
this.config.signature = signature;
|
|
98
|
+
}
|
|
88
99
|
}
|
|
89
100
|
eBayApi.SiteId = SiteId;
|
|
90
101
|
eBayApi.MarketplaceId = MarketplaceId;
|