export type NotificationCommonElementType = 'UNSUBSCRIBE'; export type NotificationCommonEmailElementWS = {content: string, defaultCommonElement?: boolean | undefined, enabled?: boolean | undefined, id?: number | undefined, locale: string, partner?: string | undefined, type: NotificationCommonElementType}; export type CreateApiNotificationV1TemplatesDefaultCommonEmailArgs = {body: NotificationCommonEmailElementWS}; export type CreateApiNotificationV1TemplatesDefaultCommonEmailOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create or update a default common email template element. * * POST /notification/v1/templates/default/common/email */ export const createApiNotificationV1TemplatesDefaultCommonEmail = async (args: CreateApiNotificationV1TemplatesDefaultCommonEmailArgs, options?: CreateApiNotificationV1TemplatesDefaultCommonEmailOptions) => { const {baseUrl = "https://marketplace.appdirect.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/notification/v1/templates/default/common/email${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 };