UNPKG

asaaas

Version:

Unofficial Asaas Payment Gateway SDK

131 lines (130 loc) 4.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PaymentsAPI = void 0; class PaymentsAPI { apiClient; constructor(apiClient) { this.apiClient = apiClient; } async new(paymentData) { try { const response = await this.apiClient.post('/payments', paymentData); return response.data; } catch (error) { console.error('Erro ao criar a cobrança:', error); throw error; } } async list(params) { try { const response = await this.apiClient.get('/payments', { params }); return response.data; } catch (error) { console.error('Erro ao obter a lista de cobranças:', error); throw error; } } async getById(id) { try { const response = await this.apiClient.get(`/payments/${id}`); return response.data; } catch (error) { console.error('Erro ao obter a cobrança:', error); throw error; } } async delete(id) { try { const response = await this.apiClient.delete(`/payments/${id}`); return response.data; } catch (error) { console.error('Erro ao deletar a cobrança:', error); throw error; } } async restore(id) { try { const response = await this.apiClient.post(`/payments/${id}/restore`); return response.data; } catch (error) { console.error('Erro ao restaurar a cobrança:', error); throw error; } } async updateById(id, paymentData) { try { const response = await this.apiClient.post(`/payments/${id}`, paymentData); return response.data; } catch (error) { console.error('Erro ao atualizar a cobrança:', error); throw error; } } async refund(id, refundData) { try { const response = await this.apiClient.post(`/payments/${id}/refund`, refundData); return response.data; } catch (error) { console.error('Erro ao estornar a cobrança:', error); throw error; } } async getIdentificationField(id) { try { const response = await this.apiClient.get(`/payments/${id}/identificationField`); return response.data; } catch (error) { console.error('Erro ao obter a linha digiável do boleto da cobrança:', error); throw error; } } async getPixQrCode(id) { try { const response = await this.apiClient.get(`/payments/${id}/pixQrCode`); return response.data; } catch (error) { console.error('Erro ao obter o QR Code Pix da cobrança:', error); throw error; } } async receiveInCash(id, paymentData) { try { const response = await this.apiClient.post(`/payments/${id}/receiveInCash`, paymentData); return response.data; } catch (error) { console.error('Erro ao confirmar recebimento em dinheiro da cobrança:', error); throw error; } } async undoReceivedInCash(id) { try { const response = await this.apiClient.post(`/payments/${id}/undoReceivedInCash`); return response.data; } catch (error) { console.error('Erro ao desfazer a confirmação de recebimento em dinheiro da cobrança:', error); throw error; } } async limits() { try { const response = await this.apiClient.get(`/payments/limits`); return response.data; } catch (error) { console.error('Erro ao obter os limites diários de cobrança:', error); throw error; } } } exports.PaymentsAPI = PaymentsAPI;