lib/adapter/normalize.js
/**
 * Normalize data from the source.
 * Returns an object starting from the path set on the request endpoint.
 * @param {Object} response - The response with data to normalize
 * @param {Object} request - The request
 * @returns {Object} Normalized data
 */
Normalize data from the source.
Returns an object starting from the path set on the request endpoint.
@param {Object} response - The response with data to normalize
@param {Object} request - The request
@returns {Object} Normalized data
Normalize data from the source . Returns an object starting from the path set on the request endpoint . @param { Object } response - The response with data to normalize @param { Object } request - The request @returns { Object } Normalized data
async function normalize(response, { endpoint }) {
  if (response.status !== 'ok') {
    return response
  }
  const { path, soap: { xsiPrefix = 'xsi' } = {} } = endpoint
  const rawObj = convert.xml2js(response.data, { compact: true })
  const { data, defaultPrefix } = getDataAtPath(rawObj, path)
  return {
    ...response,
    data: normalizeObject(data, defaultPrefix, xsiPrefix, ''),
  }
}
async function normalize ( response , { endpoint } ) { if ( response . status !== 'ok' ) { return response } const { path , soap : { xsiPrefix = 'xsi' } = { } } = endpoint const rawObj = convert . xml2js ( response . data , { compact : true } ) const { data , defaultPrefix } = getDataAtPath ( rawObj , path ) return { ... response , data : normalizeObject ( data , defaultPrefix , xsiPrefix , '' ) , } }
Normalize data from the source.
Normalize data from the source .