export type CreateApi30CampaignsCampaignIdActionsTestArgs = {campaign_id: string, body: {send_type: 'html' | 'plaintext', test_emails: Array}}; export type CreateApi30CampaignsCampaignIdActionsTestOptions = {baseUrl?: string | undefined, bearerToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send test email * * POST /3.0/campaigns/{campaign_id}/actions/test * * Also accepts auth: oauth2 */ export const createApi30CampaignsCampaignIdActionsTest = async (args: CreateApi30CampaignsCampaignIdActionsTestArgs, options?: CreateApi30CampaignsCampaignIdActionsTestOptions) => { const {baseUrl = "https://api.mailchimp.com", fetch: fetchFn = fetch, bearerToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerToken !== undefined) headers.set('authorization', `Bearer ${bearerToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/3.0/campaigns/${encodeURIComponent(String(args.campaign_id))}/actions/test${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 };