UNPKG

@matheustrres/brasilapi

Version:

Lightweight, easy-to-use & free of dependencies wrapper for BrasilAPI

41 lines 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BrasilAPIBank = void 0; const source_1 = require("./source"); const http_client_1 = require("../clients/http-client"); const paginator_1 = require("../utils/paginator"); /** * Represents the source from BrasilAPI Banks' endpoint responses */ class BrasilAPIBank extends source_1.Source { URL = 'https://brasilapi.com.br/api/banks/v1'; /** * Gets information from a bank using a code * * @param {String} code - The bank code * @returns {Promise<Result<Bank>>} */ async get(code) { const res = await (0, http_client_1.makeGET)(`${this.URL}/${code}`); return this.followUp(res); } /** * Lists all banks in Brazil * * @param {ListParams} [params] - The listing parameters * @param {Number} [params.itemsPerPage] - The limit of items per page * @param {Number} [params.page] - The page number to start with * @param {Number} [params.skip] - The amount of items to skip * @param {Number} [params.take] - The amount of items to take * @returns {Promise<Result<Paginator<Bank>>>} */ async list(params) { const res = await (0, http_client_1.makeGET)(this.URL); return this.followUp(new paginator_1.Paginator({ items: res, ...params, })); } } exports.BrasilAPIBank = BrasilAPIBank; //# sourceMappingURL=bank.js.map