ebay-api 1.13.4 → 6.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/LICENSE +18 -19
- package/README.md +512 -118
- package/lib/api/apiFactory.d.ts +27 -0
- package/lib/api/apiFactory.js +100 -0
- package/lib/api/apiFactory.js.map +1 -0
- package/lib/api/base.d.ts +13 -0
- package/lib/api/base.js +25 -0
- package/lib/api/base.js.map +1 -0
- package/lib/api/index.d.ts +11 -0
- package/lib/api/index.js +18 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/restful/buy/browse/index.d.ts +84 -0
- package/lib/api/restful/buy/browse/index.js +142 -0
- package/lib/api/restful/buy/browse/index.js.map +1 -0
- package/lib/api/restful/buy/deal/index.d.ts +55 -0
- package/lib/api/restful/buy/deal/index.js +80 -0
- package/lib/api/restful/buy/deal/index.js.map +1 -0
- package/lib/api/restful/buy/feed/index.d.ts +43 -0
- package/lib/api/restful/buy/feed/index.js +85 -0
- package/lib/api/restful/buy/feed/index.js.map +1 -0
- package/lib/api/restful/buy/index.d.ts +17 -0
- package/lib/api/restful/buy/index.js +21 -0
- package/lib/api/restful/buy/index.js.map +1 -0
- package/lib/api/restful/buy/marketing/index.d.ts +27 -0
- package/lib/api/restful/buy/marketing/index.js +51 -0
- package/lib/api/restful/buy/marketing/index.js.map +1 -0
- package/lib/api/restful/buy/marketplaceInsights/index.d.ts +28 -0
- package/lib/api/restful/buy/marketplaceInsights/index.js +51 -0
- package/lib/api/restful/buy/marketplaceInsights/index.js.map +1 -0
- package/lib/api/restful/buy/offer/index.d.ts +23 -0
- package/lib/api/restful/buy/offer/index.js +37 -0
- package/lib/api/restful/buy/offer/index.js.map +1 -0
- package/lib/api/restful/buy/order/index.d.ts +264 -0
- package/lib/api/restful/buy/order/index.js +369 -0
- package/lib/api/restful/buy/order/index.js.map +1 -0
- package/lib/api/restful/commerce/catalog/index.d.ts +73 -0
- package/lib/api/restful/commerce/catalog/index.js +108 -0
- package/lib/api/restful/commerce/catalog/index.js.map +1 -0
- package/lib/api/restful/commerce/charity/index.d.ts +34 -0
- package/lib/api/restful/commerce/charity/index.js +56 -0
- package/lib/api/restful/commerce/charity/index.js.map +1 -0
- package/lib/api/restful/commerce/identity/index.d.ts +14 -0
- package/lib/api/restful/commerce/identity/index.js +27 -0
- package/lib/api/restful/commerce/identity/index.js.map +1 -0
- package/lib/api/restful/commerce/index.d.ts +15 -0
- package/lib/api/restful/commerce/index.js +19 -0
- package/lib/api/restful/commerce/index.js.map +1 -0
- package/lib/api/restful/commerce/notification/index.d.ts +117 -0
- package/lib/api/restful/commerce/notification/index.js +187 -0
- package/lib/api/restful/commerce/notification/index.js.map +1 -0
- package/lib/api/restful/commerce/taxonomy/index.d.ts +78 -0
- package/lib/api/restful/commerce/taxonomy/index.js +135 -0
- package/lib/api/restful/commerce/taxonomy/index.js.map +1 -0
- package/lib/api/restful/commerce/translation/index.d.ts +15 -0
- package/lib/api/restful/commerce/translation/index.js +25 -0
- package/lib/api/restful/commerce/translation/index.js.map +1 -0
- package/lib/api/restful/developer/analytics/index.d.ts +22 -0
- package/lib/api/restful/developer/analytics/index.js +45 -0
- package/lib/api/restful/developer/analytics/index.js.map +1 -0
- package/lib/api/restful/developer/index.d.ts +5 -0
- package/lib/api/restful/developer/index.js +9 -0
- package/lib/api/restful/developer/index.js.map +1 -0
- package/lib/api/restful/index.d.ts +63 -0
- package/lib/api/restful/index.js +165 -0
- package/lib/api/restful/index.js.map +1 -0
- package/lib/api/restful/postOrder/cancellation/index.d.ts +57 -0
- package/lib/api/restful/postOrder/cancellation/index.js +95 -0
- package/lib/api/restful/postOrder/cancellation/index.js.map +1 -0
- package/lib/api/restful/postOrder/case/index.d.ts +63 -0
- package/lib/api/restful/postOrder/case/index.js +97 -0
- package/lib/api/restful/postOrder/case/index.js.map +1 -0
- package/lib/api/restful/postOrder/index.d.ts +11 -0
- package/lib/api/restful/postOrder/index.js +15 -0
- package/lib/api/restful/postOrder/index.js.map +1 -0
- package/lib/api/restful/postOrder/inquiry/index.d.ts +82 -0
- package/lib/api/restful/postOrder/inquiry/index.js +131 -0
- package/lib/api/restful/postOrder/inquiry/index.js.map +1 -0
- package/lib/api/restful/postOrder/return/index.d.ts +231 -0
- package/lib/api/restful/postOrder/return/index.js +361 -0
- package/lib/api/restful/postOrder/return/index.js.map +1 -0
- package/lib/api/restful/sell/account/index.d.ts +217 -0
- package/lib/api/restful/sell/account/index.js +337 -0
- package/lib/api/restful/sell/account/index.js.map +1 -0
- package/lib/api/restful/sell/analytics/index.d.ts +41 -0
- package/lib/api/restful/sell/analytics/index.js +61 -0
- package/lib/api/restful/sell/analytics/index.js.map +1 -0
- package/lib/api/restful/sell/compliance/index.d.ts +37 -0
- package/lib/api/restful/sell/compliance/index.js +57 -0
- package/lib/api/restful/sell/compliance/index.js.map +1 -0
- package/lib/api/restful/sell/feed/index.d.ts +151 -0
- package/lib/api/restful/sell/feed/index.js +255 -0
- package/lib/api/restful/sell/feed/index.js.map +1 -0
- package/lib/api/restful/sell/finances/index.d.ts +74 -0
- package/lib/api/restful/sell/finances/index.js +105 -0
- package/lib/api/restful/sell/finances/index.js.map +1 -0
- package/lib/api/restful/sell/fulfillment/index.d.ts +137 -0
- package/lib/api/restful/sell/fulfillment/index.js +199 -0
- package/lib/api/restful/sell/fulfillment/index.js.map +1 -0
- package/lib/api/restful/sell/index.d.ts +29 -0
- package/lib/api/restful/sell/index.js +33 -0
- package/lib/api/restful/sell/index.js.map +1 -0
- package/lib/api/restful/sell/inventory/index.d.ts +248 -0
- package/lib/api/restful/sell/inventory/index.js +346 -0
- package/lib/api/restful/sell/inventory/index.js.map +1 -0
- package/lib/api/restful/sell/listing/index.d.ts +14 -0
- package/lib/api/restful/sell/listing/index.js +25 -0
- package/lib/api/restful/sell/listing/index.js.map +1 -0
- package/lib/api/restful/sell/logistics/index.d.ts +44 -0
- package/lib/api/restful/sell/logistics/index.js +66 -0
- package/lib/api/restful/sell/logistics/index.js.map +1 -0
- package/lib/api/restful/sell/marketing/index.d.ts +443 -0
- package/lib/api/restful/sell/marketing/index.js +609 -0
- package/lib/api/restful/sell/marketing/index.js.map +1 -0
- package/lib/api/restful/sell/metadata/index.d.ts +77 -0
- package/lib/api/restful/sell/metadata/index.js +131 -0
- package/lib/api/restful/sell/metadata/index.js.map +1 -0
- package/lib/api/restful/sell/negotiation/index.d.ts +24 -0
- package/lib/api/restful/sell/negotiation/index.js +39 -0
- package/lib/api/restful/sell/negotiation/index.js.map +1 -0
- package/lib/api/restful/sell/recommendation/index.d.ts +26 -0
- package/lib/api/restful/sell/recommendation/index.js +39 -0
- package/lib/api/restful/sell/recommendation/index.js.map +1 -0
- package/lib/api/traditional/XMLRequest.d.ts +98 -0
- package/lib/api/traditional/XMLRequest.js +191 -0
- package/lib/api/traditional/XMLRequest.js.map +1 -0
- package/lib/api/traditional/clientAlerts/index.d.ts +9 -0
- package/lib/api/traditional/clientAlerts/index.js +15 -0
- package/lib/api/traditional/clientAlerts/index.js.map +1 -0
- package/lib/api/traditional/clientAlerts/types.d.ts +31 -0
- package/lib/api/traditional/clientAlerts/types.js +36 -0
- package/lib/api/traditional/clientAlerts/types.js.map +1 -0
- package/lib/api/traditional/fields.d.ts +1948 -0
- package/lib/api/traditional/fields.js +1949 -0
- package/lib/api/traditional/fields.js.map +1 -0
- package/lib/api/traditional/finding/index.d.ts +12 -0
- package/lib/api/traditional/finding/index.js +16 -0
- package/lib/api/traditional/finding/index.js.map +1 -0
- package/lib/api/traditional/index.d.ts +17 -0
- package/lib/api/traditional/index.js +207 -0
- package/lib/api/traditional/index.js.map +1 -0
- package/lib/api/traditional/merchandising/index.d.ts +7 -0
- package/lib/api/traditional/merchandising/index.js +11 -0
- package/lib/api/traditional/merchandising/index.js.map +1 -0
- package/lib/api/traditional/shopping/index.d.ts +11 -0
- package/lib/api/traditional/shopping/index.js +16 -0
- package/lib/api/traditional/shopping/index.js.map +1 -0
- package/lib/api/traditional/trading/index.d.ts +142 -0
- package/lib/api/traditional/trading/index.js +146 -0
- package/lib/api/traditional/trading/index.js.map +1 -0
- package/lib/auth/authNAuth.d.ts +49 -0
- package/lib/auth/authNAuth.js +122 -0
- package/lib/auth/authNAuth.js.map +1 -0
- package/lib/auth/index.d.ts +17 -0
- package/lib/auth/index.js +32 -0
- package/lib/auth/index.js.map +1 -0
- package/lib/auth/oAuth2.d.ts +90 -0
- package/lib/auth/oAuth2.js +258 -0
- package/lib/auth/oAuth2.js.map +1 -0
- package/lib/ebay-api.min.js +2 -0
- package/lib/ebay-api.min.js.map +1 -0
- package/lib/enums/apiEnums.d.ts +49 -0
- package/lib/enums/apiEnums.js +55 -0
- package/lib/enums/apiEnums.js.map +1 -0
- package/lib/enums/index.d.ts +2 -0
- package/lib/enums/index.js +15 -0
- package/lib/enums/index.js.map +1 -0
- package/lib/enums/restfulEnums.d.ts +672 -0
- package/lib/enums/restfulEnums.js +714 -0
- package/lib/enums/restfulEnums.js.map +1 -0
- package/lib/errors/index.d.ts +66 -0
- package/lib/errors/index.js +208 -0
- package/lib/errors/index.js.map +1 -0
- package/lib/index.d.ts +55 -0
- package/lib/index.js +98 -0
- package/lib/index.js.map +1 -0
- package/lib/request.d.ts +26 -0
- package/lib/request.js +51 -0
- package/lib/request.js.map +1 -0
- package/lib/types/apiTypes.d.ts +28 -0
- package/lib/types/apiTypes.js +3 -0
- package/lib/types/apiTypes.js.map +1 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.js +16 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/restfulTypes.d.ts +1067 -0
- package/lib/types/restfulTypes.js +3 -0
- package/lib/types/restfulTypes.js.map +1 -0
- package/lib/types/traditonalTypes.d.ts +34 -0
- package/lib/types/traditonalTypes.js +3 -0
- package/lib/types/traditonalTypes.js.map +1 -0
- package/package.json +115 -21
- package/.npmignore +0 -17
- package/.travis.yml +0 -7
- package/examples/Finding-FindItemsByKeywords.js +0 -46
- package/examples/Merchandising-GetMostWatchedItemsRequest.js +0 -16
- package/examples/Shopping-GetSingleItem.js +0 -18
- package/examples/Trading-GetOrders.js +0 -26
- package/index.js +0 -10
- package/lib/deep-to-array.js +0 -42
- package/lib/defaults.js +0 -69
- package/lib/errors.js +0 -44
- package/lib/json-parser.js +0 -336
- package/lib/key-lists.js +0 -64
- package/lib/urls.js +0 -64
- package/lib/versions.js +0 -35
- package/lib/xml-converter.js +0 -21
- package/lib/xml-request.js +0 -207
- package/scripts/parse-input-xml.js +0 -41
- package/test/deep-to-array.test.js +0 -100
- package/test/errors.test.js +0 -75
- package/test/helpers.js +0 -22
- package/test/mocha.opts +0 -1
- package/test/mocks/GetMultipleItems.xml +0 -115
- package/test/mocks/GetOrders-empty.xml +0 -17
- package/test/mocks/GetOrders.xml +0 -463
- package/test/pagination.test.js +0 -5
- package/test/parsing.test.js +0 -248
- package/test/xml-request.test.js +0 -447
package/test/parsing.test.js
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
require('./helpers');
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
fs = require('fs'),
|
|
5
|
-
path = require('path'),
|
|
6
|
-
convertXmlToJson = require('../lib/xml-converter').convertXmlToJson,
|
|
7
|
-
parseResponseJson = require('../lib/json-parser').parseResponseJson;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
describe('`parseResponseJson` with unlimited depth', function() {
|
|
11
|
-
|
|
12
|
-
context('Trading:GetOrders response', function () {
|
|
13
|
-
var responseXml, responseJson, parsedResponse;
|
|
14
|
-
|
|
15
|
-
var requestContext = {
|
|
16
|
-
serviceName: 'Trading',
|
|
17
|
-
opType: 'GetOrders',
|
|
18
|
-
parseDepth: -1
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
beforeEach('load mock response', function () {
|
|
22
|
-
responseXml = fs.readFileSync(path.resolve(__dirname, 'mocks', 'GetOrders.xml'), {encoding: 'utf8'});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
beforeEach('convert xml to json', function (done) {
|
|
26
|
-
convertXmlToJson(responseXml, requestContext, function (error, _json) {
|
|
27
|
-
if (error) return done(error);
|
|
28
|
-
responseJson = _json;
|
|
29
|
-
done();
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
beforeEach('parse json', function (done) {
|
|
34
|
-
parseResponseJson(responseJson, requestContext, function (error, _data) {
|
|
35
|
-
if (error) return done(error);
|
|
36
|
-
parsedResponse = _data;
|
|
37
|
-
done();
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('converted XML to JSON', function () {
|
|
42
|
-
expect(responseJson).to.have.property('GetOrdersResponse');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('parsed data from JSON', function () {
|
|
46
|
-
expect(parsedResponse).to.have.property('Timestamp', '2015-10-11T15:01:00.222Z');
|
|
47
|
-
expect(parsedResponse).to.have.property('Ack', 'Success');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('converted <OrderArray> to `Orders`', function() {
|
|
51
|
-
expect(parsedResponse).to.have.property('Orders');
|
|
52
|
-
expect(parsedResponse).not.to.have.property('OrderArray');
|
|
53
|
-
expect(parsedResponse.Orders).to.have.length(2);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('converted <TransactionArray> to `Transactions`', function() {
|
|
57
|
-
var _orders = parsedResponse.Orders;
|
|
58
|
-
|
|
59
|
-
expect(_orders[0]).to.have.property('Transactions');
|
|
60
|
-
expect(_orders[0]).not.to.have.property('TransactionArray');
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// `Transactions` are always arrays
|
|
64
|
-
expect(_orders[0].Transactions).to.have.length(1);
|
|
65
|
-
expect(_orders[1].Transactions).to.have.length(2);
|
|
66
|
-
|
|
67
|
-
expect(_orders[0].Transactions[0]).to.have.have.deep.property('Buyer.Email', 'ebay-buyer@mail.com');
|
|
68
|
-
|
|
69
|
-
expect(_orders[1].Transactions[0]).to.have.deep.property('Item.Title', 'Penguin');
|
|
70
|
-
expect(_orders[1].Transactions[1]).to.have.deep.property('Item.Title', 'Panda');
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('preserves certain fields known to be arrays, even with single value', function() {
|
|
74
|
-
// NOTE: this gets into the thorny assumptions the parser makes,
|
|
75
|
-
// where arrays turn into objects if there's only one value.
|
|
76
|
-
// (exception tested here only applies to specially handled cases.)
|
|
77
|
-
var _orders = parsedResponse.Orders;
|
|
78
|
-
|
|
79
|
-
// `TaxDetails` are always arrays
|
|
80
|
-
expect(_orders[0].Transactions[0]).to.have.deep.property('Taxes.TaxDetails')
|
|
81
|
-
.that.is.a.instanceof(Array);
|
|
82
|
-
|
|
83
|
-
expect(_orders[0].Transactions[0].Taxes.TaxDetails).to.have.length(1);
|
|
84
|
-
expect(_orders[1].Transactions[0].Taxes.TaxDetails).to.have.length(2);
|
|
85
|
-
expect(_orders[1].Transactions[1].Taxes.TaxDetails).to.have.length(2);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('flattens sub-elements within known arrays', function() {
|
|
89
|
-
expect(parsedResponse.Orders[0].Transactions[0].Taxes.TaxDetails[0])
|
|
90
|
-
.to.have.property('Imposition', 'SalesTax');
|
|
91
|
-
expect(parsedResponse.Orders[1].Transactions[1].Taxes.TaxDetails[0])
|
|
92
|
-
.to.have.property('Imposition', 'SalesTax');
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it.skip('converts booleans', function() { // DISABLED temporarily
|
|
96
|
-
expect(parsedResponse.Orders[0]).to.have.property('IsMultiLegShipping', false);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it.skip('converts numbers, but not numeric IDs', function() { // DISABLED temporarily
|
|
100
|
-
// converted
|
|
101
|
-
expect(parsedResponse).to.have.deep.property('PaginationResult.TotalNumberOfPages', 1);
|
|
102
|
-
expect(parsedResponse).to.have.deep.property('PaginationResult.TotalNumberOfEntries', 2);
|
|
103
|
-
|
|
104
|
-
// still a string
|
|
105
|
-
expect(parsedResponse.Orders[0].Transactions[0]).to.have.deep.property('Item.ItemID', '222222222222');
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
it('converts currency amounts', function() {
|
|
110
|
-
expect(parsedResponse.Orders[0]).to.have.property('AdjustmentAmount')
|
|
111
|
-
.that.deep.equal({amount: 0, currencyID: 'USD'});
|
|
112
|
-
expect(parsedResponse.Orders[0]).to.have.property('AmountPaid')
|
|
113
|
-
.that.deep.equal({amount: 6, currencyID: 'USD'});
|
|
114
|
-
expect(parsedResponse.Orders[0].Transactions[0]).to.have.property('TransactionPrice')
|
|
115
|
-
.that.deep.equal({amount: 3, currencyID: 'USD'});
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
context('Empty Trading:GetOrders response', function() {
|
|
121
|
-
var responseXml, responseJson, parsedResponse;
|
|
122
|
-
|
|
123
|
-
var requestContext = {
|
|
124
|
-
serviceName: 'Trading',
|
|
125
|
-
opType: 'GetOrders',
|
|
126
|
-
parseDepth: -1
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
beforeEach('load mock response', function () {
|
|
130
|
-
responseXml = fs.readFileSync(path.resolve(__dirname, 'mocks', 'GetOrders-empty.xml'), {encoding: 'utf8'});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
beforeEach('convert xml to json', function (done) {
|
|
134
|
-
convertXmlToJson(responseXml, requestContext, function (error, _json) {
|
|
135
|
-
if (error) return done(error);
|
|
136
|
-
responseJson = _json;
|
|
137
|
-
done();
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
beforeEach('parse json', function (done) {
|
|
142
|
-
parseResponseJson(responseJson, requestContext, function (error, _data) {
|
|
143
|
-
if (error) return done(error);
|
|
144
|
-
parsedResponse = _data;
|
|
145
|
-
done();
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('converted XML to JSON', function () {
|
|
150
|
-
expect(responseJson).to.have.property('GetOrdersResponse');
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('converted <OrderArray> to empty `Orders` array', function() {
|
|
154
|
-
expect(parsedResponse).to.have.property('Orders');
|
|
155
|
-
expect(parsedResponse).not.to.have.property('OrderArray');
|
|
156
|
-
expect(parsedResponse.Orders).to.have.length(0);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
context('Shopping:GetMultipleItems response', function () {
|
|
162
|
-
var responseXml, responseJson, parsedResponse, requestContext;
|
|
163
|
-
|
|
164
|
-
requestContext = {
|
|
165
|
-
serviceName: 'Shopping',
|
|
166
|
-
opType: 'GetMultipleItems',
|
|
167
|
-
parseDepth: -1
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
beforeEach('load mock response', function () {
|
|
171
|
-
responseXml = fs.readFileSync(path.resolve(__dirname, 'mocks', 'GetMultipleItems.xml'), {encoding: 'utf8'});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
beforeEach('convert xml to json', function (done) {
|
|
175
|
-
convertXmlToJson(responseXml, requestContext, function (error, _json) {
|
|
176
|
-
if (error) return done(error);
|
|
177
|
-
responseJson = _json;
|
|
178
|
-
done();
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
beforeEach('parse json', function (done) {
|
|
183
|
-
parseResponseJson(responseJson, requestContext, function (error, _data) {
|
|
184
|
-
if (error) return done(error);
|
|
185
|
-
parsedResponse = _data;
|
|
186
|
-
done();
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it('converted XML to JSON', function () {
|
|
191
|
-
expect(responseJson).to.have.property('GetMultipleItemsResponse');
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('parsed data from JSON', function () {
|
|
195
|
-
expect(parsedResponse).to.have.property('Timestamp', '2015-10-13T15:00:00.000Z');
|
|
196
|
-
expect(parsedResponse).to.have.property('Ack', 'Success');
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it('has array of `Items`', function() {
|
|
200
|
-
expect(parsedResponse).to.have.property('Item')
|
|
201
|
-
.that.is.an.instanceof(Array);
|
|
202
|
-
expect(parsedResponse.Item).to.have.length(1);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it('item has expected properties', function() {
|
|
206
|
-
expect(parsedResponse.Item[0]).to.have.property('ItemID', '222222222222');
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
// TODO list of fields that are known to repeat...
|
|
210
|
-
// e.g. 'PictureURL' can be an array or single value.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
context('with shallow parsing', function() {
|
|
215
|
-
beforeEach(function() {
|
|
216
|
-
requestContext = {
|
|
217
|
-
serviceName: 'Shopping',
|
|
218
|
-
opType: 'GetMultipleItems',
|
|
219
|
-
parseDepth: 1 // !!
|
|
220
|
-
};
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
beforeEach('convert xml to json', function (done) {
|
|
224
|
-
convertXmlToJson(responseXml, requestContext, function (error, _json) {
|
|
225
|
-
if (error) return done(error);
|
|
226
|
-
responseJson = _json;
|
|
227
|
-
done();
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
beforeEach('parse json shallowly', function (done) {
|
|
232
|
-
parseResponseJson(responseJson, requestContext, function (error, _data) {
|
|
233
|
-
if (error) return done(error);
|
|
234
|
-
parsedResponse = _data;
|
|
235
|
-
done();
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
it('leaves deep elements as arrays', function() {
|
|
240
|
-
expect(parsedResponse.Timestamp).to.be.be.instanceof(Array);
|
|
241
|
-
expect(parsedResponse.Item[0].ItemID).to.be.be.instanceof(Array);
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
});
|
package/test/xml-request.test.js
DELETED
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
require('./helpers');
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
request = require('request'),
|
|
5
|
-
ebay = require('../index'),
|
|
6
|
-
xmlRequest = ebay.xmlRequest;
|
|
7
|
-
|
|
8
|
-
describe('XML requests', function() {
|
|
9
|
-
describe('building requests', function() {
|
|
10
|
-
beforeEach('stub request', function () {
|
|
11
|
-
this.sinon.stub(request, 'post', function (options, callback) {
|
|
12
|
-
process.nextTick(function () {
|
|
13
|
-
callback(null, {statusCode: 200}, {});
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
describe('Shopping: GetSingleItem', function () {
|
|
19
|
-
beforeEach('build request', function () {
|
|
20
|
-
xmlRequest({
|
|
21
|
-
serviceName: 'Shopping',
|
|
22
|
-
opType: 'GetSingleItem',
|
|
23
|
-
sandbox: true,
|
|
24
|
-
appId: 'ABCDEF',
|
|
25
|
-
raw: true, // no parsing
|
|
26
|
-
params: {
|
|
27
|
-
'ItemID': '123456'
|
|
28
|
-
},
|
|
29
|
-
reqOptions: {
|
|
30
|
-
headers: {
|
|
31
|
-
'X-Extra': 'um'
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}, function noop() {
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('initiated request with expected parameters', function () {
|
|
39
|
-
expect(request.post).to.have.been.calledOnce;
|
|
40
|
-
|
|
41
|
-
expect(request.post.lastCall.args[0]).to.deep.equal({
|
|
42
|
-
url: 'http://open.api.sandbox.ebay.com/shopping',
|
|
43
|
-
headers: {
|
|
44
|
-
'Content-Type': 'text/xml',
|
|
45
|
-
'X-EBAY-API-APP-ID': 'ABCDEF',
|
|
46
|
-
'X-EBAY-API-CALL-NAME': 'GetSingleItem',
|
|
47
|
-
'X-EBAY-API-VERSION': '897',
|
|
48
|
-
'X-EBAY-API-SITE-ID': '0',
|
|
49
|
-
'X-EBAY-API-REQUEST-ENCODING': 'XML',
|
|
50
|
-
'X-EBAY-API-RESPONSE-ENCODING': 'XML',
|
|
51
|
-
'X-Extra': 'um'
|
|
52
|
-
},
|
|
53
|
-
body: '<?xml version="1.0" encoding="UTF-8"?>\n' +
|
|
54
|
-
'<GetSingleItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">\n' +
|
|
55
|
-
' <ItemID>123456</ItemID>\n' +
|
|
56
|
-
'</GetSingleItemRequest>',
|
|
57
|
-
agentOptions: {
|
|
58
|
-
ciphers: 'ALL',
|
|
59
|
-
secureProtocol: 'TLSv1_method',
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
describe('Shopping: GetMultipleItems', function () {
|
|
67
|
-
beforeEach('build request', function () {
|
|
68
|
-
xmlRequest({
|
|
69
|
-
serviceName: 'Shopping',
|
|
70
|
-
opType: 'GetMultipleItems',
|
|
71
|
-
sandbox: true,
|
|
72
|
-
appId: 'ABCDEF',
|
|
73
|
-
raw: true, // no parsing
|
|
74
|
-
params: {
|
|
75
|
-
'ItemID': ['123456', '345678']
|
|
76
|
-
}
|
|
77
|
-
}, function noop() {
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('handles multiple parameter values', function () {
|
|
82
|
-
expect(request.post).to.have.been.calledOnce;
|
|
83
|
-
|
|
84
|
-
expect(request.post.lastCall.args[0]).to.have.property('body',
|
|
85
|
-
'<?xml version="1.0" encoding="UTF-8"?>\n' +
|
|
86
|
-
'<GetMultipleItemsRequest xmlns="urn:ebay:apis:eBLBaseComponents">\n' +
|
|
87
|
-
' <ItemID>123456</ItemID>\n' +
|
|
88
|
-
' <ItemID>345678</ItemID>\n' +
|
|
89
|
-
'</GetMultipleItemsRequest>'
|
|
90
|
-
);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
describe('Trading: GetOrders (authenticated)', function () {
|
|
96
|
-
beforeEach('build request', function () {
|
|
97
|
-
xmlRequest({
|
|
98
|
-
serviceName: 'Trading',
|
|
99
|
-
opType: 'GetOrders',
|
|
100
|
-
sandbox: true,
|
|
101
|
-
appId: 'ABCDEF',
|
|
102
|
-
authToken: 'super-secret',
|
|
103
|
-
raw: true, // no parsing
|
|
104
|
-
params: {
|
|
105
|
-
'NumberOfDays': '30'
|
|
106
|
-
}
|
|
107
|
-
}, function noop() {
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('adds token to XML request', function () {
|
|
112
|
-
expect(request.post.lastCall.args[0]).to.have.property('body',
|
|
113
|
-
'<?xml version="1.0" encoding="UTF-8"?>\n' +
|
|
114
|
-
'<GetOrdersRequest xmlns="urn:ebay:apis:eBLBaseComponents">\n' +
|
|
115
|
-
' <RequesterCredentials>\n' +
|
|
116
|
-
' <eBayAuthToken>super-secret</eBayAuthToken>\n' +
|
|
117
|
-
' </RequesterCredentials>\n' +
|
|
118
|
-
' <NumberOfDays>30</NumberOfDays>\n' +
|
|
119
|
-
'</GetOrdersRequest>'
|
|
120
|
-
);
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
describe('Finding: findItemsByKeywords', function () {
|
|
126
|
-
beforeEach('build request', function () {
|
|
127
|
-
xmlRequest({
|
|
128
|
-
serviceName: 'Finding',
|
|
129
|
-
opType: 'findItemsByKeywords',
|
|
130
|
-
sandbox: true,
|
|
131
|
-
appId: 'ABCDEF',
|
|
132
|
-
raw: true, // no parsing
|
|
133
|
-
params: {
|
|
134
|
-
keywords: ['Canon', 'Powershot'],
|
|
135
|
-
outputSelector: ['AspectHistogram'],
|
|
136
|
-
itemFilter: [
|
|
137
|
-
{name: 'FreeShippingOnly', value: 'true'},
|
|
138
|
-
{name: 'MaxPrice', value: '150'},
|
|
139
|
-
],
|
|
140
|
-
domainFilter: [
|
|
141
|
-
{name: 'domainName', value: 'Digital_Cameras'}
|
|
142
|
-
],
|
|
143
|
-
paginationInput: {
|
|
144
|
-
entriesPerPage: '5'
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}, function noop() {
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('initiated request with expected parameters', function () {
|
|
152
|
-
expect(request.post).to.have.been.calledOnce;
|
|
153
|
-
|
|
154
|
-
expect(request.post.lastCall.args[0]).to.deep.equal({
|
|
155
|
-
url: 'http://svcs.sandbox.ebay.com/services/search/FindingService/v1',
|
|
156
|
-
headers: {
|
|
157
|
-
'X-EBAY-SOA-SECURITY-APPNAME': 'ABCDEF',
|
|
158
|
-
'X-EBAY-SOA-REQUEST-DATA-FORMAT': 'XML',
|
|
159
|
-
'X-EBAY-SOA-RESPONSE-DATA-FORMAT': 'XML',
|
|
160
|
-
'X-EBAY-SOA-GLOBAL-ID': 'EBAY-US',
|
|
161
|
-
'X-EBAY-SOA-SERVICE-VERSION': '1.13.0',
|
|
162
|
-
'X-EBAY-SOA-OPERATION-NAME': 'findItemsByKeywords'
|
|
163
|
-
},
|
|
164
|
-
body: '<?xml version="1.0" encoding="UTF-8"?>\n' +
|
|
165
|
-
'<findItemsByKeywordsRequest xmlns="http://www.ebay.com/marketplace/search/v1/services">\n' +
|
|
166
|
-
' <keywords>Canon</keywords>\n' +
|
|
167
|
-
' <keywords>Powershot</keywords>\n' +
|
|
168
|
-
' <outputSelector>AspectHistogram</outputSelector>\n' +
|
|
169
|
-
' <itemFilter>\n' +
|
|
170
|
-
' <name>FreeShippingOnly</name>\n' +
|
|
171
|
-
' <value>true</value>\n' +
|
|
172
|
-
' </itemFilter>\n' +
|
|
173
|
-
' <itemFilter>\n' +
|
|
174
|
-
' <name>MaxPrice</name>\n' +
|
|
175
|
-
' <value>150</value>\n' +
|
|
176
|
-
' </itemFilter>\n' +
|
|
177
|
-
' <domainFilter>\n' +
|
|
178
|
-
' <name>domainName</name>\n' +
|
|
179
|
-
' <value>Digital_Cameras</value>\n' +
|
|
180
|
-
' </domainFilter>\n' +
|
|
181
|
-
' <paginationInput>\n' +
|
|
182
|
-
' <entriesPerPage>5</entriesPerPage>\n' +
|
|
183
|
-
' </paginationInput>\n' +
|
|
184
|
-
'</findItemsByKeywordsRequest>',
|
|
185
|
-
agentOptions: {
|
|
186
|
-
ciphers: 'ALL',
|
|
187
|
-
secureProtocol: 'TLSv1_method',
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
describe('nested params', function () {
|
|
196
|
-
beforeEach('build request', function () {
|
|
197
|
-
xmlRequest({
|
|
198
|
-
serviceName: 'Trading',
|
|
199
|
-
opType: 'GetOrderTransactions',
|
|
200
|
-
appId: 'ABCDEF',
|
|
201
|
-
raw: true, // no parsing
|
|
202
|
-
params: {
|
|
203
|
-
'ItemTransactionIDArray': [{
|
|
204
|
-
'ItemTransactionID': {
|
|
205
|
-
'OrderLineItemID': '12345-67890',
|
|
206
|
-
'SomeOtherID': 'ABCDEF'
|
|
207
|
-
}
|
|
208
|
-
}]
|
|
209
|
-
}
|
|
210
|
-
}, function noop() {
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it('converts properly to nested XML', function () {
|
|
215
|
-
expect(request.post.lastCall.args[0]).to.have.property('body',
|
|
216
|
-
'<?xml version="1.0" encoding="UTF-8"?>\n' +
|
|
217
|
-
'<GetOrderTransactionsRequest xmlns="urn:ebay:apis:eBLBaseComponents">\n' +
|
|
218
|
-
' <ItemTransactionIDArray>\n' +
|
|
219
|
-
' <ItemTransactionID>\n' +
|
|
220
|
-
' <OrderLineItemID>12345-67890</OrderLineItemID>\n' +
|
|
221
|
-
' <SomeOtherID>ABCDEF</SomeOtherID>\n' +
|
|
222
|
-
' </ItemTransactionID>\n' +
|
|
223
|
-
' </ItemTransactionIDArray>\n' +
|
|
224
|
-
'</GetOrderTransactionsRequest>'
|
|
225
|
-
);
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
describe('response error handling', function() {
|
|
233
|
-
var err, data;
|
|
234
|
-
|
|
235
|
-
beforeEach(function() {
|
|
236
|
-
err = null;
|
|
237
|
-
data = null;
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
function _buildResponseCallback(errorCode, errorClassification, errorSeverity) {
|
|
241
|
-
return function(options, callback) {
|
|
242
|
-
process.nextTick(function() {
|
|
243
|
-
callback(null, {
|
|
244
|
-
statusCode: 200,
|
|
245
|
-
body: '<?xml version="1.0" encoding="UTF-8"?>\n' +
|
|
246
|
-
'<GetOrdersResponse xmlns="urn:ebay:apis:eBLBaseComponents">\n' +
|
|
247
|
-
' <Ack>' + (errorSeverity === 'Warning' ? 'Warning' : 'Failure') + '</Ack>\n' +
|
|
248
|
-
' <Errors>\n' +
|
|
249
|
-
' <ShortMessage>Something went wrong.</ShortMessage>\n' +
|
|
250
|
-
' <LongMessage>Something really went wrong.</LongMessage>\n' +
|
|
251
|
-
' <ErrorCode>' + errorCode + '</ErrorCode>\n' +
|
|
252
|
-
' <SeverityCode>' + errorSeverity + '</SeverityCode>\n' +
|
|
253
|
-
' <ErrorClassification>' + errorClassification + '</ErrorClassification>\n' +
|
|
254
|
-
' </Errors>' +
|
|
255
|
-
' <OrderArray><Order></Order></OrderArray>' +
|
|
256
|
-
'</GetOrdersResponse>' // (not comprehensive)
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
describe('RequestError from response', function() {
|
|
263
|
-
beforeEach('stub request', function() {
|
|
264
|
-
this.sinon.stub(request, 'post', _buildResponseCallback('12345', 'RequestError', 'Error'));
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
beforeEach('simulate request', function (done) {
|
|
268
|
-
xmlRequest({
|
|
269
|
-
serviceName: 'Trading',
|
|
270
|
-
opType: 'GetOrders'
|
|
271
|
-
}, function(_err, _data) {
|
|
272
|
-
err = _err;
|
|
273
|
-
data = _data;
|
|
274
|
-
done();
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
it('throws an EbayRequestError', function() {
|
|
279
|
-
expect(err).to.be.an.instanceOf(ebay.EbayRequestError);
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it('error has context properties', function() {
|
|
283
|
-
expect(err).to.have.property('severityCode', 'Error');
|
|
284
|
-
expect(err).to.have.property('classification', 'RequestError');
|
|
285
|
-
expect(err).to.have.property('errors').that.is.instanceof(Array);
|
|
286
|
-
expect(err).to.have.property('details');
|
|
287
|
-
expect(err).to.have.property('requestContext');
|
|
288
|
-
expect(err.requestContext).to.have.property('serviceName', 'Trading');
|
|
289
|
-
expect(err.requestContext).to.have.property('reqOptions');
|
|
290
|
-
expect(err.requestContext.reqOptions).to.have.property('body');
|
|
291
|
-
expect(err.requestContext.reqOptions).to.have.property('url');
|
|
292
|
-
expect(err.requestContext).to.have.property('response');
|
|
293
|
-
expect(err.requestContext.response).to.have.property('statusCode', 200);
|
|
294
|
-
expect(err.requestContext.response).to.have.property('body').that.match(/^<\?xml/);
|
|
295
|
-
expect(err.requestContext).not.to.have.property('parser'); // no functions
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
it('also gets response data', function() {
|
|
299
|
-
expect(data).to.be.ok;
|
|
300
|
-
expect(data).to.have.property('Ack', 'Failure');
|
|
301
|
-
expect(data).to.have.property('Orders').that.is.instanceof(Array);
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
describe('Warning from response', function() {
|
|
307
|
-
beforeEach('stub request', function() {
|
|
308
|
-
this.sinon.stub(request, 'post', _buildResponseCallback('12345', 'RequestError', 'Warning'));
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
beforeEach('simulate request', function (done) {
|
|
312
|
-
xmlRequest({
|
|
313
|
-
serviceName: 'Trading',
|
|
314
|
-
opType: 'GetOrders'
|
|
315
|
-
}, function(_err, _data) {
|
|
316
|
-
err = _err;
|
|
317
|
-
data = _data;
|
|
318
|
-
done();
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
it('throws an EbayRequestError', function() {
|
|
323
|
-
expect(err).to.be.an.instanceOf(ebay.EbayRequestError);
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
it('error has context properties', function() {
|
|
327
|
-
expect(err).to.have.property('severityCode', 'Warning');
|
|
328
|
-
expect(err).to.have.property('classification', 'RequestError');
|
|
329
|
-
expect(err).to.have.property('errors').that.is.instanceof(Array);
|
|
330
|
-
expect(err).to.have.property('details');
|
|
331
|
-
expect(err).to.have.property('requestContext');
|
|
332
|
-
expect(err.requestContext).to.have.property('serviceName', 'Trading');
|
|
333
|
-
expect(err.requestContext).to.have.property('reqOptions');
|
|
334
|
-
expect(err.requestContext.reqOptions).to.have.property('body');
|
|
335
|
-
expect(err.requestContext.reqOptions).to.have.property('url');
|
|
336
|
-
expect(err.requestContext).to.have.property('response');
|
|
337
|
-
expect(err.requestContext.response).to.have.property('statusCode', 200);
|
|
338
|
-
expect(err.requestContext.response).to.have.property('body').that.match(/^<\?xml/);
|
|
339
|
-
expect(err.requestContext).not.to.have.property('parser'); // no functions
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
it('also gets response data', function() {
|
|
343
|
-
expect(data).to.be.ok;
|
|
344
|
-
expect(data).to.have.property('Ack', 'Warning');
|
|
345
|
-
expect(data).to.have.property('Orders').that.is.instanceof(Array);
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
describe('SystemError from response', function() {
|
|
351
|
-
beforeEach('stub request', function() {
|
|
352
|
-
this.sinon.stub(request, 'post', _buildResponseCallback('12345', 'SystemError', 'Error'));
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
beforeEach('simulate request', function (done) {
|
|
356
|
-
xmlRequest({
|
|
357
|
-
serviceName: 'Trading',
|
|
358
|
-
opType: 'GetOrders'
|
|
359
|
-
}, function(_err, _data) {
|
|
360
|
-
err = _err;
|
|
361
|
-
data = _data;
|
|
362
|
-
done();
|
|
363
|
-
});
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
it('throws an EbaySystemError', function() {
|
|
367
|
-
expect(err).to.be.an.instanceOf(ebay.EbaySystemError);
|
|
368
|
-
});
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
describe('XML parsing fails', function() {
|
|
372
|
-
beforeEach('stub request', function() {
|
|
373
|
-
// screw up XML body
|
|
374
|
-
this.sinon.stub(request, 'post', _buildResponseCallback('<<<<', '>>>>', 'Error'));
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
beforeEach('simulate request', function (done) {
|
|
378
|
-
xmlRequest({
|
|
379
|
-
serviceName: 'Trading',
|
|
380
|
-
opType: 'GetOrders'
|
|
381
|
-
}, function(_err, _data) {
|
|
382
|
-
err = _err;
|
|
383
|
-
data = _data;
|
|
384
|
-
done();
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
it('throws an EbayClientError', function() {
|
|
389
|
-
expect(err).to.be.an.instanceOf(ebay.EbayClientError);
|
|
390
|
-
});
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
describe('non-200 response code', function() {
|
|
394
|
-
beforeEach('stub request', function () {
|
|
395
|
-
this.sinon.stub(request, 'post', function (options, callback) {
|
|
396
|
-
process.nextTick(function () {
|
|
397
|
-
callback(null, {statusCode: 503});
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
beforeEach('simulate request', function (done) {
|
|
403
|
-
xmlRequest({
|
|
404
|
-
serviceName: 'Trading',
|
|
405
|
-
opType: 'GetOrders'
|
|
406
|
-
}, function(_err) {
|
|
407
|
-
err = _err;
|
|
408
|
-
done();
|
|
409
|
-
});
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
it('throws an EbayClientError', function() {
|
|
413
|
-
expect(err).to.be.an.instanceOf(ebay.EbayClientError);
|
|
414
|
-
expect(err.message).to.match(/503/);
|
|
415
|
-
});
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
describe('other client error', function() {
|
|
419
|
-
beforeEach('stub request', function () {
|
|
420
|
-
this.sinon.stub(request, 'post', function (options, callback) {
|
|
421
|
-
process.nextTick(function () {
|
|
422
|
-
callback(null, {statusCode: 200, body: ''});
|
|
423
|
-
});
|
|
424
|
-
});
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
beforeEach('simulate request', function (done) {
|
|
428
|
-
xmlRequest({
|
|
429
|
-
serviceName: 'Trading',
|
|
430
|
-
opType: 'GetOrders',
|
|
431
|
-
parser: function(data, options, callback) {
|
|
432
|
-
callback(new Error("Boo"));
|
|
433
|
-
}
|
|
434
|
-
}, function(_err) {
|
|
435
|
-
err = _err;
|
|
436
|
-
done();
|
|
437
|
-
});
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
it('throws an EbayClientError', function() {
|
|
441
|
-
expect(err).to.be.an.instanceOf(ebay.EbayClientError);
|
|
442
|
-
expect(err.message).to.match(/Boo/);
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
});
|
|
446
|
-
});
|
|
447
|
-
});
|