export type UUID = string; export type Day = string; export type LocaleLanguage = 'en' | 'es' | 'fr' | 'it' | 'de' | 'nl'; export type GetApiV0AccountingPositionsAccountStatementArgs = {investorId: UUID, shareClassId: UUID, from: Day, to: Day, locale: LocaleLanguage}; export type GetApiV0AccountingPositionsAccountStatementOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Download account statement * * GET /v0/accounting-positions/account-statement */ export const getApiV0AccountingPositionsAccountStatement = async (args: GetApiV0AccountingPositionsAccountStatementArgs, options?: GetApiV0AccountingPositionsAccountStatementOptions) => { const {baseUrl = "https://distributor-api.spiko.io", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (args.investorId != null) query.append("investorId", String(args.investorId)) if (args.shareClassId != null) query.append("shareClassId", String(args.shareClassId)) if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (args.locale != null) query.append("locale", String(args.locale)) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v0/accounting-positions/account-statement${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.blob() };