export type GetApiV1BillsIdUsageCsvArgs = {id: number}; export type GetApiV1BillsIdUsageCsvOptions = {baseUrl?: string | undefined, basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Download usage export file * * GET /v1/Bills/{id}/usage/csv */ export const getApiV1BillsIdUsageCsv = async (args: GetApiV1BillsIdUsageCsvArgs, options?: GetApiV1BillsIdUsageCsvOptions) => { const {baseUrl = "https://restapi.rev.io", fetch: fetchFn = fetch, basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (basic !== undefined) headers.set('authorization', `Basic ${btoa(`${basic.username}:${basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/Bills/${encodeURIComponent(String(args.id))}/usage/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 undefined };