diff --git a/src/services/hubsoftService.js b/src/services/hubsoftService.js index e8d0186..933dde3 100644 --- a/src/services/hubsoftService.js +++ b/src/services/hubsoftService.js @@ -55,6 +55,30 @@ const updateAtendimentoStatus = async (id_atendimento, newStatus) => { } }; -module.exports = { - updateAtendimentoStatus +const closeAtendimento = async (id_atendimento, closingMessage) => { + try { + const token = await getAuthToken(); + + const response = await axios.put(`${apiConfig.hubsoft.atendimentosUrl}${id_atendimento}`, { + "fechar_atendimento": true, + "parametros_fechamento": { + "descricao_fechamento": closingMessage + } + }, + { + headers: { + 'Authorization': `Bearer ${token}`, + 'Content-Type': 'application/json' + } + }); + return response.data; + } catch (error) { + logError(`Erro ao fechar atendimento ID ${id_atendimento}:`, error.response ? error.response.data : error.message); + throw error; + } +}; + +module.exports = { + updateAtendimentoStatus, + closeAtendimento };