export type NotificationTemplatePublishRequest = {version?: string | undefined}; export type CreateApiNotificationsIdPublishArgs = {'Idempotency-Key'?: string | undefined, 'x-idempotency-expiration'?: string | undefined, id: string, body: NotificationTemplatePublishRequest}; export type CreateApiNotificationsIdPublishOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Publish Notification Template * * POST /notifications/{id}/publish */ export const createApiNotificationsIdPublish = async (args: CreateApiNotificationsIdPublishArgs, options?: CreateApiNotificationsIdPublishOptions) => { const {baseUrl = "https://api.courier.com", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Idempotency-Key'] != null) headers.set("Idempotency-Key", String(args['Idempotency-Key'])) if (args['x-idempotency-expiration'] != null) headers.set("x-idempotency-expiration", String(args['x-idempotency-expiration'])) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/notifications/${encodeURIComponent(String(args.id))}/publish${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 };