export type ApiPersonalizationValue = {name?: (string | null) | undefined, value?: (string | null) | undefined}; export type ApiTransactionalEmailAttachment = {fileName?: (string | null) | undefined, content?: (string | null) | undefined, mimeType?: (string | null) | undefined}; export type ApiTransactionalEmailTriggeredCampaign = {toAddresses?: (Array | null) | undefined, ccAddresses?: (Array | null) | undefined, bccAddresses?: (Array | null) | undefined, campaignId?: number | undefined, personalizationValues?: (Array | null) | undefined, metadata?: (string | null) | undefined, fromAddress?: (string | null) | undefined, attachments?: (Array | null) | undefined}; export type CreateApiV2EmailTriggeredCampaignBatchArgs = {body: Array}; export type CreateApiV2EmailTriggeredCampaignBatchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Sends one or more transactional emails with content for each taken from a triggered campaign. If sending to multiple recipients, please separate addresses with a comma. * * POST /v2/email/triggered-campaign/batch */ export const createApiV2EmailTriggeredCampaignBatch = async (args: CreateApiV2EmailTriggeredCampaignBatchArgs, options?: CreateApiV2EmailTriggeredCampaignBatchOptions) => { const {baseUrl = "https://api.dotdigital.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/octet-stream") const url = `${baseUrl.replace(/\/+$/, '')}/v2/email/triggered-campaign/batch${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 res.blob() };