export type PublicAudienceImport = {action?: ('include' | 'exclude') | undefined, email: string, emails?: Array | undefined, list?: string | undefined, sha256?: string | undefined, sha256s?: Array | undefined} | {action?: ('include' | 'exclude') | undefined, email?: string | undefined, emails: Array, list?: string | undefined, sha256?: string | undefined, sha256s?: Array | undefined} | {action?: ('include' | 'exclude') | undefined, email?: string | undefined, emails?: Array | undefined, list?: string | undefined, sha256: string, sha256s?: Array | undefined} | {action?: ('include' | 'exclude') | undefined, email?: string | undefined, emails?: Array | undefined, list?: string | undefined, sha256?: string | undefined, sha256s: Array}; export type CreateApiApi10ImportCustomAudienceArgs = {body: PublicAudienceImport}; export type CreateApiApi10ImportCustomAudienceOptions = {baseUrl: string, webhookApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Import custom audience entries * * POST /api/1.0/import/custom-audience */ export const createApiApi10ImportCustomAudience = async (args: CreateApiApi10ImportCustomAudienceArgs, options: CreateApiApi10ImportCustomAudienceOptions) => { const {baseUrl, fetch: fetchFn = fetch, webhookApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (webhookApiKey !== undefined) headers.set("Authorization", webhookApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/1.0/import/custom-audience${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };