deno.land / x / gesso@v0.1.2 / src / AccountReports.ts
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697import { BaseApi } from "./BaseApi.ts";import { Configuration } from "./Configuration.ts";import { Grade, Report } from "../types/models.ts";import { StartReportParams } from "../types/params.ts";
export class AccountReports extends BaseApi { constructor(config: Configuration) { super(config); }
public async listAvailableReports( account_id: string, body?: unknown, ): Promise<Grade> { const endpoint = `/api/v1/accounts/${account_id}/reports`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Grade; }
return Promise.reject(response); }
public async startReport( account_id: string, report: string, params?: StartReportParams, body?: unknown, ): Promise<Report> { const endpoint = `/api/v1/accounts/${account_id}/reports/${report}`; const url = new URL(endpoint, this.configuration.domain); if (params !== undefined) { for (const [key, value] of Object.entries(params)) { url.searchParams.set(key, JSON.stringify(value)); } } const response = await this.post(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Report; }
return Promise.reject(response); }
public async indexOfReports( account_id: string, report: string, body?: unknown, ): Promise<Report[]> { const endpoint = `/api/v1/accounts/${account_id}/reports/${report}`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Report[]; }
return Promise.reject(response); }
public async statusOfReport( account_id: string, report: string, id: string, body?: unknown, ): Promise<Report> { const endpoint = `/api/v1/accounts/${account_id}/reports/${report}/${id}`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.get(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Report; }
return Promise.reject(response); }
public async deleteReport( account_id: string, report: string, id: string, body?: unknown, ): Promise<Report> { const endpoint = `/api/v1/accounts/${account_id}/reports/${report}/${id}`; const url = new URL(endpoint, this.configuration.domain);
const response = await this.delete(url, JSON.stringify(body)); if (response.ok) { return await response.json() as Report; }
return Promise.reject(response); }}
Version Info