import type Client from '../Client' ; import ResourceList from '../ResourceList' ; import Election , { HttpElectionObject } from '../models/Election' ; interface ListParams { cursor ? : string ; } export default class Elections { private client ! : Client ; 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 ( d ) ) ; return new ResourceList ( data , this . list . bind ( this ) , cursor ) ; } async get ( hash ) { const url = `/transactions/${ hash }` ; const { data : { data : election } , } = await this . client . get ( url ) ; return election ; } }