2025-08-30 19:04:35 -03:00
|
|
|
const axios = require('axios');
|
2025-09-03 11:13:23 -03:00
|
|
|
const apiConfig = require('../../config/apiConfig');
|
|
|
|
|
const fs = require('fs');
|
2025-08-30 19:04:35 -03:00
|
|
|
|
2025-09-03 11:13:23 -03:00
|
|
|
const fetchTicketsFromServiceNow = async () => {
|
2025-08-30 19:04:35 -03:00
|
|
|
try {
|
2025-09-03 11:13:23 -03:00
|
|
|
const ticketsResponse = await axios.get(apiConfig.snApiConfig.baseUrl, {
|
|
|
|
|
auth: apiConfig.snApiConfig.auth
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// gerar um JSON das respostas da API
|
|
|
|
|
fs.writeFileSync('servicenow_tickets.json', JSON.stringify(ticketsResponse.data, null, 2));
|
2025-08-30 19:04:35 -03:00
|
|
|
} catch (error) {
|
2025-09-03 11:13:23 -03:00
|
|
|
console.log('SERVICE NOW error: ', error.message);
|
2025-08-30 19:04:35 -03:00
|
|
|
}
|
2025-09-03 11:13:23 -03:00
|
|
|
}
|
2025-08-30 19:04:35 -03:00
|
|
|
|
|
|
|
|
module.exports = {
|
2025-09-03 11:13:23 -03:00
|
|
|
fetchTicketsFromServiceNow
|
|
|
|
|
}
|