export type GetApiV1GiveawaysPoolsPoolIdExportArgs = {poolId: number, createdBefore?: string | undefined, createdAfter?: string | undefined}; export type GetApiV1GiveawaysPoolsPoolIdExportOptions = {baseUrl?: string | undefined, managerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export giveaway codes of a giveaway pool * * GET /v1/giveaways/pools/{poolId}/export * * Also accepts auth: management_key */ export const getApiV1GiveawaysPoolsPoolIdExport = async (args: GetApiV1GiveawaysPoolsPoolIdExportArgs, options?: GetApiV1GiveawaysPoolsPoolIdExportOptions) => { 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.createdBefore != null) query.append("createdBefore", String(args.createdBefore)) if (args.createdAfter != null) query.append("createdAfter", String(args.createdAfter)) if (managerAuth !== undefined) headers.set("Authorization", managerAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/giveaways/pools/${encodeURIComponent(String(args.poolId))}/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() };