snglpi/src/services/servicenowService.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

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