diff --git a/.gitignore b/.gitignore index efcdb7c..e25cd54 100644 --- a/.gitignore +++ b/.gitignore @@ -64,4 +64,5 @@ typings/ .idea #Temp Directory -temp/* \ No newline at end of file +temp/* +.DS_Store \ No newline at end of file diff --git a/.npmignore b/.npmignore index 3e59ee9..393e815 100644 --- a/.npmignore +++ b/.npmignore @@ -1,5 +1,5 @@ node_modules +node_modules/* .npm-debug.log tags -package-lock.json .idea \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 8f14d78..75bbadc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,7 @@ node_js: - "7" - "8" - "9" + - "10" + - "11" + - "12" sudo: false \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 644a95c..6286fb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +0.0.10 + - Add support for override content language + - Add support for the fulfillment API + - Add support for override marketplace + - Add support for the payment policy API + - Add support for the return policy API + - Add support for the searchByImage API + - Add example sample for the bulkCreateOrReplaceInventoryItem & bulkUpdatePriceQuantity; + - Add typescript support for the bulkCreateOrReplaceInventoryItem & bulkUpdatePriceQuantity; + 0.0.9 - Add support for trading APIs, shopping APIs & Finding APIs diff --git a/README.md b/README.md index a9c50e4..1615e20 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,26 @@ const eBay = new eBay(); eBay.setApiKey('YOUR_KEY', 'YOUR_SECRET'); ``` +## Set Application Access Token +```js + eBay.setToken(token.access_token); +``` + +## Set User Token +```js + eBay.setUserToken(userToken); +``` + +## Set Content Language (Default is en-US) +```js + eBay.setContentLanguage('en-GB'); +``` + +## Set MarketplaceId +```js + eBay.setMarketplaceId('EBAY_US'); +``` + ## Pull Request - Contributors can send their Pull Request to `development` branch. - Kindly validate test cases & linting before opening new PR. @@ -134,6 +154,24 @@ Originally by [Bhushankumar L](mailto:bhushankumar.lilapara@gmail.com). } ``` +#### Search By Image +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var base64Content = base64_encode('sample-image.jpg'); + // console.log('base64Content ', base64Content); + var data = { + image: base64Content + }; + try { + var response = await eBay.browse.searchByImage(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } +``` + ### Commerce ### Catalog #### Create Change Request @@ -480,6 +518,23 @@ Originally by [Bhushankumar L](mailto:bhushankumar.lilapara@gmail.com). } ``` +### Fulfillment Policy +#### Get Fulfillment Policies +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + marketplace_id: 'EBAY_US' + }; + try { + var response = await eBay.fulfillmentPolicy.getFulfillmentPolicies(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } +``` + #### Get Sales Tax ``` var userToken = utils.USER_TOKEN; @@ -511,7 +566,98 @@ Originally by [Bhushankumar L](mailto:bhushankumar.lilapara@gmail.com). } ``` +### Payment Policy +#### Get Payment Policies +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + marketplace_id: 'EBAY_US' + }; + try { + var response = await eBay.paymentPolicy.getPaymentPolicies(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } +``` + +### Return Policy +#### Get Return Policies +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + marketplace_id: 'EBAY_US' + }; + try { + var response = await eBay.returnPolicy.getReturnPolicies(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } +``` + ### Inventory +#### Bulk Create Or Replace Inventory Item +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + 'requests': [ + { + 'sku': '13465446' + }, + { + 'sku': '132165496' + } + ] + }; + try { + var response = await eBay.inventory.bulkCreateOrReplaceInventoryItem(data); + console.log('response ', response); + } catch (error) { + console.log('error ', error); + return; + } +``` + +#### Bulk Update Price Quantity +``` + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { /* BulkPriceQuantity */ + 'requests': [ + { /* PriceQuantity */ + 'offers': [ + { /* OfferPriceQuantity */ + 'availableQuantity': 'integer', + 'offerId': 'string', + 'price': { /* Amount */ + 'currency': 'string', + 'value': 'string' + } + } + ], + 'shipToLocationAvailability': { + /* ShipToLocationAvailability */ + 'quantity': 'integer' + }, + 'sku': 'string' + } + ] + } + try { + var response = await eBay.inventory.bulkUpdatePriceQuantity(sku, data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } +``` + #### Create Or Replace Inventory Item ``` var userToken = utils.USER_TOKEN; diff --git a/examples/javaScript/buy/browse/sample-image.jpg b/examples/javaScript/buy/browse/sample-image.jpg new file mode 100644 index 0000000..55da74c Binary files /dev/null and b/examples/javaScript/buy/browse/sample-image.jpg differ diff --git a/examples/javaScript/buy/browse/searchByImage.js b/examples/javaScript/buy/browse/searchByImage.js new file mode 100644 index 0000000..4631a0c --- /dev/null +++ b/examples/javaScript/buy/browse/searchByImage.js @@ -0,0 +1,36 @@ +'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 fs = require('fs'); + +// function to encode file data to base64 encoded string +function base64_encode (file) { + // read binary data + var bitmap = fs.readFileSync(file); + // convert binary data to base64 encoded string + return new Buffer(bitmap).toString('base64'); +} + +var browseRequest = async function () { + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var base64Content = base64_encode('sample-image.jpg'); + // console.log('base64Content ', base64Content); + var data = { + image: base64Content + }; + try { + var response = await eBay.browse.searchByImage(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } +}; + +browseRequest(); diff --git a/examples/javaScript/sell/account/fulfillmentPolicy/getFulfillmentPolicies.js b/examples/javaScript/sell/account/fulfillmentPolicy/getFulfillmentPolicies.js new file mode 100644 index 0000000..8df1ac1 --- /dev/null +++ b/examples/javaScript/sell/account/fulfillmentPolicy/getFulfillmentPolicies.js @@ -0,0 +1,24 @@ +'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 accountRequest = async function () { + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + marketplace_id: 'EBAY_US' + }; + try { + var response = await eBay.fulfillmentPolicy.getFulfillmentPolicies(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } +}; + +accountRequest(); diff --git a/examples/javaScript/sell/account/paymentPolicy/getPaymentPolicies.js b/examples/javaScript/sell/account/paymentPolicy/getPaymentPolicies.js new file mode 100644 index 0000000..fd4a783 --- /dev/null +++ b/examples/javaScript/sell/account/paymentPolicy/getPaymentPolicies.js @@ -0,0 +1,24 @@ +'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('../../../utils'); + +var accountRequest = async function () { + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + marketplace_id: 'EBAY_US' + }; + try { + var response = await eBay.paymentPolicy.getPaymentPolicies(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } +}; + +accountRequest(); diff --git a/examples/javaScript/sell/account/returnPolicy/getReturnPolicies.js b/examples/javaScript/sell/account/returnPolicy/getReturnPolicies.js new file mode 100644 index 0000000..31b1e14 --- /dev/null +++ b/examples/javaScript/sell/account/returnPolicy/getReturnPolicies.js @@ -0,0 +1,24 @@ +'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('../../../utils'); + +var accountRequest = async function () { + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { + marketplace_id: 'EBAY_US' + }; + try { + var response = await eBay.returnPolicy.getReturnPolicies(data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } +}; + +accountRequest(); diff --git a/examples/javaScript/sell/inventory/bulkCreateOrReplaceInventoryItem.js b/examples/javaScript/sell/inventory/bulkCreateOrReplaceInventoryItem.js new file mode 100644 index 0000000..022e8c6 --- /dev/null +++ b/examples/javaScript/sell/inventory/bulkCreateOrReplaceInventoryItem.js @@ -0,0 +1,31 @@ +'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('../../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.bulkCreateOrReplaceInventoryItem(data); + console.log('response ', response); + } catch (error) { + console.log('error ', error); + return; + } +}; + +inventoryRequest(); diff --git a/examples/javaScript/sell/inventory/bulkUpdatePriceQuantity.js b/examples/javaScript/sell/inventory/bulkUpdatePriceQuantity.js new file mode 100644 index 0000000..5eb3e32 --- /dev/null +++ b/examples/javaScript/sell/inventory/bulkUpdatePriceQuantity.js @@ -0,0 +1,42 @@ +'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('../../utils'); + +var inventoryRequest = async function () { + var userToken = utils.USER_TOKEN; + eBay.setUserToken(userToken); + var data = { /* BulkPriceQuantity */ + 'requests': [ + { /* PriceQuantity */ + 'offers': [ + { /* OfferPriceQuantity */ + 'availableQuantity': 'integer', + 'offerId': 'string', + 'price': { /* Amount */ + 'currency': 'string', + 'value': 'string' + } + } + ], + 'shipToLocationAvailability': { + /* ShipToLocationAvailability */ + 'quantity': 'integer' + }, + 'sku': 'string' + } + ] + } + try { + var response = await eBay.inventory.bulkUpdatePriceQuantity(sku, data); + console.log('response', response); + } catch (error) { + console.log('error ', error); + return; + } +}; + +inventoryRequest(); diff --git a/index.d.ts b/index.d.ts index eb96ae6..6954b6b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -26,6 +26,8 @@ declare class Browse extends BaseClient { search(params: any): Promise; + searchByImage(imageBase64String: string): Promise; + getItem(itemId: string): Promise; } @@ -71,6 +73,12 @@ declare class Inventory extends BaseClient { getInventoryItems(params: any): Promise; getBulkInventoryItem(params: any): Promise; + + bulkGetInventoryItem(params: any): Promise; + + bulkCreateOrReplaceInventoryItem(params: any): Promise; + + bulkUpdatePriceQuantity(params: any): Promise; } declare class Location extends BaseClient { @@ -489,6 +497,8 @@ declare class eBayNodeClient { setDevName(devName: string): void; setCertName(certName: string): void; + + setContentLanguage(contentLanguage: string): void; } diff --git a/lib/eBay-node-client.js b/lib/eBay-node-client.js index 94456b2..05a65a0 100644 --- a/lib/eBay-node-client.js +++ b/lib/eBay-node-client.js @@ -35,6 +35,9 @@ var exec = require('child_process').exec; var resources = { account: require('./resources/sell/account'), + fulfillmentPolicy: require('./resources/sell/account/fulfillmentPolicy'), + paymentPolicy: require('./resources/sell/account/paymentPolicy'), + returnPolicy: require('./resources/sell/account/returnPolicy'), application: require('./resources/application'), browse: require('./resources/buy/browse'), catalog: require('./resources/commerce/catalog'), @@ -51,7 +54,6 @@ var resources = { eBay.eBayResource = require('./eBayResource'); eBay.resources = resources; - function eBay(clientId, clientSecret, isSandbox) { if (!(this instanceof eBay)) { return new eBay(clientId, clientSecret, isSandbox); @@ -179,6 +181,18 @@ eBay.prototype = { } }, + setContentLanguage: function (contentLanguage) { + if (contentLanguage) { + this._setApiField('contentLanguage', contentLanguage); + } + }, + + setMarketplaceId: function (marketplaceId) { + if (marketplaceId) { + this._setApiField('marketplaceId', marketplaceId); + } + }, + setTimeout: function (timeout) { this._setApiField('timeout', timeout === null ? eBay.DEFAULT_TIMEOUT : timeout); }, @@ -207,6 +221,14 @@ eBay.prototype = { return this._api['certName']; }, + getContentLanguage: function () { + return this._api['contentLanguage']; + }, + + getMarketplaceId: function () { + return this._api['marketplaceId']; + }, + getApiField: function (key) { return this._api[key]; }, diff --git a/lib/eBayResource.js b/lib/eBayResource.js index 3458d39..1366783 100644 --- a/lib/eBayResource.js +++ b/lib/eBayResource.js @@ -15,7 +15,7 @@ var Error = require('./Error'); var hasOwn = {}.hasOwnProperty; -var RESPONSE_CONTENT_TYPE = ['text/xml', 'text/xml;charset=utf-8', 'application/xml']; +var RESPONSE_CONTENT_TYPE = [ 'text/xml', 'text/xml;charset=utf-8', 'application/xml' ]; // Provide extension mechanism for eBay Resource Sub-Classes eBayResource.extend = utils.protoExtend; @@ -26,7 +26,7 @@ eBayResource.BASIC_METHODS = require('./eBayMethod.basic.js'); /** * Encapsulates request logic for a eBay Resource */ -function eBayResource(eBay, urlData) { +function eBayResource (eBay, urlData) { this._eBay = eBay; this._urlData = urlData || {}; @@ -35,7 +35,7 @@ function eBayResource(eBay, urlData) { if (this.includeBasic) { this.includeBasic.forEach(function (methodName) { - this[methodName] = eBayResource.BASIC_METHODS[methodName]; + this[ methodName ] = eBayResource.BASIC_METHODS[ methodName ]; }, this); } @@ -63,10 +63,10 @@ eBayResource.prototype = { createFullPath: function (commandPath, urlData) { return path.join( - this.basePath(urlData), - this.path(urlData), - typeof commandPath === 'function' ? - commandPath(urlData) : commandPath + this.basePath(urlData), + this.path(urlData), + typeof commandPath === 'function' ? + commandPath(urlData) : commandPath ).replace(/\\/g, '/'); // ugly workaround for Windows }, @@ -75,7 +75,7 @@ eBayResource.prototype = { // Merge in baseData for (var i in this._urlData) { if (hasOwn.call(this._urlData, i)) { - urlData[i] = this._urlData[i]; + urlData[ i ] = this._urlData[ i ]; } } return urlData; @@ -116,10 +116,10 @@ eBayResource.prototype = { _responseHandler: function (requestParamsJSONCopy, req, userOptions, callback) { var self = this; - function processResponseType(res, responseString, callback) { + function processResponseType (res, responseString, callback) { //debug('res %o ', res); //debug('res.headers %o ', res.headers); - if (RESPONSE_CONTENT_TYPE.indexOf(res.headers['content-type'].toLowerCase()) > -1) { + if (RESPONSE_CONTENT_TYPE.indexOf(res.headers[ 'content-type' ].toLowerCase()) > -1) { debug('It is XML Response'); var parser = new xml2js.Parser({ explicitArray: false, @@ -157,14 +157,14 @@ eBayResource.prototype = { var charset = ''; var content_type = ''; var responseString = ''; - if (headers['content-type']) { - content_type = headers['content-type'].toLowerCase(); + if (headers[ 'content-type' ]) { + content_type = headers[ 'content-type' ].toLowerCase(); } - if (content_type && content_type.indexOf('charset') > -1 && content_type.split(';')[0] && content_type.split(';')[1]) { - if (content_type.split(';')[1] && content_type.split(';')[1].match(/^((\b[^\s=]+)=(([^=]|\\=)+))*$/)[3]) { - charset = content_type.split(';')[1].match(/^((\b[^\s=]+)=(([^=]|\\=)+))*$/)[3]; + if (content_type && content_type.indexOf('charset') > -1 && content_type.split(';')[ 0 ] && content_type.split(';')[ 1 ]) { + if (content_type.split(';')[ 1 ] && content_type.split(';')[ 1 ].match(/^((\b[^\s=]+)=(([^=]|\\=)+))*$/)[ 3 ]) { + charset = content_type.split(';')[ 1 ].match(/^((\b[^\s=]+)=(([^=]|\\=)+))*$/)[ 3 ]; } - content_type = content_type.split(';')[0].toLowerCase(); + content_type = content_type.split(';')[ 0 ].toLowerCase(); } var ResponseHeaders = headers; @@ -309,7 +309,7 @@ eBayResource.prototype = { // getRedirectUrl var authorizeURLOptions = { redirect_uri: data.redirectURI, - scope: [data.scope] + scope: [ data.scope ] }; var authorizationUriPromise = oauth2.authorizationCode.authorizeURL(authorizeURLOptions); return callback(null, authorizationUriPromise); @@ -374,56 +374,63 @@ eBayResource.prototype = { 'Content-Language': 'en-US', 'authorization': authorization }; - + var contentLanguage = self._eBay.getContentLanguage(); + if (contentLanguage) { + headers[ 'Content-Language' ] = contentLanguage; + } + var marketplaceId = self._eBay.getMarketplaceId(); + if (marketplaceId) { + headers[ 'X-EBAY-C-MARKETPLACE-ID' ] = marketplaceId; + } /** * eBay Old API Implementation */ if (options.api === 'trading') { delete headers.authorization; - headers['X-EBAY-API-SITEID'] = 0; - headers['X-EBAY-API-COMPATIBILITY-LEVEL'] = 967; - headers['X-EBAY-API-CALL-NAME'] = options.call; + headers[ 'X-EBAY-API-SITEID' ] = 0; + headers[ 'X-EBAY-API-COMPATIBILITY-LEVEL' ] = 967; + headers[ 'X-EBAY-API-CALL-NAME' ] = options.call; var appName = self._eBay.getAppName(); var devName = self._eBay.getDevName(); var certName = self._eBay.getCertName(); if (appName) { - headers['X-EBAY-API-APP-NAME'] = appName; + headers[ 'X-EBAY-API-APP-NAME' ] = appName; } if (devName) { - headers['X-EBAY-API-DEV-NAME'] = devName; + headers[ 'X-EBAY-API-DEV-NAME' ] = devName; } if (certName) { - headers['X-EBAY-API-CERT-NAME'] = certName; + headers[ 'X-EBAY-API-CERT-NAME' ] = certName; } } if (options.api === 'finding') { delete headers.authorization; - headers['X-EBAY-SOA-OPERATION-NAME'] = options.call; - headers['X-EBAY-SOA-SECURITY-APPNAME'] = self._eBay.getAppName(); + headers[ 'X-EBAY-SOA-OPERATION-NAME' ] = options.call; + headers[ 'X-EBAY-SOA-SECURITY-APPNAME' ] = self._eBay.getAppName(); } if (options.api === 'shopping') { // debug('Inside shopping API call'); delete headers.authorization; - headers['X-EBAY-API-APP-ID'] = self._eBay.getAppName(); - headers['X-EBAY-API-SITEID'] = '0'; - headers['X-EBAY-API-CALL-NAME'] = options.call; - headers['X-EBAY-API-VERSION'] = '863'; - headers['X-EBAY-API-REQUEST-ENCODING'] = 'XML'; + headers[ 'X-EBAY-API-APP-ID' ] = self._eBay.getAppName(); + headers[ 'X-EBAY-API-SITEID' ] = '0'; + headers[ 'X-EBAY-API-CALL-NAME' ] = options.call; + headers[ 'X-EBAY-API-VERSION' ] = '863'; + headers[ 'X-EBAY-API-REQUEST-ENCODING' ] = 'XML'; } if (options.contentType && options.contentType === 'text/xml') { self.body = data.content; } else if (options.contentType && options.contentType === 'application/json') { self.body = JSON.stringify(data); - } else if (['POST'].indexOf(method) > -1) { + } else if ([ 'POST' ].indexOf(method) > -1) { // debug('Inside POST Request'); - headers['Content-Type'] = 'application/x-www-form-urlencoded'; + headers[ 'Content-Type' ] = 'application/x-www-form-urlencoded'; self.body = '&' + qs.stringify(data); - } else if (['PUT'].indexOf(method) > -1) { + } else if ([ 'PUT' ].indexOf(method) > -1) { self.body = JSON.stringify(data); - } else if (['GET'].indexOf(method) > -1) { + } else if ([ 'GET' ].indexOf(method) > -1) { path = path.concat('?', qs.stringify(data)); - } else if (['DELETE'].indexOf(method) > -1) { + } else if ([ 'DELETE' ].indexOf(method) > -1) { self.body = JSON.stringify(data); } @@ -435,7 +442,7 @@ eBayResource.prototype = { makeRequest(); }); - function makeRequest() { + function makeRequest () { var timeout = self._eBay.getApiField('timeout'); var isInsecureConnection = self._eBay.getApiField('protocol') === 'http'; @@ -448,22 +455,22 @@ eBayResource.prototype = { headers: headers }; if (options.api === 'trading') { - params['api'] = options.api; - params['call'] = options.call; - params['variation'] = options.variation; + params[ 'api' ] = options.api; + params[ 'call' ] = options.call; + params[ 'variation' ] = options.variation; } else if (options.api === 'finding') { // debug('Inside finding call'); - params['host'] = self._eBay.getApiField('findingApiHost'); - params['api'] = options.api; - params['call'] = options.call; - params['variation'] = options.variation; + params[ 'host' ] = self._eBay.getApiField('findingApiHost'); + params[ 'api' ] = options.api; + params[ 'call' ] = options.call; + params[ 'variation' ] = options.variation; } else if (options.api === 'shopping') { // debug('Inside shopping call'); - params['host'] = self._eBay.getApiField('shoppingApiHost'); - params['port'] = 80; - params['api'] = options.api; - params['call'] = options.call; - params['variation'] = options.variation; + params[ 'host' ] = self._eBay.getApiField('shoppingApiHost'); + params[ 'port' ] = 80; + params[ 'api' ] = options.api; + params[ 'call' ] = options.call; + params[ 'variation' ] = options.variation; } debug('path ', path); debug('params %o ', params); diff --git a/lib/resources/buy/browse.js b/lib/resources/buy/browse.js index 0b53523..916086f 100644 --- a/lib/resources/buy/browse.js +++ b/lib/resources/buy/browse.js @@ -4,7 +4,6 @@ var eBayResource = require('../../eBayResource'); var eBayMethod = eBayResource.method; module.exports = eBayResource.extend({ - search: eBayMethod({ method: 'GET', path: 'buy/browse/v1/item_summary/search' @@ -14,6 +13,12 @@ module.exports = eBayResource.extend({ path: 'buy/browse/v1/item/{item_id}', urlParams: ['item_id'], required: ['item_id'] + }), + searchByImage: eBayMethod({ + authorization: 'User', + contentType: 'application/json', + method: 'POST', + path: 'buy/browse/v1/item_summary/search_by_image' }) }); diff --git a/lib/resources/sell/account/fulfillmentPolicy.js b/lib/resources/sell/account/fulfillmentPolicy.js new file mode 100644 index 0000000..552dea8 --- /dev/null +++ b/lib/resources/sell/account/fulfillmentPolicy.js @@ -0,0 +1,14 @@ +'use strict'; + +var eBayResource = require('../../../eBayResource'); +var eBayMethod = eBayResource.method; + +module.exports = eBayResource.extend({ + + getFulfillmentPolicies: eBayMethod({ + authorization: 'User', + method: 'GET', + path: 'sell/account/v1/fulfillment_policy' + }) + +}); diff --git a/lib/resources/sell/account/paymentPolicy.js b/lib/resources/sell/account/paymentPolicy.js new file mode 100644 index 0000000..bf0c4a0 --- /dev/null +++ b/lib/resources/sell/account/paymentPolicy.js @@ -0,0 +1,14 @@ +'use strict'; + +var eBayResource = require('../../../eBayResource'); +var eBayMethod = eBayResource.method; + +module.exports = eBayResource.extend({ + + getPaymentPolicies: eBayMethod({ + authorization: 'User', + method: 'GET', + path: 'sell/account/v1/payment_policy' + }) + +}); diff --git a/lib/resources/sell/account/returnPolicy.js b/lib/resources/sell/account/returnPolicy.js new file mode 100644 index 0000000..3bdd04b --- /dev/null +++ b/lib/resources/sell/account/returnPolicy.js @@ -0,0 +1,14 @@ +'use strict'; + +var eBayResource = require('../../../eBayResource'); +var eBayMethod = eBayResource.method; + +module.exports = eBayResource.extend({ + + getReturnPolicies: eBayMethod({ + authorization: 'User', + method: 'GET', + path: 'sell/account/v1/return_policy' + }) + +}); diff --git a/lib/resources/sell/inventory.js b/lib/resources/sell/inventory.js index 4cc59b8..a718192 100644 --- a/lib/resources/sell/inventory.js +++ b/lib/resources/sell/inventory.js @@ -9,35 +9,47 @@ module.exports = eBayResource.extend({ authorization: 'User', method: 'PUT', path: 'sell/inventory/v1/inventory_item/{sku}', - urlParams: ['sku'], - required: ['sku'] + urlParams: [ 'sku' ], + required: [ 'sku' ] }), deleteInventoryItem: eBayMethod({ authorization: 'User', method: 'DELETE', path: 'sell/inventory/v1/inventory_item/{sku}', - urlParams: ['sku'], - required: ['sku'] + urlParams: [ 'sku' ], + required: [ 'sku' ] }), getInventoryItem: eBayMethod({ authorization: 'User', method: 'GET', path: 'sell/inventory/v1/inventory_item/{sku}', - urlParams: ['sku'], - required: ['sku'] + urlParams: [ 'sku' ], + required: [ 'sku' ] }), getInventoryItems: eBayMethod({ authorization: 'User', method: 'GET', path: 'sell/inventory/v1/inventory_item', - urlParams: ['sku'], - required: ['sku'] + urlParams: [ 'sku' ], + required: [ 'sku' ] }), bulkGetInventoryItem: eBayMethod({ authorization: 'User', contentType: 'application/json', method: 'POST', path: 'sell/inventory/v1/bulk_get_inventory_item' + }), + bulkCreateOrReplaceInventoryItem: eBayMethod({ + authorization: 'User', + contentType: 'application/json', + method: 'POST', + path: 'sell/inventory/v1/bulk_create_or_replace_inventory_item' + }), + bulkUpdatePriceQuantity: eBayMethod({ + authorization: 'User', + contentType: 'application/json', + method: 'POST', + path: 'sell/inventory/v1/bulk_update_price_quantity' }) }); diff --git a/package.json b/package.json index 8ef2175..a811167 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ebay-node-client", - "version": "0.0.9", + "version": "0.0.10", "description": "eBay API wrapper", "keywords": [ "eBay", @@ -8,6 +8,8 @@ "eBay Inventory API", "eBay Compliance API", "eBay Fulfillment API", + "eBay Payment Policy API", + "eBay Return Policy API", "eBay Marketing API", "eBay Analytics API", "eBay Metadata API",