pajaydev / ebay-node-api

eBay API Client for node
https://pajaydev.github.io/ebay-node-api
MIT License
132 stars 75 forks source link

Update getSingleItem function #148

Closed EarthlingDavey closed 2 years ago

EarthlingDavey commented 3 years ago

Update getSingleItem to accept object as parameter.

Goal of the pull request:

Description

This change allows for additional parameters to be passed to getSingleItem. For example in a similar way to getShippingCosts.

It can be used as before with a string of ItemID, backwards compatibility is preserved.

Also, an object may be passed, to add parameters refferenced in the eBay GetSingleItem docs

e.g.

ebay.getSingleItem({
      itemId: ebayId,
      includeSelector: 'Description',
});
EarthlingDavey commented 2 years ago

@pajaydev thanks for merging this in. I appreciate you maintaining this repo! 👊🏼✌🏼

SteveMcArthur commented 2 years ago

This actually seems to have broken the getSingleItem method as it seems to be expecting a parameter named "input" but the input is actually name "itemId". So the method call always fails.

const getSingleItem = function (itemId) {
    if (!input || (typeof input !== 'object' && typeof input !== 'string'))
        throw new Error('invalid_request_error -> Invalid input');
    // To preserve backwards compatibility
    if (typeof input === 'string') {
        input = { ItemID: input };
    }
  ...
};
EarthlingDavey commented 2 years ago

Thanks @SteveMcArthur ... idk how I missed this. Probable tested on local then copy/pasted into the text editor on GitHub, lesson learned & patch PR just submitted.