UNPKG

n8n-nodes-efibank

Version:

Nó personalizado para integração com as APIs Cobranças e Pix do Efi Bank, permitindo operações de pagamentos, recebimentos e gerenciamento de transações financeiras.

70 lines 3.39 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.listSubscriptions = void 0; const sdk_node_apis_efi_1 = __importDefault(require("sdk-node-apis-efi")); const credentials_cob_1 = __importDefault(require("../../../../../interfaces/credentials-cob")); async function listSubscriptions(context, index) { try { const options = await credentials_cob_1.default.call(context); const efipay = new sdk_node_apis_efi_1.default(options); const begin_date = context.getNodeParameter('begin_date', index); const end_date = context.getNodeParameter('end_date', index); const params = { begin_date, end_date, charge_type: 'subscription', }; const date_of = context.getNodeParameter('date_of', index); const status = context.getNodeParameter('status', index); const customer_document = context.getNodeParameter('customer_document', index); const custom_id = context.getNodeParameter('custom_id', index); const value = context.getNodeParameter('value', index); const limit = context.getNodeParameter('limit', index); const page = context.getNodeParameter('page', index); const offset = context.getNodeParameter('offset', index); if (date_of === null || date_of === void 0 ? void 0 : date_of.trim()) params.date_of = date_of; if (status === null || status === void 0 ? void 0 : status.trim()) params.status = status; if (customer_document === null || customer_document === void 0 ? void 0 : customer_document.trim()) params.customer_document = customer_document; if (custom_id === null || custom_id === void 0 ? void 0 : custom_id.trim()) params.custom_id = custom_id; if (typeof value === 'number' && !isNaN(value)) params.value = value; if (typeof limit === 'number' && !isNaN(limit)) params.limit = limit; if (typeof page === 'number' && !isNaN(page)) params.page = page; if (typeof offset === 'number' && !isNaN(offset)) params.offset = offset; const resposta = await efipay.listCharges(params); return resposta; } catch (error) { if (error === null || error === void 0 ? void 0 : error.error) { if (typeof error.error_description === 'object') { throw new Error(JSON.stringify({ nome: error.error, propriedade: error.error_description.property, mensagem: error.error_description.message })); } if (typeof error.error_description === 'string') { throw new Error(JSON.stringify({ nome: error.error, mensagem: error.error_description })); } } throw new Error(JSON.stringify({ nome: error.nome || error.code || 'erro_desconhecido', mensagem: error.message || error.mensagem || error.detail || 'Ocorreu um erro desconhecido' })); } } exports.listSubscriptions = listSubscriptions; //# sourceMappingURL=listSubscriptions.js.map