Skip to content

Commit

Permalink
Get picture URL large on FindingService calls (#80)
Browse files Browse the repository at this point in the history
* eslint fixes

* add output selector to get PictureURLLarge from ebay find call
  • Loading branch information
sghael authored Apr 3, 2020
1 parent 7332417 commit 807f719
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/buildURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const buildURL = {
baseUrl += options.additionalParam ? '&' + options.additionalParam : '';
baseUrl += options.sortOrder ? '&sortOrder=' + options.sortOrder : '';
baseUrl += '&outputSelector(0)=SellerInfo';
baseUrl += '&outputSelector(1)=PictureURLLarge';
baseUrl += options.limit ? '&paginationInput.entriesPerPage=' + options.limit : '';
baseUrl += options.globalID ? '&GLOBAL-ID=' + options.globalID : '';
baseUrl += options.pageNumber ? '&paginationInput.pageNumber=' + options.pageNumber : '';
Expand Down
12 changes: 6 additions & 6 deletions test/buildURL.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('test building url methods', () => {


it('test search url', () => {
let expected_search_url = 'https://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=testID&OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&keywords=iphone&outputSelector(0)=SellerInfo&paginationInput.entriesPerPage=6&GLOBAL-ID=EBAY-US'
let expected_search_url = 'https://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=testID&OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&keywords=iphone&outputSelector(0)=SellerInfo&outputSelector(1)=PictureURLLarge&paginationInput.entriesPerPage=6&GLOBAL-ID=EBAY-US';
let options = {
name: 'iphone',
operationName: 'findItemsByKeywords',
Expand All @@ -16,32 +16,32 @@ describe('test building url methods', () => {
limit: 6,
globalID: 'EBAY-US',
baseSvcUrl: 'svcs.ebay.com'
}
};
expect(buildURL.buildSearchUrl(options)).to.be.equal(expected_search_url);
});

it('test Shopping url without selector', () => {
let expected_search_url = 'https://open.api.ebay.com/Shopping?appid=testID&callname=demoShoppingName&version=967&siteid=0&responseencoding=JSON&keywords=iphone'
let expected_search_url = 'https://open.api.ebay.com/Shopping?appid=testID&callname=demoShoppingName&version=967&siteid=0&responseencoding=JSON&keywords=iphone';
let options = {
name: 'iphone',
operationName: 'demoShoppingName',
param: 'keywords',
clientID: 'testID',
baseUrl: 'open.api.ebay.com'
}
};
expect(buildURL.buildShoppingUrl(options)).to.be.equal(expected_search_url);
});

it('test Shopping url including selector', () => {
let expected_search_url = 'https://open.api.ebay.com/Shopping?appid=testID&callname=demoShoppingName&version=967&siteid=0&responseencoding=JSON&keywords=iphone&IncludeSelector=true'
let expected_search_url = 'https://open.api.ebay.com/Shopping?appid=testID&callname=demoShoppingName&version=967&siteid=0&responseencoding=JSON&keywords=iphone&IncludeSelector=true';
let options = {
name: 'iphone',
operationName: 'demoShoppingName',
param: 'keywords',
clientID: 'testID',
includeSelector: true,
baseUrl: 'open.api.ebay.com'
}
};
expect(buildURL.buildShoppingUrl(options)).to.be.equal(expected_search_url);
});
});
10 changes: 5 additions & 5 deletions test/findingApi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ describe('test ebay finding Api', () => {
let ebay = new eBay({
clientID: 'ClientId'
});
expect(() => { ebay.findItemsByCategory() }).to.throw('Category ID is null or invalid');
expect(() => { ebay.findItemsByCategory(); }).to.throw('Category ID is null or invalid');
});

it('test findCompletedItemswith required params', () => {
let ebay = new eBay({
clientID: 'ClientId'
});
expect(() => { ebay.findCompletedItems('') }).to.throw('Keyword or category ID are required.');
expect(() => { ebay.findCompletedItems(''); }).to.throw('Keyword or category ID are required.');
});
});

describe('test constructAdditionalParams', () => {
it('test constructAdditionalParams with required params', () => {
let expected_param = 'keywords=iphone&categoryId=111&sortOrder=PricePlusShippingLowest'
let expected_param = 'keywords=iphone&categoryId=111&sortOrder=PricePlusShippingLowest';
const options = {
keywords: 'iphone',
categoryId: '111',
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('test ebay finding Api', () => {
let ebay = new eBay({
clientID: 'ABCD'
});
nockFindingApi.get('/services/search/FindingService/v1?SECURITY-APPNAME=ABCD&OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&paginationInput.entriesPerPage=2&keywords=ipad&itemFilter(0).name=ExpeditedShippingType&itemFilter(0).value=OneDayShipping&outputSelector(0)=SellerInfo&GLOBAL-ID=EBAY-US')
nockFindingApi.get('/services/search/FindingService/v1?SECURITY-APPNAME=ABCD&OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&paginationInput.entriesPerPage=2&keywords=ipad&itemFilter(0).name=ExpeditedShippingType&itemFilter(0).value=OneDayShipping&outputSelector(0)=SellerInfo&outputSelector(1)=PictureURLLarge&GLOBAL-ID=EBAY-US')
.reply(200, { "findItemsAdvancedResponse": [{ "ack": ["Success"] }] });
return ebay.findItemsAdvanced({
entriesPerPage: 2,
Expand All @@ -100,5 +100,5 @@ describe('test ebay finding Api', () => {
console.log(error);
});
});
})
});
});

0 comments on commit 807f719

Please sign in to comment.