export type GetApiAccountsCustomerIdStatementsArgs = {customerId: string, fromDate: string, toDate: string, 'api-key': string, 'auth-key': string}; export type GetApiAccountsCustomerIdStatementsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * List Monthly Statements * * GET /accounts/{customerId}/statements */ export const getApiAccountsCustomerIdStatements = async (args: GetApiAccountsCustomerIdStatementsArgs, options?: GetApiAccountsCustomerIdStatementsOptions) => { const {baseUrl = "https://uatclientapi-v2.stockal.com/client/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.fromDate != null) query.append("fromDate", String(args.fromDate)) if (args.toDate != null) query.append("toDate", String(args.toDate)) if (args['api-key'] != null) headers.set("api-key", String(args['api-key'])) if (args['auth-key'] != null) headers.set("auth-key", String(args['auth-key'])) const url = `${baseUrl.replace(/\/+$/, '')}/accounts/${encodeURIComponent(String(args.customerId))}/statements${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 (await res.json()) as unknown };