export type GetApiV1ApplicationsApplicationIdExportCouponsArgs = {applicationId: number, campaignId?: number | undefined, sort?: string | undefined, value?: string | undefined, createdBefore?: string | undefined, createdAfter?: string | undefined, valid?: ('expired' | 'validNow' | 'validFuture') | undefined, usable?: ('true' | 'false') | undefined, referralId?: number | undefined, recipientIntegrationId?: string | undefined, batchId?: string | undefined, exactMatch?: boolean | undefined, dateFormat?: ('excel' | 'ISO8601') | undefined, campaignState?: ('enabled' | 'disabled' | 'archived' | 'scheduled' | 'running' | 'expired' | 'staged') | undefined, valuesOnly?: boolean | undefined, deletedBefore?: string | undefined, deletedAfter?: string | undefined}; export type GetApiV1ApplicationsApplicationIdExportCouponsOptions = {baseUrl?: string | undefined, managerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export coupons * * GET /v1/applications/{applicationId}/export_coupons * * Also accepts auth: management_key */ export const getApiV1ApplicationsApplicationIdExportCoupons = async (args: GetApiV1ApplicationsApplicationIdExportCouponsArgs, options?: GetApiV1ApplicationsApplicationIdExportCouponsOptions) => { 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.sort != null) query.append("sort", String(args.sort)) if (args.value != null) query.append("value", String(args.value)) 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.referralId != null) query.append("referralId", String(args.referralId)) if (args.recipientIntegrationId != null) query.append("recipientIntegrationId", String(args.recipientIntegrationId)) if (args.batchId != null) query.append("batchId", String(args.batchId)) if (args.exactMatch != null) query.append("exactMatch", String(args.exactMatch)) if (args.dateFormat != null) query.append("dateFormat", String(args.dateFormat)) if (args.campaignState != null) query.append("campaignState", String(args.campaignState)) if (args.valuesOnly != null) query.append("valuesOnly", String(args.valuesOnly)) if (args.deletedBefore != null) query.append("deletedBefore", String(args.deletedBefore)) if (args.deletedAfter != null) query.append("deletedAfter", String(args.deletedAfter)) if (managerAuth !== undefined) headers.set("Authorization", managerAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/applications/${encodeURIComponent(String(args.applicationId))}/export_coupons${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() };