// Função de comunicação com a rota mounting, para a construção do ambiente do usuário async function Autenticao() { const apiUrl = await getApiUrl(); const token = getAuthToken(); const response = await fetch(`${apiUrl}/mounting`, { method: 'GET', headers: { 'Content-Type': 'application/json', 'x-access-token': token ? token : '' } }); return { response, apiUrl }; // Retorne um objeto com a resposta e apiUrl } async function IntegracaoZamade() { const apiUrl = await getApiUrl(); const token = getAuthToken(); const Chamados = await fetch(`${apiUrl}/tickets`, { method: 'GET', headers: { 'Content-Type': 'application/json', 'x-access-token': token, //'Id_Cliente': domain } }); let ResutadosChamados = Chamados.status; //console.log(ResutadosChamados); return { Chamados, ResutadosChamados }; // Retorna a resposta e a URL } async function IntegracaoBoleto() { const apiUrl = await getApiUrl(); const token = getAuthToken(); if (!apiUrl || !token) { throw new Error("Erro: Parâmetros obrigatórios ausentes (apiUrl, token ou domain)"); } await fetch(`${apiUrl}/boletos`, { method: 'OPTIONS' }); const Boleto = await fetch(`${apiUrl}/boletos`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-access-token': token } }); if (!Boleto.ok) { throw new Error(`Erro na API de geração de boletos: ${Boleto.status} - ${Boleto.statusText}`); } return { Boleto, apiUrl }; // Retorna a resposta e a URL } async function IntegracaoPDF() { const apiUrl = await getApiUrl(); const token = getAuthToken(); if (!apiUrl || !token) { throw new Error("Erro: Parâmetros obrigatórios ausentes (apiUrl, token ou domain)"); } await fetch(`${apiUrl}/baixar_boleto/`, { method: 'GET' }); const PDF = await fetch(`${apiUrl}/baixar_boleto/`, { method: 'OPTIONS', headers: { 'Content-Type': 'application/json', 'x-access-token': token } }); if (!PDF.ok) { throw new Error(`Erro na API de Geração de Pdfs: ${PDF.status} - ${PDF.statusText}`); } return { PDF, apiUrl }; // Retorna a resposta e a URL } async function IntegracaoZabix() { const apiUrl = await getApiUrl(); const token = getAuthToken(); if (!apiUrl || !token) { throw new Error("Erro: Parâmetros obrigatórios ausentes (apiUrl, token ou domain)"); } const Zabix = await fetch(`${apiUrl}/zabbix/hosts`, { method: 'GET', headers: { 'Content-Type': 'application/json', 'x-access-token': token, //'Id_Cliente': domain } }); let ResutadosZabix = Zabix.status; //console.log(ResutadosZabix); return { Zabix, ResutadosZabix }; // Retorna a resposta e a URL } /* async function IntegracaoUser() { const apiUrl = await getApiUrl(); const token = getAuthToken(); if (!apiUrl || !token) { throw new Error("Erro: Parâmetros obrigatórios ausentes (apiUrl, token ou domain)"); } const empresa = await fetch(`${apiUrl}/zabbixhosts`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-access-token': token, //'Id_Cliente': domain } }); if (!empresa.ok) { throw new Error(`Erro na API do Zabix: ${empresa.status} - ${empresa.statusText}`); } return { empresa, apiUrl }; // Retorna a resposta e a URL } */ async function EmpresasServicos() { const apiUrl = await getApiUrl(); const token = getAuthToken(); const Servicos = await fetch(`${apiUrl}/servicos`, { method: 'GET', headers: { 'Content-Type': 'application/json', 'x-access-token': token, //'Id_Cliente': domain } }); let ResutadosES = Servicos.status; //console.log(ResutadosES); return { Servicos, ResutadosES }; // Retorna a resposta e a URL } async function ConsultasEmpresas() { const apiUrl = await getApiUrl(); const token = getAuthToken(); if (!apiUrl || !token) { throw new Error("Erro: Parâmetros obrigatórios ausentes (apiUrl, token ou domain)"); } const Empresinhas = await fetch(`${apiUrl}/empresas`, { method: 'GET', headers: { 'Content-Type': 'application/json', 'x-access-token': token, //'Id_Cliente': domain } }); if (!Empresinhas.ok) { throw new Error(`Erro na API das empresas: ${Empresinhas.status} - ${Empresinhas.statusText}`); } return { Empresinhas, apiUrl }; // Retorna a resposta e a URL } // Envios de formularios async function NovoUser(novoUser) { const apiUrl = await getApiUrl(); const token = getAuthToken(); if (!apiUrl || !token) { throw new Error("Erro: Parâmetros obrigatórios ausentes (apiUrl, token ou domain)"); } const User = await fetch(`${apiUrl}/inserir`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-access-token': token, }, body: JSON.stringify(novoUser) }); if (!User.ok) { throw new Error(`Erro na criação de Usuário: ${User.status} - ${User.statusText}`); } } async function NovasImagens(dataperfil) { const apiUrl = await getApiUrl(); const token = getAuthToken(); for (let [key, value] of dataperfil.entries()) { //console.log(`${key}:`, value); } if (!apiUrl || !token) { throw new Error("Erro: Parâmetros obrigatórios ausentes (apiUrl, token ou domain)"); } const ImagemUser = await fetch(`${apiUrl}/imagem`, { method: 'POST', headers: { //'Content-Type': 'application/json', 'x-access-token': token, }, body: dataperfil // Dados enviados para a API }); if (!ImagemUser.ok) { throw new Error(`Erro na atualização de Imagens: ${ImagemUser.status} - ${ImagemUser.statusText}`); } }