@helium/http
Version:
HTTP library for interacting with the Helium blockchain API
27 lines • 1.12 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ResourceList_1 = __importDefault(require("../ResourceList"));
const Election_1 = __importDefault(require("../models/Election"));
class Elections {
constructor(client) {
this.client = client;
}
async list(params = {}) {
const url = '/elections';
const response = await this.client.get(url, { cursor: params.cursor });
const { data: { data: elections, cursor }, } = response;
const data = elections.map((d) => new Election_1.default(d));
return new ResourceList_1.default(data, this.list.bind(this), cursor);
}
async get(hash) {
// using transactions api for lookup, there is no /elections/hash endpoint
const url = `/transactions/${hash}`;
const { data: { data: election }, } = await this.client.get(url);
return election;
}
}
exports.default = Elections;
//# sourceMappingURL=Elections.js.map