export type GetApiV1LoyaltyProgramsLoyaltyProgramIdCardsExportArgs = {loyaltyProgramId: number, batchId?: string | undefined, createdBefore?: string | undefined, createdAfter?: string | undefined, dateFormat?: ('excel' | 'ISO8601') | undefined}; export type GetApiV1LoyaltyProgramsLoyaltyProgramIdCardsExportOptions = {baseUrl?: string | undefined, managerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export loyalty cards * * GET /v1/loyalty_programs/{loyaltyProgramId}/cards/export * * Also accepts auth: management_key */ export const getApiV1LoyaltyProgramsLoyaltyProgramIdCardsExport = async (args: GetApiV1LoyaltyProgramsLoyaltyProgramIdCardsExportArgs, options?: GetApiV1LoyaltyProgramsLoyaltyProgramIdCardsExportOptions) => { 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.batchId != null) query.append("batchId", String(args.batchId)) if (args.createdBefore != null) query.append("createdBefore", String(args.createdBefore)) if (args.createdAfter != null) query.append("createdAfter", String(args.createdAfter)) if (args.dateFormat != null) query.append("dateFormat", String(args.dateFormat)) if (managerAuth !== undefined) headers.set("Authorization", managerAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/loyalty_programs/${encodeURIComponent(String(args.loyaltyProgramId))}/cards/export${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() };