Coder Social home page Coder Social logo

nodejs-ebay-api's Introduction

eBay API client for Node.js

Build Status

I am not maintaining this module anymore. If anyone has an active fork and is interested in taking this over, please let me know and I will transfer the NPM project.

Intro

This module aims to support all of eBay's APIs (Trading, Shopping, Finding, Merchandising, etc), with an interface that is both a) somewhat consistent across APIs and b) not too different from the underlying interface.

eBay's APIs are primarily XML-based, so this module unfortunately has to do a lot of JSON<->XML conversion.

History

  1. I created this module in 2012, for one of the first Node.js apps I ever launched, and built it out enough to handle my use cases at the time.
  2. Since then, several other people have contributed to the module.
  3. I decided, after reviewing the alternatives and finding nothing better, to revive this module again for a project in October 2015. I've pulled in improvements from various forks, refactored most of the code, and started adding tests.
    It is possible that in adding support for new APIs/endpoints, others that used to work no longer work.

I don't have time to build this out to support every endpoint, so if you are using this module, or would like to use this module, please submit pull requests!

Current state

The 1.x branch is currently under active development, and there may be breaking changes between minor releases.
(I realize this is contrary to best practice, but the module is not yet settled enough to major-bump every time.)

If you are using the 1.x branch, I recommend that you a) let me know your use case, b) help develop it, c) watch the commit and release logs carefully.

Usage

npm install ebay-api

var ebay = require('ebay-api');

(See the examples)

A word on the eBay APIs

eBay has an enormous collection of APIs built over the years. Enter the labyrinth here: http://developer.ebay.com or here: https://www.x.com/developers/ebay/products

Sign up for an API key here: https://publisher.ebaypartnernetwork.com/PublisherToolsAPI (You'll need a key to run the examples.)

Make sure to obey the eBay API License and Terms when using this library.

Methods

xmlRequest(options, callback)

Makes an XML POST to an eBay API endpoints.

options must contain:

  • serviceName: e.g. 'Finding'
  • opType: e.g. 'findItemsAdvanced'
  • appId: your eBay API application ID

and can optionally contain:

  • params: (see examples and API documentation)
  • reqOptions: passed to the request module, e.g. for additional headers, or timeout.
  • xmlConverter: function which takes the response XML and converts to JSON. Module uses xml2js by default, but can be overridden.
  • parser: function which takes the response data (as JSON object) and extracts items (or other units depending on the query). Module includes a default parser.
  • sandbox: boolean (default false = production). May need to add additional endpoint URLs to the code as needed.
  • raw: boolean, set true to skip parsing and return the raw XML response.
  • parseDepth: how many levels down to try to parse/interpret the response. The default parser is still experimental. Set this to 0 or 1 to let your app do all the parsing. (Default: unlimited)

for authentication, include:

  • devId
  • certId
  • authToken

callback gets (error, data).

Helpers

flatten(obj)

Simplifies the JSON format of the API responses:

  • Single-element arrays and objects are flatted to their key:value pair.
  • The structure of the format { @key:KEY, __value__:VALUE } is flattened to its key:value pair.
  • Other weird structures (from the API itself, or the XML->JSON conversion) are simplified. (See the code for details.)

Its purpose is to make the data easier to handle in code, and to model/query in MongoDB.

Runs synchronously, returns flattened object.

The default parser will flatten() the response to a finite depth (because infinite recursion on an indeterminate response size would cause an unnecessary performance hit).
If you want to flatten further, use this method directly.

parseResponseJson(data, options, callback)

The default parser. Can be overridden (see options on xmlRequest()).

convertXmlToJson(xmlBody, options, callback)

The default XML->JS converter. Uses xml2js. Can be overridden (see options on xmlRequest()).

getLatestApiVersions(callback)

Disabled in 1.x. Please submit a PR with a fix/refactor if you use this.

Get the version numbers of the APIs that make their version available.

Errors

The client exports and attempts to differentiate between EbaySystemError, EbayRequestError, and EbayClientError.

An EbayAuthenticationError is also defined, but not yet hooked up to anything.

See http://developer.ebay.com/DevZone/Shopping/docs/CallRef/types/ErrorClassificationCodeType.html and http://developer.ebay.com/devzone/xml/docs/Reference/ebay/Errors/ErrorMessages.htm.

Examples

See the examples directory. To run the examples, you need to add your own app key (I don't want my keys to be disabled for abuse!) - you can get one here.

Debugging

This module uses the debug module for internal logging.

Run your app (or node REPL) with DEBUG=ebay* ... to see output.

Enjoy!

nodejs-ebay-api's People

Contributors

benbuckman avatar disruptek avatar hex20dec avatar holgate avatar keloo avatar mrskyce avatar sgri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nodejs-ebay-api's Issues

Service operation is unknown for BulkDataExchange calls

Hi,
I am trying to do a BulkDataExchange call with no luck. I enter the correct operation type but I still keep getting. Did anyone manage to do a BulkDataExchange call? Could you tell me what am I doing wrong?

Thanks in advance!!

'Bad response status code 500 <?xml version=\'1.0\' encoding=\'UTF-8\'?><errorMessage xmlns="http://www.ebay.com/marketplace/services"><error><errorId>2000</errorId><domain>CoreRuntime</domain><severity>Error</severity><category>Request</category><message>Service operation  is unknown</message><subdomain>Inbound_Meta_Data</subdomain><parameter name="Param1"></parameter></error></errorMessage>' 
var eBayAPI = require('ebay-api');
static startDownloadJobRequest(requestParams){

        return new Promise(function (resolve, reject){

            eBayAPI.xmlRequest({
                serviceName : 'BulkDataExchange',
                opType : 'startDownloadJob',

                devId: eBayParams.devId,
                certId: eBayParams.certId,
                appName: eBayParams.appName,
                sandbox: eBayParams.sandBox,
                authToken: requestParams.token,

                params: {
                    'downloadJobType': "SoldReport"

                }
            }, function(error, result) {
                console.log("startDownloadJobRequest",error, result);
                if(error)
                    reject(error);
                else{
                    resolve(result);
                }
            });

        });
    }
}

Problem when calling GetCategories

        ebay-api.ebayApiGetRequest({
                serviceName: 'Trading',
                opType: 'GetCategories',
                appId: "xxx",
                params: {
                },
                parser: ebay.parseItemsFromResponse
            },
            function allItemsCallback(error, items) {
               console.error(error);
               console.log(items);
            }
        });

I get this error:
[SyntaxError: Unexpected token <]

Restler bug causing request issues

There is a bug in the version of restler that this module utilizes. This thread provides a good look into the issue and how it was solved angular-app/angular-app#125.

This issue originally manifested itself when I would make a request to ebay, send a response back and then make another request and attempt to send another response which would then throw the error "Cant set headers after they are sent.".

Here is the original fix: QuePort/restler@d44d126

Restler has committed the fix and is functioning as expected.

API versions

Like all platform API, old versions are likely to be deprecated from time to time, forcing the library author (you) to update the code just to keep the thing useful.

It would be best to allow specifying versions, along with version-specific opType handlers in params.

I can make a pull request in a week or two if you don't wanna bother with it. ๐Ÿ˜‰

ebayApiPostXmlRequest Callback being triggered twice

This is my code snippet that calls the function:

ebay.ebayApiPostXmlRequest({
        serviceName: 'Trading',
        opType: 'GetOrders',
        devName: 'mobisoft',
....},function(error, results) {
        if (error) {
            console.dir(error);
            process.exit(1);
        }
        res.send(getAddresses(results.OrderArray.Order));<--line 39
    });

In my callback function I call res.send(...), this function is being triggered twice from ebay-api/index.js:417:7 which caused this exception.

It looks like the second one was triggered upon receiving response 304 but I cannot decrypt the https traffice.

< http.js:689
< throw new Error('Can't set headers after they are sent.');
< ^
< Error: Can't set headers after they are sent.
< at ServerResponse.OutgoingMessage.setHeader (http.js:689:11)
< at ServerResponse.header (/Users/brucexia/nodejs/ebayhelper/node_modules/express/lib/response.js:662:10)
< at ServerResponse.json (/Users/brucexia/nodejs/ebayhelper/node_modules/express/lib/response.js:232:10)
< at ServerResponse.send (/Users/brucexia/nodejs/ebayhelper/node_modules/express/lib/response.js:134:21)
< at module.exports (/Users/brucexia/nodejs/ebayhelper/routes/orders.js:39:13)
< at request.on.error.message (/Users/brucexia/nodejs/ebayhelper/node_modules/ebay-api/index.js:417:7)
< at parseData (/Users/brucexia/nodejs/ebayhelper/node_modules/ebay-api/index.js:411:9)
< at async.iterator.fn (/Users/brucexia/nodejs/ebayhelper/node_modules/ebay-api/node_modules/async/lib/async.js:517:34)
< at async.waterfall.wrapIterator (/Users/brucexia/nodejs/ebayhelper/node_modules/ebay-api/node_modules/async/lib/async.js:441:34)
< at process._tickCallback (node.js:419:13)

findItemsByProduct: Unexpected character '@' (code 64) in content after

Hello Dev,

I am using this nodejs-ebay-api module for searching the book using ISBN in app. So I took reference of this findItemsByProduct from eBay developers site. I have tried my code like following

var parameters = {
    productId:{ '__value__': "9788172234980", '@type': 'ISBN' },
    outputSelector: ['AspectHistogram'],
    paginationInput: {
        entriesPerPage: 10
    }
};
ebay.xmlRequest({
    serviceName: 'Finding',
    opType: 'findItemsByProduct',
    appId: 'My-app-id',
    params: parameters
}, function itemsCallback(error, itemsResponse) {
    if (error) throw error;
    var items = itemsResponse.searchResult.item;
    console.log('Found', items.length, 'items');
    //console.log(items[0].sellingStatus.currentPrice.amount);
    for (var i = 0; i < items.length; i++) {
        console.log(items[i].title);
    }
});

But getting error as

EbayClientError: Bad response status code 500 <?xml version='1.0' encoding='UTF-8'?><errorMessage xmlns="http://www.ebay.com/marketplace/search/v1/services"><error><errorId>5014</errorId><domain>CoreRuntime</domain><severity>Error</severity><category>System</category><message>Error reading from XML stream: Unexpected character '@' (code 64) in content after '&lt;' (malformed start element?).
 at javax.xml.stream.SerializableLocation@a550a55</message><subdomain>Comm_Recv</subdomain><parameter name="Param1">Unexpected character '@' (code 64) in content after '&lt;' (malformed start element?).
 at javax.xml.stream.SerializableLocation@a550a55</parameter></error></errorMessage>
    at Request._callback (/home/user/node_modules/ebay-api/lib/xml-request.js:151:23)
    at Request.self.callback (/home/user/node_modules/request/request.js:200:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/home/user/node_modules/request/request.js:1067:10)
    at emitOne (events.js:101:20)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/home/user/node_modules/request/request.js:988:12)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)

Please suggest me on this.

npm module branch/version outdated

I see that the master branch has stopped using restler and is now using request. However, this branch doesnt appear to have made it to npm. The package.json file declares 0.1.1, which is the package version I currently have...however the npm still has the outdated restler module (old branch?).

I will fork this module for now and then npm link to it locally...but I do not believe npm has the most recent version of your library. Let me know if I am mistaken or just missing something.

lib/urls.js not using HTTPS

Hi,

It seems that the Finding and Product URLS are currently using HTTP while HTTPS is now supported. I've created a branch with the requeired changed by was unable to push it to origin due to the following. It would be great to have this included.

remote: Permission to benbuckman/nodejs-ebay-api.git denied to dietkinnie.

Best regards,

dietkinnie

Issue with appID in getRequest

Hi, I'm new to coding and building a school project that connects to ebay trading. Keep trying to formulate an ebayApiGetRequest with this package but I always seem to run into this error after sending the request.
[SyntaxError: Unexpected token <] .
I've taken out lines individually and it seems to occur whenever I add my personal app id. Project wide search yielding no help. Are there any known issues/conflicts?

PictureUrl issue - submit product with more than 1 picture

Hi,
when trying to submit a product to ebay you have to specify the urls of the picturesyou want to add and they'r placed in a xml PictureUrl tag. Because all the xml tags have the same name there's a issue when you try to add more than 1 picture to the json (you actully override the previouse one).
Is there anyway to fix this issue without adding xml tags manualy?

TODO October 2015

Keeping track of TODOs following the refactor and 1.x release:

  • export flatten method
  • Re-enable pagination (updated: decided to remove this from the module; apps should implement their own pagination logic.)
  • Review all past issues and PRs

possible get a list of matching categories and ids given a string?

Is this possible with this API?

https://developer.ebay.com/api-docs/commerce/taxonomy/resources/category_tree/methods/getCategorySuggestions

I have tried this but I get a 503 error:

    getCategories(){
        const params = {
            q: this.keywords.split(/\s+/),
            category_tree_id: this.categoryId
        };

        return new Promise((resolve, reject) => {
            this.client.xmlRequest({
                serviceName: 'Taxonomy',
                opType: 'getCategorySuggestions',
                appId: this.appId,
                params,
                parser: this.client.parseResponseJson
            }, (err, res) => {
                if (err) {
                    return reject(err);
                }

                resolve(res);
            });
        });
    }

Switching country code per request

I'm a wee bit stuck and getting a bit tired of trying this and that, so I thought I'd ask the community.

If I'm building something that would change the country being searched per request, can I do something like the following?

  var filters = {};

  filters.ItemFilter = [
    new ebay.ItemFilter("ListingType", "FixedPrice"),
    new ebay.ItemFilter("AvailableTo", "AU")
  ];

  var reqOptions = {};

  reqOptions["X-EBAY-SOA-GLOBAL-ID"] = "EBAY-AU";

  ebay.ebayApiGetRequest({
      serviceName: 'FindingService',
      opType: 'findItemsByProduct',
      appId: credentials.prod.ebay.appId,
      params: params,
      filters: filters,
      reqOptions: reqOptions,
      parser: ebay.parseItemsFromResponse
    },
    // gets all the items together in a merged array
    function itemsCallback(error, items) {
      // handle it
    }
  );

AddFixedPriceItem Call... No <Item.Country> exists?

Hi, I'm trying to make an AddFixedPriceItemCall. I'm using the ebayApiPostXmlRequest method, and my params are seen below:

params: {
            authToken: myAuthTokenIsHere,
            Item: {
                Country: 'US',
                Currency: 'USD',
                Description: description,
                ListingType: 'FixedPriceItem',
                PictureDetails: picturesArray,
                Quantity: '5',
                StartPrice: price
            },
}

I have auth tokens, etc. and all application tokens, I've simply omitted that code from here. Unfortunately, it's giving errors that the country doesn't exist, although it's obviously shown in my Item{} object. Is this a bug, or am I doing something wrong?

Thank you!

json2xml instead of node-xml?

Thanks for the great job on eBay API.

AFAIK you are converting JSON objects into node-xml formats, while the json2xml object format is more friendly to pure JavaScript coders.

Could even skip the _(params).each loop to convert things. ;)

site id doesn't work

Hello.
i want to specify a site ID (e.g 71 for france), usually i would put it the header of the xml request (X-EBAY-API-SITE-ID), but with the xmlRequest method i didn't manage to do that. The call returns me the data according to the default site ID = 0 (US).
here is my code:

const ebay = require('ebay-api');
const options = {
  serviceName: 'Trading',
  opType: 'GeteBayDetails',
  devId: ebayApiCredentials.devId,
  certId: ebayApiCredentials.certId,
  appId: ebayApiCredentials.appId,
  authToken: btas.token,
  params: {
    DetailName: detailName
  },
  reqOptions: {
    headers: {
      'X-EBAY-API-SITE-ID': btas.siteID
    }
  }
};
ebay.xmlRequest(options, (error, data) => {
  return resolve(data);
});

i have tried also to insert it like this

reqOptions: {
    headers: {
      siteid : btas.siteID
    }

and also just in the body.
thanks!

FinalValueFee won't appear in the result

Hi,

In the Trading API GetOrders call there is an input parameter: IncludeFinalValueFee if you send this with true value the FinalValueFee should be in the response according to the eBay API documentation and the ebay scratchpad call but I don't seem to find it in our response the FinalValueFee parameter that should be there. Do you know what could be the issue?

Thank you for your help in advance.

All queries are using the wrong values

I have made a simple script to interface with ebay through this plugin but all queries are using these values.

serviceName='Trading'
opType='GetSellingManagerSoldListings';

Even if i leave them blank it queries this same API. Even when i try GetSellingManagerSaleRecord is shows the same response.

What am i doing wrong?

my server.js below.. I have replaced my actual values with XXXXXXXXXXXXXX. The authToken is fed in from the client side at this time.

var ebay_cred={
    //get orders
  // app/environment
  devId: 'XXXXXXXXXXXXXX',
  certId: 'XXXXXXXXXXXXXX',
  appName: 'XXXXXXXXXXXXXX',
  sandbox: false,
};
s={};
s.userOps=function(x,y){
    y=ebay_cred;
    for (var n in x) {
       y[n]=x[n];
    }
    return y;
}
var http = require('http'),io = require('socket.io'),fs = require('fs'),request = require('request');
var server = http.createServer();
server.listen(3000);
io = io.listen(server);

io.on('connection', function (cn) {
    function tx(x){cn.emit('f',x);}
    cn.on('f', function (d) {
        switch(d.f){
            case'diag':
                tx(ebay_cred);
            break;
            case'getOrders':
                d.op.serviceName='Trading',d.op.opType='GetSellingManagerSoldListings';
                ebay.xmlRequest(s.userOps(d.op),function(er,d) {
                    tx({f:'getOrders',d:ebay.flatten(d)});
                });
            break;
            case'x':
                ebay.xmlRequest(s.userOps(d.op),function(er,d) {
                    tx(d);
                });
            break;
        }
    });
});

my client code looks like this

    <table id="processingOrders">
        <tbody>

        </tbody>
    </table>
<script>
  $user={token:'XXXXXXXXXXXX'}
  var socket = io('ws://localhost:3000');
    function cx(x){
        if(!x.op){x.op={}};x.op.authToken=$user.token;
        socket.emit('f',x);
    }
    socket.on('f',function (d) {
        console.log(d);
        switch(d.f){
            case'getOrders':
                d.e=$('#processingOrders');
                d.tmp='';
                if(d.d&&d.d.SaleRecord){
                $.each(d.d.SaleRecord,function(n,v){
                    v._SM=v.SellingManagerSoldTransaction,v._SA=v.ShippingAddress;
                    d.tmp+='<tr>';
                        d.tmp+='<td>'+v._SM.ItemTitle+'</td><td>'+v._SA.Name+'</td><td>'+v._SA.PostalCode+'</td>';
                    d.tmp+='</tr>';
                });
                }
                d.e.find('tbody').append(d.tmp);
            break;
        }
        delete(d.tmp);
    });
    </script>

Some example client calls:

cx({f:'getOrders'})
cx({f:'x',ops:{serviceName:'Finding',opType:'GetSellingManagerSaleRecord',params:{ItemID:"172279039480",TransactionID:"1581513952007"}}})

ebayApiPostXmlRequest request is incorrect

I started using the current master branch that utilizes the request module...however I started having code failing giving me the error

{
    "EBayTime": "2014-10-03 18:43:44",
    "Errors": {
        "Error": {
            "Code": "2",
            "Column": "0",
            "ErrorClass": "RequestError",
            "Line": "0",
            "Severity": "SeriousError",
            "SeverityCode": "1",
            "ShortMessage": "Unsupported verb."
        }
    }
}

After fooling with this for a few hours and ensuring that everything was going to ebay as they expected...I reviewed the code around utilization of request.

In the ebayApiPostXmlRequest function there is an object called options.reqOptions which contains data for the xml body and headers for the request headers. However, when it is handed off to the request module the options.reqOptions is passed into the request headers parameter...which is incorrect

current (i assume broken?)

var request = requestModule.post({'url': url, 'headers': options.reqOptions}, function(error, response, result) {

working (assume fix?)

var request = requestModule.post({'url': url, body: options.reqOptions.data, 'headers': options.reqOptions.headers}, function(error, response, result) {

Hope this helps anyone that has seen this issue..

Possible to make the call "GetMemberMessages"

Is it possible to make the API call to the "GetMemberMessages" end point.
This is the error I get:
{ '$': { xmlns: 'urn:ebay:apis:eBLBaseComponents' },
Timestamp: '2017-05-04 18:45:55',
Ack: 'Failure',
Errors:
{ ShortMessage: 'Unsupported API call.',
LongMessage: 'The API call "GetMemberMessagesRequest" is invalid or not supported in this release.',
ErrorCode: '2',
SeverityCode: 'Error',
ErrorClassification: 'RequestError' },
Version: '775',
Build: '18007281' }

Params I am using:

params: {
"WarningLevel":"High",
"MailMessageType":"All",
"Pagination":{
"EntriesPerPage":"100",
"PageNumber":"1"
}
}

Processing of nested repeatable fields

Hi

The API is Awesome !
I had one problem when trying to add a nested repeatable field.

e.g. GetOrders where I want to get a single order identified by it's OrderID ( ItemID - TransactionID).
This sits in an OrderIDArray element.
So should look like this

213123123-234234234 ..... repeat as necessary

The code in index.js was passing the object directly and not as an array.
It may be the way I passed it in the first place but I tried the example line in index.js and it failed.
So I modified my index.js for the ebay-api slightly

This the array I am passing in from my Router app.js

var OrderIDArray = [];
var Orderelem = [{'OrderID' : orderID}];
    params: {
      'authToken': app.get('authToken'),
      'OrderIDArray' : Orderelem
}

Line 158 ish in ebay-api index.js

// 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 = {};

// Added this to convert the json string to an array, in a similar way to the array test above.
if (_.isObject(value)) {
value = [value];
};
el[key] = value;
top.push(el);
});
});

As I stated, it may be me. However, just in case this helps anyone else.

Authentication failed : Invalid Application

I always get the above error no matter if I use my production or sandbox keys. I also tried to add devId and certId.

Code:

inspect = require('eyespect').inspector({maxLength: null})
chalk = require('chalk')

ebay = require('ebay-api')

ebayConfig = require('../config/ebay.config.js')
appId = ebayConfig.getAppKey('AppID')
console.log appId

exports.getItems = (appUser, searchTerm, callback)->
  options = {}
  options.appId = ebayConfig.getAppKey('appId')
  options.devId = ebayConfig.getAppKey('devId')
  options.certId = ebayConfig.getAppKey('certId')

  options.serviceName = "Finding"
  options.opType = "findItemsAdvanced"

  params = {
    keywords: ["Canon", "Powershot"],

    #add additional fields
    outputSelector: ['AspectHistogram'],

    paginationInput: {
      entriesPerPage: 10
    },

    itemFilter: [
      {name: 'FreeShippingOnly', value: true},
      {name: 'MaxPrice', value: '150'}
    ],

    domainFilter: [
      {name: 'domainName', value: 'Digital_Cameras'}
    ]
  }
  options.params = params

  inspect options #the appId, devId and certId are displayed correctly
  ebay.xmlRequest(options, callback)

Error Msg:

{"err":{"name":"EbayClientError","message":"Bad response status code 500 <?xml version='1.0' encoding='UTF-8'?><errorMessage xmlns=\"http://www.ebay.com/marketplace/search/v1/services\"><error><errorId>11002</errorId><domain>Security</domain><severity>Error</severity><category>System</category><message>Authentication failed : Invalid Application: MYAPPID</message><subdomain>Authentication</subdomain><parameter name=\"Param1\">Invalid Application: MYAPPID</parameter></error></errorMessage>"}}

GetNotificationPreferences doesn't properly convert xml to json

I put a breakpoint on xml-converter.js, and the xmlBody is passed in correctly, but somewhere it will drop all the notificationEnable entries

raw xml received from ebay

<?xml version="1.0" encoding="UTF-8"?>
<GetNotificationPreferencesResponse xmlns="urn:ebay:apis:eBLBaseComponents">
   <Timestamp>2016-10-03T03:22:21.880Z</Timestamp>
   <Ack>Success</Ack>
   <Version>967</Version>
   <Build>E967_CORE_APINOTIFY_18003059_R1</Build>
   <UserDeliveryPreferenceArray>
      <NotificationEnable>
         <EventType>EndOfAuction</EventType>
         <EventEnable>Disable</EventEnable>
      </NotificationEnable>
      <NotificationEnable>
         <EventType>AuctionCheckoutComplete</EventType>
         <EventEnable>Enable</EventEnable>
      </NotificationEnable>
      <NotificationEnable>
         <EventType>Feedback</EventType>
         <EventEnable>Disable</EventEnable>
      </NotificationEnable>
      <NotificationEnable>
         <EventType>FixedPriceTransaction</EventType>
         <EventEnable>Enable</EventEnable>
      </NotificationEnable>
      <NotificationEnable>
         <EventType>ItemListed</EventType>
         <EventEnable>Disable</EventEnable>
      </NotificationEnable>
      <NotificationEnable>
         <EventType>MyMessagesM2MMessage</EventType>
         <EventEnable>Disable</EventEnable>
      </NotificationEnable>
      <NotificationEnable>
         <EventType>BidReceived</EventType>
         <EventEnable>Disable</EventEnable>
      </NotificationEnable>
      <NotificationEnable>
         <EventType>FeedbackReceived</EventType>
         <EventEnable>Enable</EventEnable>
      </NotificationEnable>
   </UserDeliveryPreferenceArray>
</GetNotificationPreferencesResponse>

after conversion

{
  "$": {
    "xmlns": "urn:ebay:apis:eBLBaseComponents"
  },
  "Timestamp": "2016-10-03T03:22:21.880Z",
  "Ack": "Success",
  "Version": "967",
  "Build": "E967_CORE_APINOTIFY_18003059_R1",
  "UserDeliveryPreferences": []
}

Problem with buildXmlInput

var xmlBody contains a xml request with a wrong syntax.
The ItemId it's wrong. The correct identificator is ItemID.

`buildXmlInput` and `deepToArray` don't allow single-wrapper arrays

The module is trying to be smart in converting the input JSON params to XML.
See deep-to-array.test.js and xml-request.test.js.

So given an input param thing: ['a', 'b', 'c'], it converts that to

<thing>a</thing>
<thing>b</thing>
<thing>c</thing>

But if we want to do something like,

<OrderIDArray>
  <OrderID>aaaa</OrderID>
  <OrderID>bbbb</OrderID>
</OrderIDArray>

This doesn't seem currently possible.

Should the module try to stay smart, and somehow differentiate these? Or should the input param structure simply follow the xml module's pattern without conversion?

Nested objects are not handled properly in options.params

If you try to pass a params object that has a nested object inside it, the xml serialization doesn't work properly.

{code}
params : {
authToken : 'AuthToken',
ItemID : 'itemId',
// 'CreateTimeFrom' : '2013-10-13T00:00:00.0',
// 'CreateTimeTo' : '2013-10-27T00:00:00.0',
MemberMessage :
{
Body : ['Hello,',
'There'].join('\n'),
QuestionType: 'General',
RecipientID : 'ReceipientId',
Subject : 'My Store'
}
}
{code}

The XML you get in this case doesn't include the contents of MemberMessage and you get . That's it.

(this is an example trying to use the AddMemberMessageAAQToPartner eBay API Method to send an ebay message to a buyer (http://developer.ebay.com/Devzone/XML/docs/Reference/eBay/AddMemberMessageAAQToPartner.html)

Affiliate setup

Has anyone successfully setup their eBay Partner Network to work with this library? Reading the docs it seems like a minefield.

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.