UNPKG

giganet_conecta

Version:

Aplicação com o fim de facilitar conexões com APi's e Banco de Dados (MySql, Mongo e Elasticsearch).

58 lines (52 loc) 1.48 kB
const request = require("request"); // InserirOrdemServicoIxc module.exports = async function ( id_cliente, id_assundo, id_login, mensagem, id_cidade, ) { try { const token = process.env.conecta_api_ixc_soft_token; try { const options = { method: "POST", url: "https://giganet-rs.com.br/webservice/v1/su_oss_chamado", headers: { "content-type": "application/json", Authorization: "Basic " + Buffer.from(token).toString("base64"), }, // Passado a ordem de serviço modificado body: JSON.stringify({ id: "", id_filial: "1", status: "A", id_cliente: id_cliente, id_assunto: id_assundo, setor: "2", prioridade: "N", mensagem: mensagem, id_login: id_login, origem_endereco: "L", ...(id_cidade && { cidade: id_cidade }), tipo: "C", origem_endereco: "C", liberado: 1, melhor_horario_agenda: "Q", }), }; return await new Promise((resolve, reject) => { request(options, (error, response, body) => { if (error) { reject(error); } else { resolve(body); } }); }); } catch (error) {} } catch (error) { throw `Erro em inserir uma ordem de serviço no IXC Soft: ${error}`; } };