import {z} from 'zod' export type UserProfile = {currencyCode: string, timeZoneSid: string, maxTravelDistanceUnits: string, mobilePhone?: (string | null) | undefined, preferredEmail?: string | undefined, latitude?: (number | null) | undefined, longitude?: (number | null) | undefined, maxTravelDistance?: (number | null) | undefined, homePhone?: (string | null) | undefined, address?: (string | null) | undefined, smarterId?: string | undefined, smarterIdEnrollmentSid?: string | undefined}; export type UpdateApiV1InstallsInstallSidUsersUserSidProfileArgs = {installSid: string, userSid: string, body: UserProfile}; export type UpdateApiV1InstallsInstallSidUsersUserSidProfileOptions = {baseUrl?: string | undefined, client?: string | undefined, fetch?: typeof fetch | undefined}; export const timezone = z.object({}).nullable(); export const authentication = z.object({}).nullable(); export const smarterId = z.object({}).nullable(); export const model28 = z.object({}).nullable(); export const model29 = z.object({}).nullable(); export const identity = z.object({}).nullable(); export const userResponse = z.object({sid: z.string().nullable().optional(), firstName: z.string().nullable().optional(), lastName: z.string().nullable().optional(), email: z.string().nullable().optional(), preferredEmail: z.string().nullable().optional(), username: z.string().nullable().optional(), smarterIdEnrollmentSid: z.string().nullable().optional(), mobilePhone: z.string().nullable().optional(), homePhone: z.string().nullable().optional(), address: z.string().nullable().optional(), lmsId: z.string().nullable().optional(), apiId: z.string().nullable().optional(), sisId: z.string().nullable().optional(), externalId: z.string().nullable().optional(), latitude: z.number().nullable().optional(), longitude: z.number().nullable().optional(), lastEnrollmentSync: z.string().nullable().optional(), currencyCode: z.string().nullable().optional(), timeZoneSid: z.string().nullable().optional(), timezone: timezone.optional(), maxTravelDistance: z.number().nullable().optional(), maxTravelDistanceUnits: z.string().nullable().optional(), createdDate: z.string().nullable().optional(), editDate: z.string().nullable().optional(), freshdeskUserId: z.string().nullable().optional(), role: z.string().nullable().optional(), enabled: z.boolean().nullable().optional(), authentication: authentication.optional(), smarterId: smarterId.optional(), course: model28.optional(), exam: model29.optional(), identity: identity.optional()}); 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 }; /** * Update User Profile * * PUT /v1/installs/{installSid}/users/{userSid}/profile */ export const updateApiV1InstallsInstallSidUsersUserSidProfile = async (args: UpdateApiV1InstallsInstallSidUsersUserSidProfileArgs, options?: UpdateApiV1InstallsInstallSidUsersUserSidProfileOptions) => { const {baseUrl = "https://api.smarterproctoring.com", fetch: fetchFn = fetch, client} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (client !== undefined) headers.set("token", client) const url = `${baseUrl.replace(/\/+$/, '')}/v1/installs/${encodeURIComponent(String(args.installSid))}/users/${encodeURIComponent(String(args.userSid))}/profile${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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(userResponse, await res.json()) };