lib/adapter/serialize.js
/**
 * Serialize data before sending to the source.
 * Will set the given data as a property according to the path set on the
 * request endpoint, if specified.
 * @param {Object} request - The request
 * @returns {Object} Serialized data
 */
Serialize data before sending to the source.
Will set the given data as a property according to the path set on the
request endpoint, if specified.
@param {Object} request - The request
@returns {Object} Serialized data
Serialize data before sending to the source . Will set the given data as a property according to the path set on the request endpoint if specified . @param { Object } request - The request @returns { Object } Serialized data
async function serialize(request) {
  const {
    requestPath,
    namespace,
    soapAction: soapActionOption,
    soapActionNamespace,
    soap = {},
  } = request.endpoint
  const { soapAction, ...preparedObj } = prepareData(
    await unpromise(request.data),
    requestPath,
    namespace,
    soapActionOption,
    soapActionNamespace,
    soap
  )
  const options = {
    compact: true,
    spaces: soap.spaces || 2,
    textFn: encodeText,
    allowDoubleSanitization: true,
  }
  const data = convert.js2xml(preparedObj, options)
  return {
    ...request,
    data,
    params: {
      ...(soapAction ? { soapAction } : {}),
      ...request.params,
    },
  }
}
async function serialize ( request ) { const { requestPath , namespace , soapAction : soapActionOption , soapActionNamespace , soap = { } , } = request . endpoint const { soapAction , ... preparedObj } = prepareData ( await unpromise ( request . data ) , requestPath , namespace , soapActionOption , soapActionNamespace , soap ) const options = { compact : true , spaces : soap . spaces || 2 , textFn : encodeText , allowDoubleSanitization : true , } const data = convert . js2xml ( preparedObj , options ) return { ... request , data , params : { ... ( soapAction ? { soapAction } : { } ) , ... request . params , } , } }
Serialize data before sending to the source.
Serialize data before sending to the source .