export type CreateApiAccountsAccountIdAutomationsAutomationIdTriggerArgs = {'X-PhraseApp-OTP'?: string | undefined, account_id: string, id: string}; export type CreateApiAccountsAccountIdAutomationsAutomationIdTriggerOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Trigger an automation * * POST /accounts/{account_id}/automations/{automation_id}/trigger */ export const createApiAccountsAccountIdAutomationsAutomationIdTrigger = async (args: CreateApiAccountsAccountIdAutomationsAutomationIdTriggerArgs, options?: CreateApiAccountsAccountIdAutomationsAutomationIdTriggerOptions) => { const {baseUrl = "https://eu.phrase.com/control-hub", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['X-PhraseApp-OTP'] != null) headers.set("X-PhraseApp-OTP", String(args['X-PhraseApp-OTP'])) const url = `${baseUrl.replace(/\/+$/, '')}/accounts/${encodeURIComponent(String(args.account_id))}/automations/${encodeURIComponent(String(args.automation_id))}/trigger${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };