UNPKG

asaaas

Version:

Unofficial Asaas Payment Gateway SDK

66 lines (65 loc) 2.49 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AsaasClient = void 0; const axios_1 = __importDefault(require("axios")); const Customers_1 = require("./Customers"); const Installments_1 = require("./Installments"); const Payments_1 = require("./Payments"); const Subscriptions_1 = require("./Subscriptions"); const Webhooks_1 = require("./Webhooks"); const PixTransactions_1 = require("./PixTransactions"); const PixQrCodes_1 = require("./PixQrCodes"); const Invoices_1 = require("./Invoices"); const Bill_1 = require("./Bill"); const Transfers_1 = require("./Transfers"); const MyAccount_1 = require("./MyAccount"); const Accounts_1 = require("./Accounts"); class AsaasClient { apiKey; customers; payments; installments; subscriptions; webhooks; pixTransactions; pixQrCodes; invoices; bill; transfers; myAccount; accounts; constructor(apiKey, options = {}) { this.apiKey = apiKey; const apiClient = axios_1.default.create({ baseURL: this.getUrl(options), headers: { common: { 'User-Agent': options.userAgent ?? 'npm/asaas', access_token: this.apiKey, }, }, }); this.customers = new Customers_1.CustomersAPI(apiClient); this.payments = new Payments_1.PaymentsAPI(apiClient); this.installments = new Installments_1.InstallmentsAPI(apiClient); this.subscriptions = new Subscriptions_1.SubscriptionsAPI(apiClient); this.webhooks = new Webhooks_1.WebhooksAPI(apiClient); this.pixTransactions = new PixTransactions_1.PixTransactionsAPI(apiClient); this.pixQrCodes = new PixQrCodes_1.PixQrCodesAPI(apiClient); this.invoices = new Invoices_1.InvoicesAPI(apiClient); this.bill = new Bill_1.BillAPI(apiClient); this.transfers = new Transfers_1.TransfersAPI(apiClient); this.myAccount = new MyAccount_1.MyAccountAPI(apiClient); this.accounts = new Accounts_1.AccountsAPI(apiClient); } getUrl(options = {}) { if (options.sandbox) { return options.sandboxUrl || 'https://sandbox.asaas.com/api/v3'; } return options.baseUrl || 'https://api.asaas.com/v3'; } } exports.AsaasClient = AsaasClient;