asaaas
Version:
Unofficial Asaas Payment Gateway SDK
71 lines (70 loc) • 2.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvoicesAPI = void 0;
class InvoicesAPI {
apiClient;
constructor(apiClient) {
this.apiClient = apiClient;
}
async create(params) {
try {
const response = await this.apiClient.post('/invoices', params);
return response.data;
}
catch (error) {
console.error('Erro ao agendar uma nota fiscal:', error);
throw error;
}
}
async list(params) {
try {
const response = await this.apiClient.get('/invoices', { params });
return response.data;
}
catch (error) {
console.error('Erro ao obter a lista de notas fiscal:', error);
throw error;
}
}
async getById(id) {
try {
const response = await this.apiClient.get(`/invoices/${id}`);
return response.data;
}
catch (error) {
console.error('Erro ao obter a nota fiscal:', error);
throw error;
}
}
async updateById(id, params) {
try {
const response = await this.apiClient.post(`/invoices/${id}`, params);
return response.data;
}
catch (error) {
console.error('Erro ao atualizar a nota fiscal:', error);
throw error;
}
}
async authorize(id) {
try {
const response = await this.apiClient.post(`/invoices/${id}/authorize`);
return response.data;
}
catch (error) {
console.error('Erro ao emitir nota fiscal:', error);
throw error;
}
}
async cancel(id) {
try {
const response = await this.apiClient.post(`/invoices/${id}/cancel`);
return response.data;
}
catch (error) {
console.error('Erro ao cancelar nota fiscal:', error);
throw error;
}
}
}
exports.InvoicesAPI = InvoicesAPI;