import {z} from 'zod' export type CreateApiCustomersCreatePortalArgs = {body: {customer_resources_filters?: (Array<{field: string, operation: '=', value: string | boolean}>) | undefined, customization_profile_id?: string | undefined, exclude_locale_picker?: boolean | undefined, features?: ({configure?: ({allow_access_automation_rule_customization?: boolean | undefined, allow_climate_automation_rule_customization?: boolean | undefined, allow_instant_key_customization?: boolean | undefined, exclude?: boolean | undefined}) | undefined, connect?: ({accepted_providers?: Array | undefined, exclude?: boolean | undefined, excluded_providers?: Array | undefined}) | undefined, manage?: ({device_management_confirmation?: ({body?: string | undefined, cancel_button_label?: string | undefined, confirm_button_label?: string | undefined, title?: string | undefined}) | undefined, events?: ({allowed_events?: Array | undefined, default_events?: Array | undefined}) | undefined, exclude?: boolean | undefined, exclude_reservation_management?: boolean | undefined, exclude_reservation_technical_details?: boolean | undefined, exclude_staff_management?: boolean | undefined}) | undefined, manage_devices?: ({exclude?: boolean | undefined}) | undefined, organize?: ({exclude?: boolean | undefined}) | undefined}) | undefined, is_embedded?: boolean | undefined, landing_page?: ({manage?: ({space_key: string} | {property_key: string} | {room_key: string} | {common_area_key: string} | {unit_key: string} | {facility_key: string} | {building_key: string} | {listing_key: string} | {property_listing_key: string} | {site_key: string} | {reservation_key: string} | {booking_key: string} | {access_grant_key: string}) | undefined}) | undefined, locale?: ('en-US' | 'pt-PT' | 'fr-FR' | 'it-IT' | 'es-ES' | 'de-DE' | 'nl-NL' | 'el-GR' | 'pl-PL' | 'ru-RU') | undefined, navigation_mode?: ('full' | 'restricted') | undefined, customer_data?: ({access_grants?: (Array<{access_grant_key: string, building_keys?: Array | undefined, common_area_keys?: Array | undefined, ends_at?: string | undefined, facility_keys?: Array | undefined, guest_key?: string | undefined, listing_keys?: Array | undefined, name?: string | undefined, preferred_code?: string | undefined, property_keys?: Array | undefined, resident_key?: string | undefined, room_keys?: Array | undefined, space_keys?: Array | undefined, starts_at?: string | undefined, tenant_key?: string | undefined, unit_keys?: Array | undefined, user_identity_key?: string | undefined, user_key?: string | undefined}>) | undefined, bookings?: (Array<{booking_key: string, building_keys?: Array | undefined, common_area_keys?: Array | undefined, ends_at?: string | undefined, facility_keys?: Array | undefined, guest_key?: string | undefined, listing_keys?: Array | undefined, name?: string | undefined, preferred_code?: string | undefined, property_keys?: Array | undefined, resident_key?: string | undefined, room_keys?: Array | undefined, space_keys?: Array | undefined, starts_at?: string | undefined, tenant_key?: string | undefined, unit_keys?: Array | undefined, user_identity_key?: string | undefined, user_key?: string | undefined}>) | undefined, buildings?: Array<{building_key: string, name: string}> | undefined, common_areas?: (Array<{common_area_key: string, name: string, parent_site_key?: string | undefined}>) | undefined, customer_key: string, facilities?: Array<{facility_key: string, name: string}> | undefined, guests?: (Array<{email_address?: string | undefined, guest_key: string, name: string, phone_number?: string | undefined}>) | undefined, listings?: Array<{listing_key: string, name: string}> | undefined, properties?: Array<{name: string, property_key: string}> | undefined, property_listings?: (Array<{custom_metadata?: ({[key: string]: string | boolean | null}) | undefined, name: string, property_listing_key: string}>) | undefined, reservations?: (Array<{building_keys?: Array | undefined, common_area_keys?: Array | undefined, custom_metadata?: ({[key: string]: string | boolean | null}) | undefined, ends_at?: string | undefined, facility_keys?: Array | undefined, guest_key?: string | undefined, listing_keys?: Array | undefined, name?: string | undefined, preferred_code?: string | undefined, property_keys?: Array | undefined, reservation_key: string, resident_key?: string | undefined, room_keys?: Array | undefined, space_keys?: Array | undefined, starts_at?: string | undefined, tenant_key?: string | undefined, unit_keys?: Array | undefined, user_identity_key?: string | undefined, user_key?: string | undefined}>) | undefined, residents?: (Array<{email_address?: string | undefined, name: string, phone_number?: string | undefined, resident_key: string}>) | undefined, rooms?: (Array<{name: string, parent_site_key?: string | undefined, room_key: string}>) | undefined, sites?: Array<{name: string, site_key: string}> | undefined, spaces?: (Array<{customer_data?: ({address?: (string | null) | undefined, default_checkin_time?: (string | null) | undefined, default_checkout_time?: (string | null) | undefined, time_zone?: (string | null) | undefined}) | undefined, duration_minutes?: number | undefined, geolocation?: {latitude: number, longitude: number} | undefined, name: string, parent_site_key?: string | undefined, space_key: string}>) | undefined, staff_members?: (Array<{building_keys?: Array | undefined, common_area_keys?: Array | undefined, email_address?: string | undefined, facility_keys?: Array | undefined, listing_keys?: Array | undefined, name: string, phone_number?: string | undefined, property_keys?: Array | undefined, property_listing_keys?: Array | undefined, room_keys?: Array | undefined, site_keys?: Array | undefined, space_keys?: Array | undefined, staff_member_key: string, unit_keys?: Array | undefined}>) | undefined, tenants?: (Array<{email_address?: string | undefined, name: string, phone_number?: string | undefined, tenant_key: string}>) | undefined, units?: (Array<{name: string, parent_site_key?: string | undefined, unit_key: string}>) | undefined, user_identities?: (Array<{email_address?: string | undefined, name: string, phone_number?: string | undefined, user_identity_key: string}>) | undefined, users?: (Array<{email_address?: string | undefined, name: string, phone_number?: string | undefined, user_key: string}>) | undefined}) | undefined}}; export type CreateApiCustomersCreatePortalOptions = {baseUrl?: string | undefined, patWithWorkspace?: string | undefined, fetch?: typeof fetch | undefined}; export const customerPortal = z.object({created_at: z.string(), customer_key: z.string(), expires_at: z.string(), url: z.string(), workspace_id: z.string()}); export const createApiCustomersCreatePortalResponse = z.object({customer_portal: customerPortal}); 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 }; /** * Create Customer Portal * * POST /customers/create_portal * * Also accepts auth: console_session_with_workspace, api_key */ export const createApiCustomersCreatePortal = async (args: CreateApiCustomersCreatePortalArgs, options?: CreateApiCustomersCreatePortalOptions) => { const {baseUrl = "https://connect.getseam.com", fetch: fetchFn = fetch, patWithWorkspace} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (patWithWorkspace !== undefined) headers.set('authorization', `Bearer ${patWithWorkspace}`) const url = `${baseUrl.replace(/\/+$/, '')}/customers/create_portal${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(createApiCustomersCreatePortalResponse, await res.json()) };