export type GetApiV1ApplicationsApplicationIdExportReferralsArgs = {applicationId: number, campaignId?: number | undefined, createdBefore?: string | undefined, createdAfter?: string | undefined, valid?: ('expired' | 'validNow' | 'validFuture') | undefined, usable?: ('true' | 'false') | undefined, batchId?: string | undefined, dateFormat?: ('excel' | 'ISO8601') | undefined}; export type GetApiV1ApplicationsApplicationIdExportReferralsOptions = {baseUrl?: string | undefined, managerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export referrals * * GET /v1/applications/{applicationId}/export_referrals * * Also accepts auth: management_key */ export const getApiV1ApplicationsApplicationIdExportReferrals = async (args: GetApiV1ApplicationsApplicationIdExportReferralsArgs, options?: GetApiV1ApplicationsApplicationIdExportReferralsOptions) => { const {baseUrl = "https://yourbaseurl.talon.one", fetch: fetchFn = fetch, managerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/csv") if (args.campaignId != null) query.append("campaignId", String(args.campaignId)) if (args.createdBefore != null) query.append("createdBefore", String(args.createdBefore)) if (args.createdAfter != null) query.append("createdAfter", String(args.createdAfter)) if (args.valid != null) query.append("valid", String(args.valid)) if (args.usable != null) query.append("usable", String(args.usable)) if (args.batchId != null) query.append("batchId", String(args.batchId)) if (args.dateFormat != null) query.append("dateFormat", String(args.dateFormat)) if (managerAuth !== undefined) headers.set("Authorization", managerAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/applications/${encodeURIComponent(String(args.applicationId))}/export_referrals${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() };