UNPKG

@contaazul/n8n-nodes-contaazul

Version:

Node para integração com a API da Conta Azul no n8n

96 lines 4.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getFinancialAccounts = getFinancialAccounts; exports.getRevenuesByFilter = getRevenuesByFilter; exports.getExpensesByFilter = getExpensesByFilter; exports.getInstallmentById = getInstallmentById; const utils_1 = require("./utils"); async function getFinancialAccounts() { var _a; const nome = this.getNodeParameter('nome_conta', 0, ''); const tipos = this.getNodeParameter('tipos', 0, []); const apenas_ativo = this.getNodeParameter('apenas_ativo', 0, true); const pagina = this.getNodeParameter('pagina_conta', 0, 1); const tamanho_pagina = this.getNodeParameter('tamanho_pagina_conta', 0, 10); const qs = { pagina, tamanho_pagina, apenas_ativo, }; if (nome) { qs.nome = nome; } if (tipos && tipos.length > 0) { qs.tipos = tipos; } const responseData = await ((_a = this.helpers.requestOAuth2) === null || _a === void 0 ? void 0 : _a.call(this, 'contaAzulOAuth2Api', { method: 'GET', url: 'https://api-v2.contaazul.com/v1/conta-financeira', qs, json: true, })); return this.helpers.returnJsonArray(responseData); } async function getRevenuesByFilter() { var _a; const busca = this.getNodeParameter('busca_receita', 0, ''); const pagina = this.getNodeParameter('pagina_receita', 0, 1); const tamanho_pagina = this.getNodeParameter('tamanho_pagina_receita', 0, 10); const data_vencimento_de_raw = this.getNodeParameter('data_vencimento_de', 0); const data_vencimento_ate_raw = this.getNodeParameter('data_vencimento_ate', 0); const data_vencimento_de = (0, utils_1.toYYYYMMDD)(data_vencimento_de_raw); const data_vencimento_ate = (0, utils_1.toYYYYMMDD)(data_vencimento_ate_raw); const qs = { pagina, tamanho_pagina, data_vencimento_de, data_vencimento_ate, }; if (busca) { qs.busca = busca; } const responseData = await ((_a = this.helpers.requestOAuth2) === null || _a === void 0 ? void 0 : _a.call(this, 'contaAzulOAuth2Api', { method: 'GET', url: 'https://api-v2.contaazul.com/v1/financeiro/eventos-financeiros/contas-a-receber/buscar', qs, json: true, })); return this.helpers.returnJsonArray(responseData.itens); } async function getExpensesByFilter() { var _a; const busca = this.getNodeParameter('busca_despesa', 0, ''); const pagina = this.getNodeParameter('pagina_despesa', 0, 1); const tamanho_pagina = this.getNodeParameter('tamanho_pagina_despesa', 0, 10); const data_vencimento_de_raw = this.getNodeParameter('data_vencimento_de_despesa', 0); const data_vencimento_ate_raw = this.getNodeParameter('data_vencimento_ate_despesa', 0); const data_vencimento_de = (0, utils_1.toYYYYMMDD)(data_vencimento_de_raw); const data_vencimento_ate = (0, utils_1.toYYYYMMDD)(data_vencimento_ate_raw); const qs = { pagina, tamanho_pagina, data_vencimento_de, data_vencimento_ate, }; if (busca) { qs.busca = busca; } const responseData = await ((_a = this.helpers.requestOAuth2) === null || _a === void 0 ? void 0 : _a.call(this, 'contaAzulOAuth2Api', { method: 'GET', url: 'https://api-v2.contaazul.com/v1/financeiro/eventos-financeiros/contas-a-pagar/buscar', qs, json: true, })); return this.helpers.returnJsonArray(responseData.itens); } async function getInstallmentById() { var _a; const installmentId = this.getNodeParameter('installmentId', 0); const responseData = await ((_a = this.helpers.requestOAuth2) === null || _a === void 0 ? void 0 : _a.call(this, 'contaAzulOAuth2Api', { method: 'GET', url: `https://api-v2.contaazul.com/v1/financeiro/eventos-financeiros/parcelas/${installmentId}`, json: true, })); return this.helpers.returnJsonArray([responseData]); } //# sourceMappingURL=financeiro.js.map