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 16:11:30 -03:00
|
|
|
const ticketsResponse = await axios.get(apiConfig.snIncidentConfig.baseUrl, {
|
|
|
|
|
auth: apiConfig.servicenowAuthentication.auth
|
2025-09-03 11:13:23 -03:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// gerar um JSON das respostas da API
|
|
|
|
|
fs.writeFileSync('servicenow_tickets.json', JSON.stringify(ticketsResponse.data, null, 2));
|
2025-09-03 16:11:30 -03:00
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log('SERVICE NOW Tickets error: ', error.message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const fetchRequestsFromServiceNow = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const requestsResponse = await axios.get(apiConfig.snRequestConfig.baseUrl, {
|
|
|
|
|
auth: apiConfig.servicenowAuthentication.auth
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// gerar um JSON das respostas da API
|
|
|
|
|
fs.writeFileSync('servicenow_requests.json', JSON.stringify(requestsResponse.data, null, 2));
|
|
|
|
|
|
2025-08-30 19:04:35 -03:00
|
|
|
} catch (error) {
|
2025-09-03 16:11:30 -03:00
|
|
|
console.log('SERVICE NOW Requests 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 16:11:30 -03:00
|
|
|
fetchTicketsFromServiceNow,
|
|
|
|
|
fetchRequestsFromServiceNow
|
2025-09-03 11:13:23 -03:00
|
|
|
}
|