Home Reference Source

lib/helpers/getMatchingProduct.js

  1. const errors = require('../errors');
  2.  
  3. const parseMatchingProduct = require('../parsers/matchingProduct');
  4.  
  5. const inputParser = opt => ({
  6. MarketplaceId: opt.marketplaceId || opt.MarketplaceId,
  7. IdType: opt.idType || opt.IdType,
  8. IdList: opt.idList || opt.IdList,
  9. });
  10.  
  11. const outputParser = (out) => {
  12. if (out.Error) {
  13. throw new errors.ServiceError(out.Error.Message);
  14. }
  15. return parseMatchingProduct(out);
  16. };
  17.  
  18. const getMatchingProductForId = api => api.parseEndpoint(outputParser, inputParser)('GetMatchingProductForId');
  19.  
  20. module.exports = getMatchingProductForId;