export type NotificationFormById = {userIds: Array, message: string}; export type NotificationFormByRoleInProject = {role: 'owner' | 'manager', message: string}; export type CreateApiProjectsProjectIdNotifyArgs = {projectId: number, body: NotificationFormById | NotificationFormByRoleInProject}; export type CreateApiProjectsProjectIdNotifyOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send Notification To Project Members * * POST /projects/{projectId}/notify */ export const createApiProjectsProjectIdNotify = async (args: CreateApiProjectsProjectIdNotifyArgs, options?: CreateApiProjectsProjectIdNotifyOptions) => { const {baseUrl = "https://api.crowdin.com/api/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/projects/${encodeURIComponent(String(args.projectId))}/notify${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 };