UNPKG

asaas

Version:

Unofficial Asaas Payment Gateway SDK

65 lines (64 loc) 2.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SubscriptionsAPI = void 0; const BaseAPI_1 = require("./BaseAPI"); class SubscriptionsAPI extends BaseAPI_1.BaseAPI { constructor(apiClient, options = {}) { super(apiClient, options); } async create(params) { try { const response = await this.apiClient.post('/subscriptions', params); return response.data; } catch (error) { return this.handleError(error, 'Erro ao criar uma nova assinatura:'); } } async list(params) { try { const response = await this.apiClient.get('/subscriptions', { params }); return response.data; } catch (error) { return this.handleError(error, 'Erro ao obter a lista de assinaturas:'); } } async getById(id) { try { const response = await this.apiClient.get(`/subscriptions/${id}`); return response.data; } catch (error) { return this.handleError(error, 'Erro ao obter a assinatura:'); } } async getPayments(id) { try { const response = await this.apiClient.get(`/subscriptions/${id}/payments`); return response.data; } catch (error) { return this.handleError(error, 'Erro ao obter as cobranças da assinatura:'); } } async delete(id) { try { const response = await this.apiClient.delete(`/subscriptions/${id}`); return response.data; } catch (error) { return this.handleError(error, 'Erro ao deletar a assinatura:'); } } async updateById(id, params) { try { const response = await this.apiClient.post(`/subscriptions/${id}`, params); return response.data; } catch (error) { return this.handleError(error, 'Erro ao atualizar a assinatura:'); } } } exports.SubscriptionsAPI = SubscriptionsAPI;