UNPKG

@reportfy/tester

Version:

Lib para teste de integração usando serviço do reportfy

43 lines (40 loc) 1.07 kB
const { requestApi } = require('../helpers/request') const URL_CONFIG_API = 'https://tester.reportfy.com.br/api/config' const REPORT_INTEGRATION = 'https://tester.reportfy.com.br/api/report' /** * @function * @param key * @returns {Promise<*>} */ exports.getConfigByKey = async ({ key, accessKey, secretKey }) => { try { const { data } = await requestApi({ url: `${URL_CONFIG_API}`, method: 'post', data: { token: key, accessKey, secretKey } }) if (data === null) { throw new Error('key inválida!') } return data } catch (_) { throw new Error('key inválida!') } } /** * @function * @param data * @returns {Promise<null>} */ exports.reportRequestSender = async (data, { key, accessKey, secretKey }) => { try { await requestApi({ url: `${REPORT_INTEGRATION}/${key}`, method: 'post', data: {...data, accessKey, secretKey } }) return null } catch (_) { return null } }