import {z} from 'zod' export type UpdateAppointmentInput = {media_transcription_id?: string | undefined, activity_type_id?: string | undefined, currency_exchange_rates_list_id?: string | undefined, description?: string | undefined, duration?: number | undefined, end_date?: string | undefined, invitees_can_edit?: boolean | undefined, is_recurrence_active?: boolean | undefined, is_recurrence_exception?: boolean | undefined, location?: string | undefined, meeting_url?: Record | undefined, occurence_date?: string | undefined, organizer?: string | undefined, owner_id?: string | undefined, recurrence_master_id?: string | undefined, recurrence_rule?: string | undefined, recurrence_tzid?: string | undefined, schedule_id?: string | undefined, schedule_tzid?: string | undefined, start_date?: string | undefined, subject?: string | undefined, unit_id?: string | undefined, revision?: number | undefined, account_relations?: (Array<{id?: string | undefined}>) | undefined, contact_relations?: (Array<{id?: string | undefined}>) | undefined, lead_relations?: (Array<{id?: string | undefined}>) | undefined, opportunity_relations?: (Array<{id?: string | undefined}>) | undefined, project_relations?: (Array<{id?: string | undefined}>) | undefined, quote_relations?: (Array<{id?: string | undefined}>) | undefined, custom_entity_relations?: (Array<{id?: string | undefined}>) | undefined, invitees_contacts?: (Array<{id?: string | undefined}>) | undefined, invitees_clients?: (Array<{id?: string | undefined}>) | undefined, exchange_entity_id?: string | undefined, gapi_entity_id?: string | undefined, o365_entity_id?: string | undefined, documents?: (Array<{id?: string | undefined}>) | undefined, comments?: (Array<{id?: string | undefined}>) | undefined, tags?: (Array<{id?: string | undefined}>) | undefined}; export type PatchApiEntitiesAppointmentsIdArgs = {id: string, 'validation-level'?: number | undefined, body: UpdateAppointmentInput}; export type PatchApiEntitiesAppointmentsIdOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; export const appointment = z.object({is_delete_protected: z.boolean(), id: z.string(), active_reminder: z.string().optional(), media_transcription_id: z.string().optional(), is_deleted: z.boolean().optional(), modified: z.string().optional(), created: z.string().optional(), activity_type: z.string(), currency_exchange_rates_list: z.string().optional(), owner: z.string(), recurrence_master: z.string().optional(), schedule: z.string().optional(), unit: z.string(), activity_type_id: z.string().optional(), currency_exchange_rates_list_id: z.string().optional(), description: z.string().optional(), duration: z.number().optional(), end_date: z.string(), invitees_can_edit: z.boolean().optional(), is_recurrence_active: z.boolean().optional(), is_recurrence_exception: z.boolean().optional(), location: z.string().optional(), meeting_url: z.object({}).optional(), occurence_date: z.string().optional(), organizer: z.string().optional(), owner_id: z.string(), recurrence_master_id: z.string().optional(), recurrence_rule: z.string().optional(), recurrence_tzid: z.string().optional(), schedule_id: z.string().optional(), schedule_tzid: z.string().optional(), start_date: z.string().optional(), subject: z.string(), table_name: z.string(), unit_id: z.string().optional(), revision: z.number().int().optional(), status: z.union([z.literal(1), z.literal(2), z.literal(3), z.literal(4), z.literal(5), z.literal(6)]), account_relations: z.array(z.string()).optional(), contact_relations: z.array(z.string()).optional(), lead_relations: z.array(z.string()).optional(), opportunity_relations: z.array(z.string()).optional(), project_relations: z.array(z.string()).optional(), quote_relations: z.array(z.string()).optional(), custom_entity_relations: z.array(z.string()).optional(), invitees_contacts: z.array(z.string()).optional(), invitees_clients: z.array(z.string()).optional(), exchange_entity_id: z.string().optional(), gapi_entity_id: z.string().optional(), o365_entity_id: z.string().optional(), has_3rd_party_mapping: z.boolean(), reminder: z.string().optional(), documents: z.array(z.string()).optional(), comments: z.array(z.string()).optional(), tags: z.array(z.string()).optional(), formatted_name: z.string(), recurrence: z.object({}).optional(), modified_by_user: z.string().optional()}); export const patchApiEntitiesAppointmentsIdResponse = z.object({success: z.boolean().optional(), data: appointment.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 }; /** * Appointments.update * * PATCH /entities/Appointments/{id} */ export const patchApiEntitiesAppointmentsId = async (args: PatchApiEntitiesAppointmentsIdArgs, options?: PatchApiEntitiesAppointmentsIdOptions) => { const {baseUrl = "https://us-east.api.coevera.com/api/v100/rest/spaces/your_space_id", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['validation-level'] != null) query.append("validation-level", String(args['validation-level'])) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/entities/Appointments/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(patchApiEntitiesAppointmentsIdResponse, await res.json()) };