export type GetApiOrganizationsOrgIdStatementsStatementIdCsvArgs = {orgId: number, statementId: number}; export type GetApiOrganizationsOrgIdStatementsStatementIdCsvOptions = {baseUrl?: string | undefined, apiKeyAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Download a billing statement as a CSV file * * GET /organizations/{orgId}/statements/{statementId}/csv */ export const getApiOrganizationsOrgIdStatementsStatementIdCsv = async (args: GetApiOrganizationsOrgIdStatementsStatementIdCsvArgs, options?: GetApiOrganizationsOrgIdStatementsStatementIdCsvOptions) => { const {baseUrl = "https://dashboard.hologram.io/api/1", fetch: fetchFn = fetch, apiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (apiKeyAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${apiKeyAuth.username}:${apiKeyAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/organizations/${encodeURIComponent(String(args.orgId))}/statements/${encodeURIComponent(String(args.statementId))}/csv${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };