lib/adapter/send.js
/**
 * Send the given data to the endpoint, and return status and data.
 * This is used for both retrieving and sending data, and Integreat will
 * handle the preparation of the sent and the retrieved data.
 *
 * If an auth strategy is provided, authorization is attempted if not already
 * authenticated, and a successfull authentication is required before sending
 * the data with auth headers from the auth strategy.
 *
 * @param {Object} request - Request with uri/endpoint, data, auth, method, and headers
 * @returns {Object} Object with status and data
 */
Send the given data to the endpoint, and return status and data.
This is used for both retrieving and sending data, and Integreat will
handle the preparation of the sent and the retrieved data.

If an auth strategy is provided, authorization is attempted if not already
authenticated, and a successfull authentication is required before sending
the data with auth headers from the auth strategy.

@param {Object} request - Request with uri/endpoint, data, auth, method, and headers
@returns {Object} Object with status and data
Send the given data to the endpoint and return status and data . This is used for both retrieving and sending data and Integreat will handle the preparation of the sent and the retrieved data . If an auth strategy is provided authorization is attempted if not already authenticated and a successfull authentication is required before sending the data with auth headers from the auth strategy . @param { Object } request - Request with uri / endpoint data auth method and headers @returns { Object } Object with status and data
async function send (got, { endpoint, data: requestData, auth, params = {} }, logger = undefined) {
  if (!endpoint) {
    return { status: 'noaction', error: 'No endpoint' }
  }
  const { uri } = endpoint
  const options = createOptions(requestData, endpoint, params, auth)
  const request = {
    uri,
    method: options.method,
    body: options.body,
    headers: options.headers,
    retries: options.retry.retries
  }
  if (params.dryrun) {
    return {
      status: 'dryrun',
      data: request
    }
  }
  logRequest(request, logger)
  const response = await sendRequest(uri, options, got)
  logResponse(response, request, logger)
  return response
}
async function send ( got , { endpoint , data : requestData , auth , params = { } } , logger = undefined ) { if ( ! endpoint ) { return { status : 'noaction' , error : 'No endpoint' } } const { uri } = endpoint const options = createOptions ( requestData , endpoint , params , auth ) const request = { uri , method : options . method , body : options . body , headers : options . headers , retries : options . retry . retries } if ( params . dryrun ) { return { status : 'dryrun' , data : request } } logRequest ( request , logger ) const response = await sendRequest ( uri , options , got ) logResponse ( response , request , logger ) return response }
Send the given data to the endpoint, and return status and data.
Send the given data to the endpoint and return status and data .