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 CreateApiApi10ImportSuppressionArgs = {body: PublicAudienceImport}; export type CreateApiApi10ImportSuppressionOptions = {baseUrl: string, webhookApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Import suppression entries * * POST /api/1.0/import/suppression */ export const createApiApi10ImportSuppression = async (args: CreateApiApi10ImportSuppressionArgs, options: CreateApiApi10ImportSuppressionOptions) => { 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/suppression${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 };