-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added shopping api * organize shopping url * updated shopping api * remove console log * fix test case
- Loading branch information
Showing
14 changed files
with
132 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
|
||
const Ebay = require('../src/index'); | ||
|
||
let ebay = new Ebay({ | ||
clientID: "--AppID/ClientID--", | ||
}); | ||
|
||
ebay.getAllCategories('1234').then((data) => { | ||
console.log(data); //extract data.CategoryArray | ||
}, (error) => { | ||
console.log(error); | ||
}); | ||
|
||
|
||
// Get User Profile | ||
// https://developer.ebay.com/devzone/shopping/docs/callref/GetUserProfile.html | ||
ebay.getUserDetails({ userId: "ajaykumapratha_0", details: true }).then((data) => { | ||
console.log(data); | ||
}, (error) => { | ||
console.log(error); | ||
}); | ||
|
||
|
||
// Get Item Status | ||
// https://developer.ebay.com/devzone/shopping/docs/callref/GetItemStatus.html | ||
ebay.getItemStatus(["153265274986", "153265274986"]).then((data) => { | ||
console.log(data); | ||
}, (error) => { | ||
console.log(error); | ||
}); | ||
|
||
// https://developer.ebay.com/devzone/shopping/docs/callref/GetShippingCosts.html | ||
ebay.getShippingCosts({ | ||
itemId: "153265274986", destCountryCode: 'US', | ||
destPostalCode: '95128' | ||
}).then((data) => { | ||
console.log(data); | ||
}, (error) => { | ||
console.log(error); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
'use strict'; | ||
const makeString = require('make-string'); | ||
const { makeRequest } = require('./request'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
'use strict'; | ||
let httpRequest = require("https"); | ||
const qs = require("querystring"); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
'use strict'; | ||
|
||
const { getRequest } = require('./request'); | ||
const urlObject = require('./buildURL'); | ||
const makeString = require('make-string'); | ||
|
||
const getAllCategories = function (categoryID) { | ||
this.options.name = categoryID ? categoryID : -1; | ||
this.options.operationName = "GetCategoryInfo"; | ||
this.options.param = "CategoryID"; | ||
const url = urlObject.buildShoppingUrl(this.options); | ||
return getRequest(url).then((data) => { | ||
return JSON.parse(data); | ||
}, console.error | ||
) | ||
}; | ||
|
||
const getUserDetails = function (input) { | ||
if (!input || typeof input !== 'object') throw new Error("Invalid input"); | ||
if (!input.userId) throw new Error("Invalid Input, UserId is required"); | ||
this.options.operationName = "GetUserProfile"; | ||
this.options.param = "UserID"; | ||
this.options.name = input.userId; | ||
this.options.includeSelector = input.details ? "Details" : null; | ||
const url = urlObject.buildShoppingUrl(this.options); | ||
return getRequest(url).then((data) => { | ||
return JSON.parse(data); | ||
}, console.error | ||
) | ||
}; | ||
|
||
const getItemStatus = function (itemIds) { | ||
if (!itemIds) throw new Error("User ID is null or invalid"); | ||
this.options.operationName = "GetItemStatus"; | ||
this.options.param = "ItemID"; | ||
this.options.name = makeString(itemIds, { braces: 'false', quotes: 'no' }); | ||
const url = urlObject.buildShoppingUrl(this.options); | ||
return getRequest(url).then((data) => { | ||
return JSON.parse(data); | ||
}, console.error | ||
) | ||
}; | ||
|
||
const getShippingCosts = function (input) { | ||
if (!input || typeof input !== 'object') throw new Error("Invalid input"); | ||
if (!input.itemId) throw new Error("Item ID is null or invalid"); | ||
this.options.operationName = "GetShippingCosts"; | ||
this.options.param = "ItemID"; | ||
this.options.name = input.itemId; | ||
const countryCodeParam = input.destCountryCode ? "&DestinationCountryCode=" + input.destCountryCode : ""; | ||
const postalCodeParam = input.destPostalCode ? "&DestinationPostalCode=" + input.destPostalCode : ''; | ||
const params = countryCodeParam + postalCodeParam; | ||
let url = urlObject.buildShoppingUrl(this.options); | ||
url = url + params; | ||
return getRequest(url).then((data) => { | ||
return JSON.parse(data); | ||
}, console.error | ||
) | ||
}; | ||
|
||
module.exports = { | ||
getAllCategories, | ||
getUserDetails, | ||
getItemStatus, | ||
getShippingCosts | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
'use strict'; | ||
const { makeRequest } = require('./request'); | ||
const { upperCase } = require('./utils'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters