export type GetApiPaymentBatchTemplateArgs = {accept: 'text/csv'}; export type GetApiPaymentBatchTemplateOptions = {baseUrl?: string | undefined, CommonAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download blank template csv * * GET /payment-batch-template */ export const getApiPaymentBatchTemplate = async (args: GetApiPaymentBatchTemplateArgs, options?: GetApiPaymentBatchTemplateOptions) => { const {baseUrl = "https://api.equalsmoney.com/v2", fetch: fetchFn = fetch, CommonAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.accept != null) headers.set("accept", String(args.accept)) if (CommonAuth !== undefined) headers.set("Authorization", CommonAuth) const url = `${baseUrl.replace(/\/+$/, '')}/payment-batch-template${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() };