export type UserMessageResponseAction = 'ACCEPT' | 'DISMISS'; export type CreateApiUsersUserIdMessagesMessageIdArgs = {userId: number, messageId: number, body: {properties?: (string | null) | undefined, action: UserMessageResponseAction}}; export type CreateApiUsersUserIdMessagesMessageIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /users/{userId}/messages/{messageId} */ export const createApiUsersUserIdMessagesMessageId = async (args: CreateApiUsersUserIdMessagesMessageIdArgs, options: CreateApiUsersUserIdMessagesMessageIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/users/${encodeURIComponent(String(args.userId))}/messages/${encodeURIComponent(String(args.messageId))}${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 };