UNPKG

@hotwax/oms-api

Version:

The OMS API package comes with prebuilt methods that helps communicate with HotWax Commerce OMS using Rest API

52 lines (40 loc) 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getIdentification = getIdentification; exports.getTelecomCountryCode = getTelecomCountryCode; exports.hasError = hasError; exports.isError = isError; exports.jsonParse = jsonParse; var _telecomCode = require("./telecomCode"); function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } function hasError(response) { return _typeof(response.data) != "object" || !!response.data._ERROR_MESSAGE_ || !!response.data._ERROR_MESSAGE_LIST_ || !!response.data.error; } function isError(response) { return response.code === 'error'; } function getIdentification(identifications, id) { var externalId = ''; if (identifications) { var externalIdentification = identifications.find(function (identification) { return identification.startsWith(id); }); var externalIdentificationSplit = externalIdentification ? externalIdentification.split('/') : []; externalId = externalIdentificationSplit[1] ? externalIdentificationSplit[1] : ''; } return externalId; } function getTelecomCountryCode(code) { return _telecomCode.telecomCode[code]; } function jsonParse(value) { var parsedValue; try { parsedValue = JSON.parse(value); } catch (e) { parsedValue = value; } return parsedValue; }