import {z} from 'zod' export type EmployeeWithoutCompanyDetails = {id?: string | undefined, name: string, avatar_image?: (string | null) | undefined, email: string, slack_uid: string | null, role?: (string | null) | undefined, company?: string | undefined, user?: string | undefined, is_admin?: boolean | undefined, is_manager?: string | undefined, points?: number | undefined, level?: string | undefined}; export type QuizQuestionAnswer = {id?: string | undefined, created?: string | undefined, modified?: string | undefined, answer: string, position?: number | undefined, correct?: (boolean | null) | undefined, explanation?: (string | null) | undefined, question?: string | undefined}; export type LessonImageInLessonSerializers = {id?: string | undefined, company?: (string | null) | undefined, image_name?: (string | null) | undefined, image_url?: (string | null) | undefined, image_url_public?: (string | null) | undefined, editor_content?: (string | null) | undefined, content_type?: ('lesson' | 'quiz' | 'engagement_question' | 'engagement_message' | 'assessment_question_content' | null) | undefined}; export type EditorStateInLessonSerializers = {id?: string | undefined, note_editor_state?: (string | null) | undefined, summary_editor_state?: (string | null) | undefined, question_editor_state?: (string | null) | undefined, quiz_editor_state?: (string | null) | undefined, quiz_message_state?: (string | null) | undefined, content: Array}; export type CustomEngagementQuestionVideo = {id?: string | undefined, engagement_question?: (string | null) | undefined, service_id?: number | undefined, name: string, duration?: number | undefined, hashed_id?: string | undefined, progress: unknown, thumbnail: string, processed?: boolean | undefined, plays?: number | undefined}; export type QuizQuestion = {id?: string | undefined, answers?: Array | undefined, editor_content?: EditorStateInLessonSerializers | undefined, quiz_question_context?: string | undefined, engagement_custom_video?: Array | undefined, created?: string | undefined, modified?: string | undefined, position?: number | undefined, answer_type?: ('no_action' | 'user_acknowledged' | 'multiple_choice' | 'neutral' | 'written_response' | 'external_url' | null) | undefined, external_url?: (string | null) | undefined, external_url_btn_text?: (string | null) | undefined, single_select?: boolean | undefined, quiz?: string | undefined}; export type ChannelEngagement = {id?: string | undefined, created?: string | undefined, modified?: string | undefined, video_ts?: (string | null) | undefined, message_ts: string, channel: string, schedule_id?: string | undefined, engagement: string}; export type WeeklyQuiz = {id?: string | undefined, title?: (string | null) | undefined, company?: (string | null) | undefined, engagement_type?: ('private' | 'channel') | undefined, mention_channel?: boolean | undefined, channel?: (string | null) | undefined, questions?: Array | undefined, channel_engagements: Array, anonymize_user_results?: boolean | undefined}; export type Owner = {id: string, name: string}; export type ContentImage = {id?: string | undefined, company?: (string | null) | undefined, image_name?: (string | null) | undefined, image_url?: (string | null) | undefined, image_url_public?: (string | null) | undefined, editor_content?: (string | null) | undefined}; export type RichTextEditorState = {id?: string | undefined, editor_state?: (string | null) | undefined, content?: Array | undefined}; export type EngagementWelcomeMessage = {id?: string | undefined, editor_content: RichTextEditorState, created?: string | undefined, modified?: string | undefined, enabled?: boolean | undefined, slack_markup?: (string | null) | undefined, button_text?: string | undefined, polymorphic_ctype?: number | undefined, engagement: string}; export type EngagementClosingMessage = {id?: string | undefined, editor_content: RichTextEditorState, created?: string | undefined, modified?: string | undefined, enabled?: boolean | undefined, slack_markup?: (string | null) | undefined, show_review_option?: boolean | undefined, polymorphic_ctype?: number | undefined, engagement: string}; export type CompanyWeeklyQuiz = {id?: string | undefined, quiz: WeeklyQuiz, next_renew_date?: string | undefined, start_date_for_dynamic_engagement?: string | undefined, owners?: Array | undefined, welcome_message: EngagementWelcomeMessage, closing_message: EngagementClosingMessage, created?: string | undefined, modified?: string | undefined, active?: boolean | undefined, start_date?: (string | null) | undefined, channels?: Array | undefined, okta_groups_sync?: Array | undefined, auto_enroll?: boolean | undefined, send_cycle?: ('once' | 'weekly' | 'monthly' | 'quarterly' | 'semi-annual' | 'annual') | undefined, respect_users_tz?: boolean | undefined, company: string, created_by?: (string | null) | undefined}; export type EmployeeWeeklyQuestion = {id?: string | undefined, created?: string | undefined, modified?: string | undefined, finished?: boolean | undefined, correct?: boolean | undefined, finish_date?: (string | null) | undefined, answers?: (Record | null) | undefined, written_answer?: (string | null) | undefined, acknowledged?: boolean | undefined, employee_quiz?: (string | null) | undefined, question?: (string | null) | undefined}; export type EmployeeWeekly = {id?: string | undefined, employee: EmployeeWithoutCompanyDetails, weekly: CompanyWeeklyQuiz, finished?: string | undefined, active?: boolean | undefined, active_question: string | null, questions: Array}; export type CreateApiApiEmployeesQuizzesEngagementIdSendReminderArgs = {body: EmployeeWeekly}; export type CreateApiApiEmployeesQuizzesEngagementIdSendReminderOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const employeeWithoutCompanyDetails = z.object({id: z.string().optional(), name: z.string().min(1).max(80), avatar_image: z.string().max(200).nullable().optional(), email: z.string().min(1).max(254), slack_uid: z.string().max(254).nullable(), role: z.string().nullable().optional(), company: z.string().optional(), user: z.string().optional(), is_admin: z.boolean().optional(), is_manager: z.string().optional(), points: z.number().int().gte(-2147483648).lte(2147483647).optional(), level: z.string().optional()}); export const quizQuestionAnswer = z.object({id: z.string().optional(), created: z.string().optional(), modified: z.string().optional(), answer: z.string().min(1).max(150), position: z.number().int().gte(-32768).lte(32767).optional(), correct: z.boolean().nullable().optional(), explanation: z.string().nullable().optional(), question: z.string().optional()}); export const lessonImageInLessonSerializers = z.object({id: z.string().optional(), company: z.string().nullable().optional(), image_name: z.string().max(200).nullable().optional(), image_url: z.string().nullable().optional(), image_url_public: z.string().nullable().optional(), editor_content: z.string().nullable().optional(), content_type: z.enum(["lesson", "quiz", "engagement_question", "engagement_message", "assessment_question_content"]).nullable().optional()}); export const editorStateInLessonSerializers = z.object({id: z.string().optional(), note_editor_state: z.string().nullable().optional(), summary_editor_state: z.string().nullable().optional(), question_editor_state: z.string().nullable().optional(), quiz_editor_state: z.string().nullable().optional(), quiz_message_state: z.string().nullable().optional(), content: z.array(lessonImageInLessonSerializers)}); export const customEngagementQuestionVideo = z.object({id: z.string().optional(), engagement_question: z.string().nullable().optional(), service_id: z.number().int().optional(), name: z.string().min(1).max(300), duration: z.number().int().optional(), hashed_id: z.string().optional(), progress: z.string(), thumbnail: z.string().min(1).max(500), processed: z.boolean().optional(), plays: z.number().int().gte(-2147483648).lte(2147483647).optional()}); export const quizQuestion = z.object({id: z.string().optional(), answers: z.array(quizQuestionAnswer).optional(), editor_content: editorStateInLessonSerializers.optional(), quiz_question_context: z.string().optional(), engagement_custom_video: z.array(customEngagementQuestionVideo).optional(), created: z.string().optional(), modified: z.string().optional(), position: z.number().int().gte(-32768).lte(32767).optional(), answer_type: z.enum(["no_action", "user_acknowledged", "multiple_choice", "neutral", "written_response", "external_url"]).nullable().optional(), external_url: z.string().max(200).nullable().optional(), external_url_btn_text: z.string().nullable().optional(), single_select: z.boolean().optional(), quiz: z.string().optional()}); export const channelEngagement = z.object({id: z.string().optional(), created: z.string().optional(), modified: z.string().optional(), video_ts: z.string().max(30).nullable().optional(), message_ts: z.string().min(1).max(30), channel: z.string().min(1).max(20), schedule_id: z.string().max(50).optional(), engagement: z.string()}); export const weeklyQuiz = z.object({id: z.string().optional(), title: z.string().max(200).nullable().optional(), company: z.string().nullable().optional(), engagement_type: z.enum(["private", "channel"]).optional(), mention_channel: z.boolean().optional(), channel: z.string().min(1).max(20).nullable().optional(), questions: z.array(quizQuestion).optional(), channel_engagements: z.array(channelEngagement), anonymize_user_results: z.boolean().optional()}); export const owner = z.object({id: z.string(), name: z.string().min(1)}); export const contentImage = z.object({id: z.string().optional(), company: z.string().nullable().optional(), image_name: z.string().max(200).nullable().optional(), image_url: z.string().nullable().optional(), image_url_public: z.string().nullable().optional(), editor_content: z.string().nullable().optional()}); export const richTextEditorState = z.object({id: z.string().optional(), editor_state: z.string().nullable().optional(), content: z.array(contentImage).optional()}); export const engagementWelcomeMessage = z.object({id: z.string().optional(), editor_content: richTextEditorState, created: z.string().optional(), modified: z.string().optional(), enabled: z.boolean().optional(), slack_markup: z.string().nullable().optional(), button_text: z.string().min(1).max(50).optional(), polymorphic_ctype: z.number().int().optional(), engagement: z.string()}); export const engagementClosingMessage = z.object({id: z.string().optional(), editor_content: richTextEditorState, created: z.string().optional(), modified: z.string().optional(), enabled: z.boolean().optional(), slack_markup: z.string().nullable().optional(), show_review_option: z.boolean().optional(), polymorphic_ctype: z.number().int().optional(), engagement: z.string()}); export const companyWeeklyQuiz = z.object({id: z.string().optional(), quiz: weeklyQuiz, next_renew_date: z.string().optional(), start_date_for_dynamic_engagement: z.string().optional(), owners: z.array(owner).optional(), welcome_message: engagementWelcomeMessage, closing_message: engagementClosingMessage, created: z.string().optional(), modified: z.string().optional(), active: z.boolean().optional(), start_date: z.string().nullable().optional(), channels: z.array(z.string().min(1).max(100)).optional(), okta_groups_sync: z.array(z.string().min(1).max(200)).optional(), auto_enroll: z.boolean().optional(), send_cycle: z.enum(["once", "weekly", "monthly", "quarterly", "semi-annual", "annual"]).optional(), respect_users_tz: z.boolean().optional(), company: z.string(), created_by: z.string().nullable().optional()}); export const employeeWeeklyQuestion = z.object({id: z.string().optional(), created: z.string().optional(), modified: z.string().optional(), finished: z.boolean().optional(), correct: z.boolean().optional(), finish_date: z.string().nullable().optional(), answers: z.object({}).nullable().optional(), written_answer: z.string().nullable().optional(), acknowledged: z.boolean().optional(), employee_quiz: z.string().nullable().optional(), question: z.string().nullable().optional()}); export const employeeWeekly = z.object({id: z.string().optional(), employee: employeeWithoutCompanyDetails, weekly: companyWeeklyQuiz, finished: z.string().optional(), active: z.boolean().optional(), active_question: z.string().nullable(), questions: z.array(employeeWeeklyQuestion)}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * POST /api/employees/quizzes/{engagement_id}/send_reminder */ export const createApiApiEmployeesQuizzesEngagementIdSendReminder = async (args: CreateApiApiEmployeesQuizzesEngagementIdSendReminderArgs, options?: CreateApiApiEmployeesQuizzesEngagementIdSendReminderOptions) => { const {baseUrl = "https://app.haekka.com", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/api/employees/quizzes/${encodeURIComponent(String(args.engagement_id))}/send_reminder${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 validateResponse(employeeWeekly, await res.json()) };