import { API , DEFAULT_API_OPTIONS } from '../core/api' ; import { ApiOptions , Block , BlockList } from '../models' ; import Threads from './threads' ; const dot = '%2E' ; extends API export default class Blocks extends API { threads : Threads ; constructor ( opts = DEFAULT_API_OPTIONS ) { super ( opts ) ; this . threads = new Threads ( opts ) ; } param id returns async meta ( id ) { const response = await this . sendGet ( `blocks/${ id }/meta` ) ; return response . json ( ) as Promise < Block > ; } param thread param offset param limit returns async list ( thread ? , offset ? , limit ? ) { const response = await this . sendGet ( 'blocks' , undefined , { thread : thread || '' , offset : offset || '' , limit : limit || 5 } ) ; return response . json ( ) as Promise < BlockList > ; } param id returns async ignore ( id ) { const response = await this . sendDelete ( `blocks/${ id }` ) ; return response . json ( ) as Promise < Block > ; } param id param index param path returns async fileContent ( id , index ? , path ? ) { const response = await this . sendGet ( `blocks/${ id }/files/${ index || '0' }/${ path || dot }/content` ) ; return response . arrayBuffer ( ) ; } param id param index param path returns async fileMeta ( id , index ? , path ? ) { const response = await this . sendGet ( `blocks/${ id }/files/${ index || '0' }/${ path || dot }/meta` ) ; return response . arrayBuffer ( ) ; } }