@matheustrres/brasilapi
Version:
Lightweight, easy-to-use & free of dependencies wrapper for BrasilAPI
41 lines • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BrasilAPIBroker = 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 Brokers' endpoint responses
*/
class BrasilAPIBroker extends source_1.Source {
URL = 'https://brasilapi.com.br/api/cvm/corretoras/v1';
/**
* Gets information from a broker in the CVM archives
*
* @param {String} cnpj - The broker's CNPJ
* @returns {Promise<Result<Broker>>}
*/
async get(cnpj) {
const res = await (0, http_client_1.makeGET)(`${this.URL}/${cnpj}`);
return this.followUp(res);
}
/**
* Lists all the brokers in the CVM archives
*
* @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<Broker>>>}
*/
async list(params) {
const res = await (0, http_client_1.makeGET)(this.URL);
return this.followUp(new paginator_1.Paginator({
items: res,
...params,
}));
}
}
exports.BrasilAPIBroker = BrasilAPIBroker;
//# sourceMappingURL=broker.js.map