From c8d412898a6a4fa89932aee25db90847faebc68b Mon Sep 17 00:00:00 2001 From: BL Date: Thu, 11 Oct 2018 14:53:55 +0530 Subject: [PATCH 1/4] Add Support for inventory API : getBulkInventoryItem and use async/await in javascript example --- examples/javaScript/buy/browse/getItem.js | 12 +++---- examples/javaScript/buy/browse/search.js | 12 +++---- .../commerce/taxonomy/getCategorySubtree.js | 13 ++++---- .../taxonomy/getCategorySuggestions.js | 13 ++++---- .../commerce/taxonomy/getCategoryTree.js | 12 +++---- .../taxonomy/getDefaultCategoryTreeId.js | 12 +++---- .../taxonomy/getItemAspectsForCategory.js | 15 ++++----- .../inventory/createOrReplaceInventoryItem.js | 15 ++++----- .../sell/inventory/getBulkInventoryItem.js | 32 +++++++++++++++++++ .../sell/inventory/getInventoryItem.js | 13 ++++---- .../sell/inventory/getInventoryItems.js | 12 +++---- lib/resources/sell/inventory.js | 6 ++++ 12 files changed, 100 insertions(+), 67 deletions(-) create mode 100644 examples/javaScript/sell/inventory/getBulkInventoryItem.js diff --git a/examples/javaScript/buy/browse/getItem.js b/examples/javaScript/buy/browse/getItem.js index be0ad5d..1bb43b1 100644 --- a/examples/javaScript/buy/browse/getItem.js +++ b/examples/javaScript/buy/browse/getItem.js @@ -18,13 +18,13 @@ var browseRequest = async function () { } var itemId = 'v1|110329773707|410089528845'; - eBay.browse.getItem(itemId, function (error, response) { - if (error) { - console.log('error ', error); - return; - } + try { + var response = await eBay.browse.getItem(itemId); console.log('response', response); - }); + } catch (error) { + console.log('error', error); + return; + } }; browseRequest(); diff --git a/examples/javaScript/buy/browse/search.js b/examples/javaScript/buy/browse/search.js index d8bd412..a731239 100644 --- a/examples/javaScript/buy/browse/search.js +++ b/examples/javaScript/buy/browse/search.js @@ -21,13 +21,13 @@ var browseRequest = async function () { gtin: '010942122258', limit: '1' }; - eBay.browse.search(data, function (error, response) { - if (error) { - console.log('error ', error); - return; - } + try { + var response = await eBay.browse.search(data); console.log('response', response); - }); + } catch (error) { + console.log('error ', error); + return; + } }; browseRequest(); diff --git a/examples/javaScript/commerce/taxonomy/getCategorySubtree.js b/examples/javaScript/commerce/taxonomy/getCategorySubtree.js index 4023b4f..4551960 100644 --- a/examples/javaScript/commerce/taxonomy/getCategorySubtree.js +++ b/examples/javaScript/commerce/taxonomy/getCategorySubtree.js @@ -21,14 +21,13 @@ var categoryRequest = async function () { var data = { category_id: '179623' }; - - eBay.taxonomy.getCategorySubtree(categoryTreeId, data , function (error, response) { - if (error) { - console.log('error ', error); - return; - } + try { + var response = await eBay.taxonomy.getCategorySubtree(categoryTreeId, data); console.log('response', response); - }); + } catch (error) { + console.log('error ', error); + return; + } }; categoryRequest(); diff --git a/examples/javaScript/commerce/taxonomy/getCategorySuggestions.js b/examples/javaScript/commerce/taxonomy/getCategorySuggestions.js index d4131af..990972c 100644 --- a/examples/javaScript/commerce/taxonomy/getCategorySuggestions.js +++ b/examples/javaScript/commerce/taxonomy/getCategorySuggestions.js @@ -18,17 +18,16 @@ var categoryRequest = async function () { } var categoryTreeId = 203; - var data = { 'q': 'abc' }; - eBay.taxonomy.getCategorySuggestions(categoryTreeId, data, function (error, response) { - if (error) { - console.log('error ', error); - return; - } + try { + var response = await eBay.taxonomy.getCategorySuggestions(categoryTreeId, data); console.log('response', response); - }); + } catch (error) { + console.log('error ', error); + return; + } }; categoryRequest(); diff --git a/examples/javaScript/commerce/taxonomy/getCategoryTree.js b/examples/javaScript/commerce/taxonomy/getCategoryTree.js index 815515a..3bdf875 100644 --- a/examples/javaScript/commerce/taxonomy/getCategoryTree.js +++ b/examples/javaScript/commerce/taxonomy/getCategoryTree.js @@ -19,13 +19,13 @@ var categoryRequest = async function () { } var categoryTreeId = 203; - eBay.taxonomy.getCategoryTree(categoryTreeId, function (error, response) { - if (error) { - console.log('error ', error); - return; - } + try { + var response = await eBay.taxonomy.getCategoryTree(categoryTreeId); console.log('response', response); - }); + } catch (error) { + console.log('error ', error); + return; + } }; categoryRequest(); diff --git a/examples/javaScript/commerce/taxonomy/getDefaultCategoryTreeId.js b/examples/javaScript/commerce/taxonomy/getDefaultCategoryTreeId.js index 3b1fbbf..2bcd3e9 100644 --- a/examples/javaScript/commerce/taxonomy/getDefaultCategoryTreeId.js +++ b/examples/javaScript/commerce/taxonomy/getDefaultCategoryTreeId.js @@ -20,13 +20,13 @@ var categoryRequest = async function () { var data = { marketplace_id: 'EBAY_IN' }; - eBay.taxonomy.getDefaultCategoryTreeId(data, function (error, response) { - if (error) { - console.log('error ', error); - return; - } + try { + var response = await eBay.taxonomy.getDefaultCategoryTreeId(data); console.log('response', response); - }); + } catch (error) { + console.log('error ', error); + return; + } }; categoryRequest(); diff --git a/examples/javaScript/commerce/taxonomy/getItemAspectsForCategory.js b/examples/javaScript/commerce/taxonomy/getItemAspectsForCategory.js index a5b7827..87bf98e 100644 --- a/examples/javaScript/commerce/taxonomy/getItemAspectsForCategory.js +++ b/examples/javaScript/commerce/taxonomy/getItemAspectsForCategory.js @@ -19,16 +19,15 @@ var categoryRequest = async function () { var categoryTreeId = 203; var data = { - category_id: '179623' + category_id: '931' }; - - eBay.taxonomy.getItemAspectsForCategory(categoryTreeId, data, function (error, response) { - if (error) { - console.log('error ', error); - return; - } + try { + var response = await eBay.taxonomy.getItemAspectsForCategory(categoryTreeId, data); console.log('response', response); - }); + } catch (error) { + console.log('error ', error); + return; + } }; categoryRequest(); diff --git a/examples/javaScript/sell/inventory/createOrReplaceInventoryItem.js b/examples/javaScript/sell/inventory/createOrReplaceInventoryItem.js index 0e2e852..22a7875 100644 --- a/examples/javaScript/sell/inventory/createOrReplaceInventoryItem.js +++ b/examples/javaScript/sell/inventory/createOrReplaceInventoryItem.js @@ -6,7 +6,7 @@ var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET'; var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret); var utils = require('../../../javaScript/utils'); -var inventoryRequest = function () { +var inventoryRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); @@ -38,15 +38,14 @@ var inventoryRequest = function () { ] } }; - var sku = '32984729384730'; - eBay.inventory.createOrReplaceInventoryItem(sku, data, function (error, response) { - if (error) { - console.log('error ', error); - return; - } + try { + var response = await eBay.inventory.createOrReplaceInventoryItem(sku, data); console.log('response', response); - }); + } catch (error) { + console.log('error ', error); + return; + } }; inventoryRequest(); diff --git a/examples/javaScript/sell/inventory/getBulkInventoryItem.js b/examples/javaScript/sell/inventory/getBulkInventoryItem.js new file mode 100644 index 0000000..33505b8 --- /dev/null +++ b/examples/javaScript/sell/inventory/getBulkInventoryItem.js @@ -0,0 +1,32 @@ +'use strict'; + +var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY'; +var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET'; + +var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret); +var utils = require('../../../javaScript/utils'); + +var inventoryRequest = async function () { + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + + var data = { + 'requests': [ + { + 'sku': '13465446' + }, + { + 'sku': '132165496' + } + ] + }; + try { + var response = await eBay.inventory.bulkGetInventoryItem(data); + console.log('response ', response); + } catch (error) { + console.log('error ', error); + return; + } +}; + +inventoryRequest(); diff --git a/examples/javaScript/sell/inventory/getInventoryItem.js b/examples/javaScript/sell/inventory/getInventoryItem.js index a61f335..d8ae800 100644 --- a/examples/javaScript/sell/inventory/getInventoryItem.js +++ b/examples/javaScript/sell/inventory/getInventoryItem.js @@ -11,13 +11,12 @@ var inventoryRequest = async function () { eBay.setUserToken(userToken); var sku = '32984729384729'; - eBay.inventory.getInventoryItem(sku, function (error, response) { - if (error) { - console.log('error ', error); - return; - } - console.log('response', response); - }); + try { + var response = await eBay.inventory.getInventoryItem(sku); + console.log('response ', response); + } catch (error) { + console.log('error ', error); + } }; inventoryRequest(); diff --git a/examples/javaScript/sell/inventory/getInventoryItems.js b/examples/javaScript/sell/inventory/getInventoryItems.js index 56048dd..b03131a 100644 --- a/examples/javaScript/sell/inventory/getInventoryItems.js +++ b/examples/javaScript/sell/inventory/getInventoryItems.js @@ -13,13 +13,13 @@ var inventoryRequest = async function () { var data = { limit: '10' }; - eBay.inventory.getInventoryItems(data, function (error, response) { - if (error) { - console.log('error ', error); - return; - } + try { + var response = await eBay.inventory.getInventoryItems(data); console.log('response', response); - }); + } catch (error) { + console.log('error ', error); + return; + } }; inventoryRequest(); diff --git a/lib/resources/sell/inventory.js b/lib/resources/sell/inventory.js index a1f4a89..7605331 100644 --- a/lib/resources/sell/inventory.js +++ b/lib/resources/sell/inventory.js @@ -25,6 +25,12 @@ module.exports = eBayResource.extend({ path: 'sell/inventory/v1/inventory_item', urlParams: ['sku'], required: ['sku'] + }), + bulkGetInventoryItem: eBayMethod({ + authorization: 'User', + contentType: 'application/json', + method: 'POST', + path: 'sell/inventory/v1/bulk_get_inventory_item' }) }); From 89f02610acb2808af642f0dcd44dab0177959604 Mon Sep 17 00:00:00 2001 From: BL Date: Thu, 11 Oct 2018 15:20:43 +0530 Subject: [PATCH 2/4] remove unnecessary space --- examples/javaScript/application/oauthToken.js | 1 - examples/javaScript/commerce/catalog/createChangeRequest.js | 2 -- examples/javaScript/commerce/catalog/getChangeRequest.js | 2 -- examples/javaScript/commerce/catalog/getChangeRequests.js | 2 -- examples/javaScript/commerce/catalog/getProduct.js | 2 -- examples/javaScript/commerce/catalog/getProductMetadata.js | 2 -- .../commerce/catalog/getProductMetadataForCategories.js | 2 -- examples/javaScript/commerce/catalog/search.js | 2 -- examples/javaScript/commerce/catalog/searchByCategory.js | 1 - examples/javaScript/commerce/taxonomy/getCategoryTree.js | 1 - examples/javaScript/sell/account/createOrReplaceSalesTax.js | 1 - examples/javaScript/sell/account/deleteSalesTax.js | 2 -- examples/javaScript/sell/account/getSalesTax.js | 1 - examples/javaScript/sell/account/getSalesTaxes.js | 1 - .../javaScript/sell/inventory/createOrReplaceInventoryItem.js | 2 -- examples/javaScript/sell/inventory/getBulkInventoryItem.js | 1 - examples/javaScript/sell/inventory/getInventoryItem.js | 1 - examples/javaScript/sell/inventory/getInventoryItems.js | 1 - examples/javaScript/sell/location/createInventoryLocation.js | 2 -- examples/javaScript/sell/location/deleteInventoryLocation.js | 1 - examples/javaScript/sell/location/disableInventoryLocation.js | 1 - examples/javaScript/sell/location/enableInventoryLocation.js | 1 - examples/javaScript/sell/location/getInventoryLocation.js | 1 - examples/javaScript/sell/location/getInventoryLocations.js | 1 - examples/javaScript/sell/location/updateInventoryLocation.js | 2 -- examples/javaScript/sell/offer/createOffer.js | 2 -- examples/javaScript/sell/offer/deleteOffer.js | 1 - examples/javaScript/sell/offer/getListingFees.js | 2 -- examples/javaScript/sell/offer/getOffer.js | 1 - examples/javaScript/sell/offer/getOffersBySku.js | 1 - examples/javaScript/sell/offer/publishOffer.js | 1 - examples/javaScript/sell/offer/updateOffer.js | 2 -- examples/javaScript/sell/offer/withdrawOffer.js | 1 - 33 files changed, 47 deletions(-) diff --git a/examples/javaScript/application/oauthToken.js b/examples/javaScript/application/oauthToken.js index e3bffea..0b85fbe 100644 --- a/examples/javaScript/application/oauthToken.js +++ b/examples/javaScript/application/oauthToken.js @@ -6,7 +6,6 @@ var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET'; var eBay = require('../../../lib/eBay-node-client')(clientId, clientSecret); var applicationRequest = async function () { - try { var token = await eBay.application.getOAuthToken({ grant_type: 'client_credentials', diff --git a/examples/javaScript/commerce/catalog/createChangeRequest.js b/examples/javaScript/commerce/catalog/createChangeRequest.js index dfff0c1..c5da097 100644 --- a/examples/javaScript/commerce/catalog/createChangeRequest.js +++ b/examples/javaScript/commerce/catalog/createChangeRequest.js @@ -8,10 +8,8 @@ var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret); var utils = require('../../../javaScript/utils'); var catalogRequest = async function () { - var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { 'changeRequestType': 'PRODUCT_CREATION', 'reasonForChangeRequest': 'Request to add new product', diff --git a/examples/javaScript/commerce/catalog/getChangeRequest.js b/examples/javaScript/commerce/catalog/getChangeRequest.js index 07353d0..0d39314 100644 --- a/examples/javaScript/commerce/catalog/getChangeRequest.js +++ b/examples/javaScript/commerce/catalog/getChangeRequest.js @@ -8,10 +8,8 @@ var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret); var utils = require('../../../javaScript/utils'); var catalogRequest = async function () { - var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var changeRequestId = '1010101'; try { var response = await eBay.catalog.getChangeRequest(changeRequestId); diff --git a/examples/javaScript/commerce/catalog/getChangeRequests.js b/examples/javaScript/commerce/catalog/getChangeRequests.js index 9d538ea..d95777b 100644 --- a/examples/javaScript/commerce/catalog/getChangeRequests.js +++ b/examples/javaScript/commerce/catalog/getChangeRequests.js @@ -8,10 +8,8 @@ var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret); var utils = require('../../../javaScript/utils'); var catalogRequest = async function () { - var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - try { var response = await eBay.catalog.getChangeRequests(); console.log('response', response); diff --git a/examples/javaScript/commerce/catalog/getProduct.js b/examples/javaScript/commerce/catalog/getProduct.js index efdc0f3..3b6ceab 100644 --- a/examples/javaScript/commerce/catalog/getProduct.js +++ b/examples/javaScript/commerce/catalog/getProduct.js @@ -8,10 +8,8 @@ var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret); var utils = require('../../../javaScript/utils'); var catalogRequest = async function () { - var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var epId = '1300568638'; try { var response = await eBay.catalog.getProduct(epId); diff --git a/examples/javaScript/commerce/catalog/getProductMetadata.js b/examples/javaScript/commerce/catalog/getProductMetadata.js index 37dcef8..e4a0f24 100644 --- a/examples/javaScript/commerce/catalog/getProductMetadata.js +++ b/examples/javaScript/commerce/catalog/getProductMetadata.js @@ -8,10 +8,8 @@ var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret); var utils = require('../../../javaScript/utils'); var catalogRequest = async function () { - var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { 'epid': '241827861', 'primary_category_id': '9355', diff --git a/examples/javaScript/commerce/catalog/getProductMetadataForCategories.js b/examples/javaScript/commerce/catalog/getProductMetadataForCategories.js index 15bd7cf..768e1b6 100644 --- a/examples/javaScript/commerce/catalog/getProductMetadataForCategories.js +++ b/examples/javaScript/commerce/catalog/getProductMetadataForCategories.js @@ -8,10 +8,8 @@ var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret); var utils = require('../../../javaScript/utils'); var catalogRequest = async function () { - var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { 'primary_category_id': '500', 'other_applicable_category_ids': '34,36,63' diff --git a/examples/javaScript/commerce/catalog/search.js b/examples/javaScript/commerce/catalog/search.js index 00009dc..ac696cb 100644 --- a/examples/javaScript/commerce/catalog/search.js +++ b/examples/javaScript/commerce/catalog/search.js @@ -8,10 +8,8 @@ var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret); var utils = require('../../../javaScript/utils'); var catalogRequest = async function () { - var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { gtin: '010942122258' }; diff --git a/examples/javaScript/commerce/catalog/searchByCategory.js b/examples/javaScript/commerce/catalog/searchByCategory.js index 92038d2..d55ceea 100644 --- a/examples/javaScript/commerce/catalog/searchByCategory.js +++ b/examples/javaScript/commerce/catalog/searchByCategory.js @@ -10,7 +10,6 @@ var utils = require('../../../javaScript/utils'); var catalogRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { // Leaf Category Name q: 'Video Cables', diff --git a/examples/javaScript/commerce/taxonomy/getCategoryTree.js b/examples/javaScript/commerce/taxonomy/getCategoryTree.js index 3bdf875..4d6d4c6 100644 --- a/examples/javaScript/commerce/taxonomy/getCategoryTree.js +++ b/examples/javaScript/commerce/taxonomy/getCategoryTree.js @@ -6,7 +6,6 @@ var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET'; var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret); var categoryRequest = async function () { - try { var token = await eBay.application.getOAuthToken({ grant_type: 'client_credentials', diff --git a/examples/javaScript/sell/account/createOrReplaceSalesTax.js b/examples/javaScript/sell/account/createOrReplaceSalesTax.js index 4fb0141..39b6ef7 100644 --- a/examples/javaScript/sell/account/createOrReplaceSalesTax.js +++ b/examples/javaScript/sell/account/createOrReplaceSalesTax.js @@ -10,7 +10,6 @@ var utils = require('../../../javaScript/utils'); var accountRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var countryCode = 'US'; var jurisdictionId = 'IN'; var data = { diff --git a/examples/javaScript/sell/account/deleteSalesTax.js b/examples/javaScript/sell/account/deleteSalesTax.js index 20182c7..b2b3a8a 100644 --- a/examples/javaScript/sell/account/deleteSalesTax.js +++ b/examples/javaScript/sell/account/deleteSalesTax.js @@ -9,8 +9,6 @@ var utils = require('../../../javaScript/utils'); var accountRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - - var countryCode = 'US'; var jurisdictionId = 'IN'; try { diff --git a/examples/javaScript/sell/account/getSalesTax.js b/examples/javaScript/sell/account/getSalesTax.js index 2702c8f..26ab49b 100644 --- a/examples/javaScript/sell/account/getSalesTax.js +++ b/examples/javaScript/sell/account/getSalesTax.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var accountRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var countryCode = 'US'; var jurisdictionId = 'IN'; try { diff --git a/examples/javaScript/sell/account/getSalesTaxes.js b/examples/javaScript/sell/account/getSalesTaxes.js index 7c45506..4d1fbb3 100644 --- a/examples/javaScript/sell/account/getSalesTaxes.js +++ b/examples/javaScript/sell/account/getSalesTaxes.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var accountRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { country_code: 'US' }; diff --git a/examples/javaScript/sell/inventory/createOrReplaceInventoryItem.js b/examples/javaScript/sell/inventory/createOrReplaceInventoryItem.js index 22a7875..13231ae 100644 --- a/examples/javaScript/sell/inventory/createOrReplaceInventoryItem.js +++ b/examples/javaScript/sell/inventory/createOrReplaceInventoryItem.js @@ -7,10 +7,8 @@ var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret); var utils = require('../../../javaScript/utils'); var inventoryRequest = async function () { - var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { 'availability': { 'shipToLocationAvailability': { diff --git a/examples/javaScript/sell/inventory/getBulkInventoryItem.js b/examples/javaScript/sell/inventory/getBulkInventoryItem.js index 33505b8..e457bbe 100644 --- a/examples/javaScript/sell/inventory/getBulkInventoryItem.js +++ b/examples/javaScript/sell/inventory/getBulkInventoryItem.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var inventoryRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { 'requests': [ { diff --git a/examples/javaScript/sell/inventory/getInventoryItem.js b/examples/javaScript/sell/inventory/getInventoryItem.js index d8ae800..8b8835a 100644 --- a/examples/javaScript/sell/inventory/getInventoryItem.js +++ b/examples/javaScript/sell/inventory/getInventoryItem.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var inventoryRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var sku = '32984729384729'; try { var response = await eBay.inventory.getInventoryItem(sku); diff --git a/examples/javaScript/sell/inventory/getInventoryItems.js b/examples/javaScript/sell/inventory/getInventoryItems.js index b03131a..f0875a8 100644 --- a/examples/javaScript/sell/inventory/getInventoryItems.js +++ b/examples/javaScript/sell/inventory/getInventoryItems.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var inventoryRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { limit: '10' }; diff --git a/examples/javaScript/sell/location/createInventoryLocation.js b/examples/javaScript/sell/location/createInventoryLocation.js index 2a74341..e915c4f 100644 --- a/examples/javaScript/sell/location/createInventoryLocation.js +++ b/examples/javaScript/sell/location/createInventoryLocation.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { 'location': { 'address': { @@ -63,7 +62,6 @@ var offerRequest = async function () { } ] }; - var customLocationIdentifier = 'LOC1014'; try { var response = await eBay.location.createInventoryLocation(customLocationIdentifier, data); diff --git a/examples/javaScript/sell/location/deleteInventoryLocation.js b/examples/javaScript/sell/location/deleteInventoryLocation.js index fa619f7..42563a8 100644 --- a/examples/javaScript/sell/location/deleteInventoryLocation.js +++ b/examples/javaScript/sell/location/deleteInventoryLocation.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var customLocationIdentifier = 'LOC1014'; try { var response = await eBay.location.deleteInventoryLocation(customLocationIdentifier); diff --git a/examples/javaScript/sell/location/disableInventoryLocation.js b/examples/javaScript/sell/location/disableInventoryLocation.js index c422c9d..dfa5a6c 100644 --- a/examples/javaScript/sell/location/disableInventoryLocation.js +++ b/examples/javaScript/sell/location/disableInventoryLocation.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var customLocationIdentifier = 'LOC1014'; try { var response = await eBay.location.disableInventoryLocation(customLocationIdentifier); diff --git a/examples/javaScript/sell/location/enableInventoryLocation.js b/examples/javaScript/sell/location/enableInventoryLocation.js index 72cbf13..8e843b3 100644 --- a/examples/javaScript/sell/location/enableInventoryLocation.js +++ b/examples/javaScript/sell/location/enableInventoryLocation.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var customLocationIdentifier = 'LOC1014'; try { var response = await eBay.location.enableInventoryLocation(customLocationIdentifier); diff --git a/examples/javaScript/sell/location/getInventoryLocation.js b/examples/javaScript/sell/location/getInventoryLocation.js index d4d875a..7fe11ed 100644 --- a/examples/javaScript/sell/location/getInventoryLocation.js +++ b/examples/javaScript/sell/location/getInventoryLocation.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var customLocationIdentifier = 'LOC1014'; try { var response = await eBay.location.getInventoryLocation(customLocationIdentifier); diff --git a/examples/javaScript/sell/location/getInventoryLocations.js b/examples/javaScript/sell/location/getInventoryLocations.js index 5e54bd3..17586c8 100644 --- a/examples/javaScript/sell/location/getInventoryLocations.js +++ b/examples/javaScript/sell/location/getInventoryLocations.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { limit: 10, offset: 0 diff --git a/examples/javaScript/sell/location/updateInventoryLocation.js b/examples/javaScript/sell/location/updateInventoryLocation.js index ed8a10f..bae2d48 100644 --- a/examples/javaScript/sell/location/updateInventoryLocation.js +++ b/examples/javaScript/sell/location/updateInventoryLocation.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { 'name': 'My Store #1', 'location': { @@ -28,7 +27,6 @@ var offerRequest = async function () { ], 'merchantLocationKey': 'store-1' }; - var customLocationIdentifier = 'LOC1014'; try { var response = await eBay.location.updateInventoryLocation(customLocationIdentifier, data); diff --git a/examples/javaScript/sell/offer/createOffer.js b/examples/javaScript/sell/offer/createOffer.js index e1ccc06..eeddb72 100644 --- a/examples/javaScript/sell/offer/createOffer.js +++ b/examples/javaScript/sell/offer/createOffer.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { 'sku': '32984729384730', 'marketplaceId': 'EBAY_US', @@ -36,7 +35,6 @@ var offerRequest = async function () { 'thirdPartyTaxCategory': 'Electronics' } }; - try { var response = await eBay.offer.createOffer(data); console.log('response', response); diff --git a/examples/javaScript/sell/offer/deleteOffer.js b/examples/javaScript/sell/offer/deleteOffer.js index f66fff5..a44c3fc 100644 --- a/examples/javaScript/sell/offer/deleteOffer.js +++ b/examples/javaScript/sell/offer/deleteOffer.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var offerId = '6360335010'; try { var response = await eBay.offer.deleteOffer(offerId); diff --git a/examples/javaScript/sell/offer/getListingFees.js b/examples/javaScript/sell/offer/getListingFees.js index 717ec00..e66eed1 100644 --- a/examples/javaScript/sell/offer/getListingFees.js +++ b/examples/javaScript/sell/offer/getListingFees.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { offers: [ { @@ -17,7 +16,6 @@ var offerRequest = async function () { } ] }; - try { var response = await eBay.offer.getListingFees(data); console.log('response', response); diff --git a/examples/javaScript/sell/offer/getOffer.js b/examples/javaScript/sell/offer/getOffer.js index 1a8c4c5..8ed8f18 100644 --- a/examples/javaScript/sell/offer/getOffer.js +++ b/examples/javaScript/sell/offer/getOffer.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var offerId = '6360335010'; try { var response = await eBay.offer.getOffer(offerId); diff --git a/examples/javaScript/sell/offer/getOffersBySku.js b/examples/javaScript/sell/offer/getOffersBySku.js index e37b277..fb6f0cf 100644 --- a/examples/javaScript/sell/offer/getOffersBySku.js +++ b/examples/javaScript/sell/offer/getOffersBySku.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { sku: '32984729384730' }; diff --git a/examples/javaScript/sell/offer/publishOffer.js b/examples/javaScript/sell/offer/publishOffer.js index 2f1aac3..7ef3a1f 100644 --- a/examples/javaScript/sell/offer/publishOffer.js +++ b/examples/javaScript/sell/offer/publishOffer.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var offerId = '6360337010'; try { var response = await eBay.offer.publishOffer(offerId); diff --git a/examples/javaScript/sell/offer/updateOffer.js b/examples/javaScript/sell/offer/updateOffer.js index 4ebb73f..62212cc 100644 --- a/examples/javaScript/sell/offer/updateOffer.js +++ b/examples/javaScript/sell/offer/updateOffer.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var data = { 'availableQuantity': 60, 'categoryId': '30120', @@ -27,7 +26,6 @@ var offerRequest = async function () { }, 'quantityLimitPerBuyer': 3 }; - var offerId = '6360335010'; try { var response = await eBay.offer.updateOffer(offerId, data); diff --git a/examples/javaScript/sell/offer/withdrawOffer.js b/examples/javaScript/sell/offer/withdrawOffer.js index 4a3f510..e2510ac 100644 --- a/examples/javaScript/sell/offer/withdrawOffer.js +++ b/examples/javaScript/sell/offer/withdrawOffer.js @@ -9,7 +9,6 @@ var utils = require('../../../javaScript/utils'); var offerRequest = async function () { var userToken = utils.USER_TOKEN; eBay.setUserToken(userToken); - var offerId = '6360335010'; try { var response = await eBay.offer.withdrawOffer(offerId); From bb02d84ef1dfb18eca157d02404769bbe4e47e75 Mon Sep 17 00:00:00 2001 From: BL Date: Thu, 11 Oct 2018 16:22:40 +0530 Subject: [PATCH 3/4] Add example in README.md file --- CHANGELOG.md | 4 + README.md | 834 +++++++++++++++++++++++++++++++++++++++++++++++++++ index.d.ts | 2 + package.json | 2 +- 4 files changed, 841 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6de5c9..71236dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +0.0.6 October 11, 2018 + - Add Support for Inventory API : getBulkInventoryItem + - Add examples in README.md + 0.0.5 October 3, 2018 - Add Support for Offer API : createOffer, updateOffer,getOffer, getOffers, publishOffer, deleteOffer, getListingFees, withdrawOffer - Add Support for Seller Location API : createInventoryLocation, updateInventoryLocation, enableInventoryLocation, disableInventoryLocation, getInventoryLocation, deleteInventoryLocation, getInventoryLocations diff --git a/README.md b/README.md index c8d487a..5a1d5fc 100644 --- a/README.md +++ b/README.md @@ -75,3 +75,837 @@ eBay.setApiKey('YOUR_KEY', 'YOUR_SECRET'); ``` Originally by [Bhushankumar Lilapara](https://github.com/bhushankumarl) (bhushankumar.lilapara@gmail.com). +``` + +### Application +#### Oauth Token +``` + try { + var token = await eBay.application.getOAuthToken({ + grant_type: 'client_credentials', + scope: 'https://api.ebay.com/oauth/api_scope' + }); + console.log('token.access_token ', token.access_token); + eBay.setToken(token.access_token); + } catch (error) { + console.log('error ', error); + } + +``` +### Browse +#### Get Item +``` + try { + var token = await eBay.application.getOAuthToken({ + grant_type: 'client_credentials', + scope: 'https://api.ebay.com/oauth/api_scope' + }); + eBay.setToken(token.access_token); + } catch (error) { + console.log('error ', error); + return; + } + + var itemId = 'v1|110329773707|410089528845'; + try { + var response = await eBay.browse.getItem(itemId); + console.log('response', response); + } catch (error) { + console.log('error', error); + return; + } + +``` +#### Search +``` + try { + var token = await eBay.application.getOAuthToken({ + grant_type: 'client_credentials', + scope: 'https://api.ebay.com/oauth/api_scope' + }); + eBay.setToken(token.access_token); + } catch (error) { + console.log('error ', error); + return; + } + + var data = { + gtin: '010942122258', + limit: '1' + }; + try { + var response = await eBay.browse.search(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +### Catalog +#### Create Change Request +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + 'changeRequestType': 'PRODUCT_CREATION', + 'reasonForChangeRequest': 'Request to add new product', + 'suggestedProduct': { + 'title': 'Apple iPhone', + 'description': 'This Space Grey iPhone comes with 256GB of storage, and can be used on any carrier network in the US.', + 'primaryCategoryId': '178114', + 'aspects': [ + { + 'name': 'Model', + 'values': ['iPhone 20'] + } + ], + 'imageUrl': 'https://i.ebayimg.com/images/g/HFAAAOSw9W5bWgcQ/s-l1600.jpg?set_id=89040003C1C1', + 'brand': 'Apple', + 'upc': ['0745577656433'], + 'mpn': ['MD295LL/A'] + } + }; + try { + var response = await eBay.catalog.createChangeRequest(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Change Request +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var changeRequestId = '1010101'; + try { + var response = await eBay.catalog.getChangeRequest(changeRequestId); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Change Requests +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + try { + var response = await eBay.catalog.getChangeRequests(); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Product +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var epId = '1300568638'; + try { + var response = await eBay.catalog.getProduct(epId); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Product Metadata +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + 'epid': '241827861', + 'primary_category_id': '9355', + 'other_applicable_category_ids': '15032,42428' + }; + try { + var response = await eBay.catalog.getProductMetadata(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Product Metadata For Categories +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + 'primary_category_id': '500', + 'other_applicable_category_ids': '34,36,63' + }; + try { + var response = await eBay.catalog.getProductMetadataForCategories(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Search +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + gtin: '010942122258' + }; + try { + var response = await eBay.catalog.search(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Search By Category +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + // Leaf Category Name + q: 'Video Cables', + // Leaf Category Id + category_ids: '67859' + }; + try { + var response = await eBay.catalog.search(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +### Taxonomy +#### Get Category Subtree +``` + try { + var token = await eBay.application.getOAuthToken({ + grant_type: 'client_credentials', + scope: 'https://api.ebay.com/oauth/api_scope' + }); + eBay.setToken(token.access_token); + } catch (error) { + console.log('error ', error); + return; + } + + var categoryTreeId = 203; + var data = { + category_id: '179623' + }; + try { + var response = await eBay.taxonomy.getCategorySubtree(categoryTreeId, data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Category Suggestions +``` + try { + var token = await eBay.application.getOAuthToken({ + grant_type: 'client_credentials', + scope: 'https://api.ebay.com/oauth/api_scope' + }); + eBay.setToken(token.access_token); + } catch (error) { + console.log('error ', error); + return; + } + + var categoryTreeId = 203; + var data = { + 'q': 'abc' + }; + try { + var response = await eBay.taxonomy.getCategorySuggestions(categoryTreeId, data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Category Tree +``` + try { + var token = await eBay.application.getOAuthToken({ + grant_type: 'client_credentials', + scope: 'https://api.ebay.com/oauth/api_scope' + }); + eBay.setToken(token.access_token); + } catch (error) { + console.log('error ', error); + return; + } + + var categoryTreeId = 203; + try { + var response = await eBay.taxonomy.getCategoryTree(categoryTreeId); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Default Category Tree Id +``` + try { + var token = await eBay.application.getOAuthToken({ + grant_type: 'client_credentials', + scope: 'https://api.ebay.com/oauth/api_scope' + }); + eBay.setToken(token.access_token); + } catch (error) { + console.log('error ', error); + return; + } + + var data = { + marketplace_id: 'EBAY_IN' + }; + try { + var response = await eBay.taxonomy.getDefaultCategoryTreeId(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Item Aspects For Category +``` + try { + var token = await eBay.application.getOAuthToken({ + grant_type: 'client_credentials', + scope: 'https://api.ebay.com/oauth/api_scope' + }); + eBay.setToken(token.access_token); + } catch (error) { + console.log('error ', error); + return; + } + + var categoryTreeId = 203; + var data = { + category_id: '931' + }; + try { + var response = await eBay.taxonomy.getItemAspectsForCategory(categoryTreeId, data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +### Account +#### Create Or Replace Sales Tax +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var countryCode = 'US'; + var jurisdictionId = 'IN'; + var data = { + 'salesTaxPercentage': 7.0, + 'shippingAndHandlingTaxed': false + }; + try { + var response = await eBay.account.getSalesTax(countryCode, jurisdictionId, data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Delete Sales Tax +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var countryCode = 'US'; + var jurisdictionId = 'IN'; + try { + var response = await eBay.account.deleteSalesTax(countryCode, jurisdictionId); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Sales Tax +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var countryCode = 'US'; + var jurisdictionId = 'IN'; + try { + var response = await eBay.account.getSalesTax(countryCode, jurisdictionId); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Sales Taxes +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + country_code: 'US' + }; + try { + var response = await eBay.account.getSalesTaxes(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +### Inventory +#### Create Or Replace Inventory Item +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + 'availability': { + 'shipToLocationAvailability': { + 'quantity': 50 + } + }, + 'condition': 'NEW', + 'product': { + 'title': 'GoPro Hero4 Helmet Cam', + 'description': 'New GoPro Hero4 Helmet Cam. Unopened box.', + 'aspects': { + 'Brand': ['GoPro'], + 'Type': ['Helmet/Action'], + 'Storage Type': ['Removable'], + 'Recording Definition': ['High Definition'], + 'Media Format': ['Flash Drive (SSD)'], + 'Optical Zoom': ['10x'] + }, + 'brand': 'GoPro', + 'mpn': 'CHDHX-401', + 'imageUrls': [ + 'http://i.ebayimg.com/images/i/182196556219-0-1/s-l1000.jpg', + 'http://i.ebayimg.com/images/i/182196556219-0-1/s-l1001.jpg', + 'http://i.ebayimg.com/images/i/182196556219-0-1/s-l1002.jpg' + ] + } + }; + var sku = '32984729384730'; + try { + var response = await eBay.inventory.createOrReplaceInventoryItem(sku, data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Bulk Inventory Item +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + 'requests': [ + { + 'sku': '13465446' + }, + { + 'sku': '132165496' + } + ] + }; + try { + var response = await eBay.inventory.bulkGetInventoryItem(data); + console.log('response ', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Inventory Item +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var sku = '32984729384729'; + try { + var response = await eBay.inventory.getInventoryItem(sku); + console.log('response ', response); + } catch (error) { + console.log('error ', error); + } + +``` +#### Get Inventory Items +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + limit: '10' + }; + try { + var response = await eBay.inventory.getInventoryItems(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +### Location +#### Create Inventory Location +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + 'location': { + 'address': { + 'addressLine1': '2055 Hamilton Ave', + 'addressLine2': 'Building 3', + 'city': 'San Jose', + 'stateOrProvince': 'CA', + 'postalCode': '95125', + 'country': 'US' + } + }, + 'locationInstructions': 'Open for drop-off only.', + 'name': 'Warehouse-1', + 'merchantLocationStatus': 'ENABLED', + 'locationTypes': [ + 'WAREHOUSE' + ], + 'operatingHours': [ + { + 'dayOfWeek': 'MONDAY', + 'intervals': [ + { + 'open': '09:00:00', + 'close': '12:00:00' + }, + { + 'open': '13:00:00', + 'close': '18:00:00' + } + ] + }, + { + 'dayOfWeek': 'TUESDAY', + 'intervals': [ + { + 'open': '09:00:00', + 'close': '15:00:00' + } + ] + } + ], + 'specialHours': [ + { + 'date': '2016-10-19T00:09:00.000Z', + 'intervals': [ + { + 'open': '09:00:00', + 'close': '11:00:00' + } + ] + } + ] + }; + var customLocationIdentifier = 'LOC1014'; + try { + var response = await eBay.location.createInventoryLocation(customLocationIdentifier, data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Delete Inventory Location +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var customLocationIdentifier = 'LOC1014'; + try { + var response = await eBay.location.deleteInventoryLocation(customLocationIdentifier); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Disable Inventory Location +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var customLocationIdentifier = 'LOC1014'; + try { + var response = await eBay.location.disableInventoryLocation(customLocationIdentifier); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Enable Inventory Location +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var customLocationIdentifier = 'LOC1014'; + try { + var response = await eBay.location.enableInventoryLocation(customLocationIdentifier); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Inventory Location +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var customLocationIdentifier = 'LOC1014'; + try { + var response = await eBay.location.getInventoryLocation(customLocationIdentifier); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Inventory Locations +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + limit: 10, + offset: 0 + }; + try { + var response = await eBay.location.getInventoryLocations(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Update Inventory Location +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + 'name': 'My Store #1', + 'location': { + 'address': { + 'addressLine1': '2055 Hamilton Ave', + 'addressLine2': 'Building 3', + 'city': 'San Jose', + 'stateOrProvince': 'CA', + 'postalCode': '95008', + 'country': 'US' + } + }, + 'merchantLocationStatus': 'ENABLED', + 'locationTypes': [ + 'STORE' + ], + 'merchantLocationKey': 'store-1' + }; + var customLocationIdentifier = 'LOC1014'; + try { + var response = await eBay.location.updateInventoryLocation(customLocationIdentifier, data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +### Offer +#### Create Offer +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + 'sku': '32984729384730', + 'marketplaceId': 'EBAY_US', + 'format': 'FIXED_PRICE', + 'listingDescription': 'This is Test product', + 'availableQuantity': 1, + 'quantityLimitPerBuyer': 1, + 'pricingSummary': { + 'price': { + 'value': 0.99, + 'currency': 'USD' + } + }, + 'listingPolicies': { + 'fulfillmentPolicyId': '78842674011', + 'paymentPolicyId': '61019561011', + 'returnPolicyId': '61019560011' + }, + 'categoryId': '178086', + 'merchantLocationKey': 'Store1', + 'tax': { + 'vatPercentage': 10.2, + 'applyTax': true, + 'thirdPartyTaxCategory': 'Electronics' + } + }; + try { + var response = await eBay.offer.createOffer(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Delete Offer +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var offerId = '6360335010'; + try { + var response = await eBay.offer.deleteOffer(offerId); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Listing Fees +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + offers: [ + { + 'offerId': '6360337010' + } + ] + }; + try { + var response = await eBay.offer.getListingFees(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Offer +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var offerId = '6360335010'; + try { + var response = await eBay.offer.getOffer(offerId); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Get Offers By Sku +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + sku: '32984729384730' + }; + try { + var response = await eBay.offer.getOffers(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Publish Offer +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var offerId = '6360337010'; + try { + var response = await eBay.offer.publishOffer(offerId); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Update Offer +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + 'availableQuantity': 60, + 'categoryId': '30120', + 'listingDescription': 'Test Test : Lumia phone with a stunning 5.7 inch Quad HD display and a powerful octa-core processor.', + 'listingPolicies': { + 'fulfillmentPolicyId': '78842674011', + 'paymentPolicyId': '61019561011', + 'returnPolicyId': '61019560011' + }, + 'pricingSummary': { + 'price': { + 'currency': 'USD', + 'value': '260.00' + } + }, + 'quantityLimitPerBuyer': 3 + }; + var offerId = '6360335010'; + try { + var response = await eBay.offer.updateOffer(offerId, data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` +#### Withdraw Offer +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var offerId = '6360335010'; + try { + var response = await eBay.offer.withdrawOffer(offerId); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } + +``` \ No newline at end of file diff --git a/index.d.ts b/index.d.ts index fdb2b0c..7ea027e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -67,6 +67,8 @@ declare class Inventory extends BaseClient { getInventoryItem(sku: string): Promise; getInventoryItems(params: any): Promise; + + getBulkInventoryItem(params: any): Promise; } declare class Location extends BaseClient { diff --git a/package.json b/package.json index 8680605..a4219b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ebay-node-client", - "version": "0.0.5", + "version": "0.0.6", "description": "eBay API wrapper", "keywords": [ "eBay", From 5f7f9bbd8abea8d5db8a13445a85bcf8c58dbaa3 Mon Sep 17 00:00:00 2001 From: BL Date: Thu, 11 Oct 2018 16:27:53 +0530 Subject: [PATCH 4/4] Remove unnecessary example from the readme.md file --- README.md | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/README.md b/README.md index 5a1d5fc..f30dfa2 100644 --- a/README.md +++ b/README.md @@ -58,21 +58,6 @@ eBay.setApiKey('YOUR_KEY', 'YOUR_SECRET'); - Contributors can send their Pull Request to `development` branch. - Kindly validate test cases & linting before opening new PR. -### Application - -#### Get OAuth Token -```js - try { - var token = await eBay.application.getOAuthToken({ - grant_type: 'client_credentials', - scope: 'https://api.ebay.com/oauth/api_scope' - }); - eBay.setToken(token.access_token); - } catch (error) { - console.log('error ', error); - } -``` - ``` Originally by [Bhushankumar Lilapara](https://github.com/bhushankumarl) (bhushankumar.lilapara@gmail.com). ```