export type JourneyTemplatePublishRequest = {version?: string | undefined}; export type CreateApiJourneysTemplateIdTemplatesNotificationIdPublishArgs = {'Idempotency-Key'?: string | undefined, 'x-idempotency-expiration'?: string | undefined, templateId: string, notificationId: string, body: JourneyTemplatePublishRequest}; export type CreateApiJourneysTemplateIdTemplatesNotificationIdPublishOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Publish a journey-scoped notification template * * POST /journeys/{templateId}/templates/{notificationId}/publish */ export const createApiJourneysTemplateIdTemplatesNotificationIdPublish = async (args: CreateApiJourneysTemplateIdTemplatesNotificationIdPublishArgs, options?: CreateApiJourneysTemplateIdTemplatesNotificationIdPublishOptions) => { 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(/\/+$/, '')}/journeys/${encodeURIComponent(String(args.templateId))}/templates/${encodeURIComponent(String(args.notificationId))}/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 };