Comparing version 0.0.7 to 0.1.0
30
index.js
@@ -136,2 +136,5 @@ // eBay API client for Node.js | ||
// e.g. 'Pagination': [ { 'EntriesPerPage': '100' } ] | ||
// | ||
// for repeatable fields, use an array value (see below) | ||
// | ||
var buildXmlInput = function(opType, params) { | ||
@@ -155,7 +158,13 @@ var xmlBuilder = require('xml'); | ||
} | ||
_(params).each(function(value, key) { | ||
var el = {}; | ||
el[key] = value; | ||
top.push(el); | ||
// for repeatable fields, use array values. | ||
// to keep this simpler, treat everything as an array value. | ||
_(params).each(function(values, key) { | ||
if (!_.isArray(values)) values = [values]; | ||
_(values).each(function(value){ | ||
var el = {}; | ||
el[key] = value; | ||
top.push(el); | ||
}); | ||
}); | ||
@@ -344,2 +353,5 @@ | ||
// options.parser = options.parser || ...; // @todo | ||
// converts XML to JSON by default, but can also return raw XML | ||
options.rawXml = options.rawXml || false; | ||
@@ -355,3 +367,4 @@ | ||
options.reqOptions.data = buildXmlInput(options.opType, options.params); | ||
options.reqOptions.data = buildXmlInput(options.opType, options.params); | ||
// console.log(options.reqOptions.data); | ||
@@ -369,2 +382,7 @@ var request = restler.post(url, options.reqOptions); | ||
} | ||
// raw XML wanted? | ||
if (options.rawXml) { | ||
return callback(null, result); | ||
} | ||
@@ -371,0 +389,0 @@ async.waterfall([ |
{ | ||
"name": "ebay-api", | ||
"description": "eBay API Client", | ||
"version": "0.0.7", | ||
"version": "0.1.0", | ||
"homepage": "https://github.com/newleafdigital/nodejs-ebay-api", | ||
@@ -6,0 +6,0 @@ "author": "Ben Buckman <ben@newleafdigital.com> (http://newleafdigital.com)", |
@@ -6,3 +6,3 @@ eBay API client for Node.js | ||
This was built to power the "eBay Picks" section of [AntiquesNearMe.com](http://antiquesnearme.com). It can currently query the FindingService, MerchandisingService, and Shopping API via JSON-GET requests, and parts of the Trading API via XML-POST. Other services can be added as needed. (Pull requests welcome!) | ||
This was built to power the "eBay Picks" section of [AntiquesNearMe.com](http://antiquesnearme.com). It can currently query the FindingService, MerchandisingService, and Shopping API via JSON-GET requests, and the Trading API via XML-POST. Other services can be added as needed. (Pull requests welcome!) | ||
@@ -100,5 +100,9 @@ ## To use | ||
- params (for the XML input) | ||
- (Note: for `GetCategories` and possibly other services, pass the auth token as `params.authToken`, not `RequesterCredentials.eBayAuthToken` as indicated in the API documentation.) | ||
- See `buildXmlInput()` for ways to structure this. | ||
- reqOptions: headers and other options to pass to the request | ||
- IMPT: Some parameters for these endpoints, such as _SITE-ID_ and _authToken_, should go into the headers, not into `params`. See the API documentation. | ||
- sandbox: true/false (default false = production). May need to add additional endpoint URLs to the code as needed. | ||
- rawXml: boolean. If `true`, passes the raw XML response back to callback. `false` means XML is converted to JSON (for consistency with other APIs). Default is `false`/JSON. | ||
@@ -105,0 +109,0 @@ `callback` gets `(error, data)`. (There is not currently a default parser for these endpoints.) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32966
605
159