import {z} from 'zod' export type AllQuietApiAuthenticationModelsPhoneNumberConfirmation = {phoneNumber?: (string | null) | undefined, confirmedAt?: (string | null) | undefined, requestedAt?: (string | null) | undefined, confirmationCode?: (string | null) | undefined, type?: (string | null) | undefined}; export type AllQuietApiAuthenticationModelsIncidentNotificationSettings = {shouldSendSMS?: (boolean | null) | undefined, delayInMinSMS?: (number | null) | undefined, severitiesSMS?: (Array | null) | undefined, shouldCallVoice?: (boolean | null) | undefined, delayInMinVoice?: (number | null) | undefined, severitiesVoice?: (Array | null) | undefined, shouldSendPush?: (boolean | null) | undefined, delayInMinPush?: (number | null) | undefined, severitiesPush?: (Array | null) | undefined, shouldSendEmail?: (boolean | null) | undefined, delayInMinEmail?: (number | null) | undefined, severitiesEmail?: (Array | null) | undefined, phoneNumberConfirmations?: (Array | null) | undefined, disabledIntentsEmail?: (Array | null) | undefined, disabledIntentsVoice?: (Array | null) | undefined, disabledIntentsPush?: (Array | null) | undefined, disabledIntentsSMS?: (Array | null) | undefined}; export type AllQuietApiCommonCalendarPublishingSettingsRequest = {isPublished?: (boolean | null) | undefined, onlyIncludeTier1?: (boolean | null) | undefined}; export type AllQuietApiPublicUsersUserResourceUpdateRequest = {email?: (string | null) | undefined, displayName?: (string | null) | undefined, phoneNumber?: (string | null) | undefined, timeZoneId?: (string | null) | undefined, incidentNotificationSettings?: AllQuietApiAuthenticationModelsIncidentNotificationSettings | undefined, calendarPublishingSettings?: AllQuietApiCommonCalendarPublishingSettingsRequest | undefined, disableWeeklyIncidentEngagementReport?: (boolean | null) | undefined}; export type UpdateApiApiPublicV1UserIdArgs = {id: string, organizationId?: string | undefined, body: AllQuietApiPublicUsersUserResourceUpdateRequest}; export type UpdateApiApiPublicV1UserIdOptions = {baseUrl: string, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const allQuietApiAuthenticationModelsPhoneNumberConfirmation = z.object({phoneNumber: z.string().nullable().optional(), confirmedAt: z.string().nullable().optional(), requestedAt: z.string().nullable().optional(), confirmationCode: z.string().nullable().optional(), type: z.string().nullable().optional()}); export const allQuietApiAuthenticationModelsIncidentNotificationSettings = z.object({shouldSendSMS: z.boolean().nullable().optional(), delayInMinSMS: z.number().int().gte(0).lte(60).nullable().optional(), severitiesSMS: z.array(z.string()).nullable().optional(), shouldCallVoice: z.boolean().nullable().optional(), delayInMinVoice: z.number().int().gte(0).lte(60).nullable().optional(), severitiesVoice: z.array(z.string()).nullable().optional(), shouldSendPush: z.boolean().nullable().optional(), delayInMinPush: z.number().int().gte(0).lte(60).nullable().optional(), severitiesPush: z.array(z.string()).nullable().optional(), shouldSendEmail: z.boolean().nullable().optional(), delayInMinEmail: z.number().int().gte(0).lte(60).nullable().optional(), severitiesEmail: z.array(z.string()).nullable().optional(), phoneNumberConfirmations: z.array(allQuietApiAuthenticationModelsPhoneNumberConfirmation).nullable().optional(), disabledIntentsEmail: z.array(z.string()).nullable().optional(), disabledIntentsVoice: z.array(z.string()).nullable().optional(), disabledIntentsPush: z.array(z.string()).nullable().optional(), disabledIntentsSMS: z.array(z.string()).nullable().optional()}); export const allQuietApiCommonCalendarPublishingSettingsResponse = z.object({isPublished: z.boolean().optional(), publicCalendarUrlOutlook: z.string().nullable().optional(), publicCalendarUrlGoogle: z.string().nullable().optional(), onlyIncludeTier1: z.boolean().nullable().optional()}); export const allQuietApiPublicUsersUserResourceResponse = z.object({id: z.string().optional(), email: z.string().nullable().optional(), userName: z.string().nullable().optional(), displayName: z.string().nullable().optional(), phoneNumber: z.string().nullable().optional(), timeZoneId: z.string().nullable().optional(), incidentNotificationSettings: allQuietApiAuthenticationModelsIncidentNotificationSettings.optional(), calendarPublishingSettings: allQuietApiCommonCalendarPublishingSettingsResponse.optional(), disableWeeklyIncidentEngagementReport: z.boolean().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 a user * * PUT /api/public/v1/user/{id} */ export const updateApiApiPublicV1UserId = async (args: UpdateApiApiPublicV1UserIdArgs, options: UpdateApiApiPublicV1UserIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.organizationId != null) query.append("organizationId", String(args.organizationId)) if (ApiKey !== undefined) headers.set("Authorization", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/public/v1/user/${encodeURIComponent(String(args.id))}${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(allQuietApiPublicUsersUserResourceResponse, await res.json()) };