/* * Automatically generated by codegen/smith.ts. * Do not edit this file or add other files to this directory. */ import { seamApiLtsVersion } from 'lib/lts-version.js' import { getAuthHeadersForClientSessionToken, warnOnInsecureuserIdentifierKey, } from 'lib/seam/connect/auth.js' import { type Client, createClient } from 'lib/seam/connect/client.js' import { isSeamHttpOptionsWithApiKey, isSeamHttpOptionsWithClient, isSeamHttpOptionsWithClientSessionToken, isSeamHttpOptionsWithConsoleSessionToken, isSeamHttpOptionsWithPersonalAccessToken, type SeamHttpFromPublishableKeyOptions, SeamHttpInvalidOptionsError, type SeamHttpOptions, type SeamHttpOptionsWithApiKey, type SeamHttpOptionsWithClient, type SeamHttpOptionsWithClientSessionToken, type SeamHttpOptionsWithConsoleSessionToken, type SeamHttpOptionsWithPersonalAccessToken, type SeamHttpRequestOptions, } from 'lib/seam/connect/options.js' import { limitToSeamHttpRequestOptions, parseOptions, } from 'lib/seam/connect/parse-options.js' import type { UnmanagedDevice } from 'lib/seam/connect/resources/unmanaged-device.js' import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js' import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' export class SeamHttpDevicesUnmanaged { client: Client readonly defaults: Required readonly ltsVersion = seamApiLtsVersion static ltsVersion = seamApiLtsVersion constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) { const options = parseOptions(apiKeyOrOptions) this.client = 'client' in options ? options.client : createClient(options) this.defaults = limitToSeamHttpRequestOptions(options) } static fromClient( client: SeamHttpOptionsWithClient['client'], options: Omit = {}, ): SeamHttpDevicesUnmanaged { const constructorOptions = { ...options, client } if (!isSeamHttpOptionsWithClient(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing client') } return new SeamHttpDevicesUnmanaged(constructorOptions) } static fromApiKey( apiKey: SeamHttpOptionsWithApiKey['apiKey'], options: Omit = {}, ): SeamHttpDevicesUnmanaged { const constructorOptions = { ...options, apiKey } if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing apiKey') } return new SeamHttpDevicesUnmanaged(constructorOptions) } static fromClientSessionToken( clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], options: Omit< SeamHttpOptionsWithClientSessionToken, 'clientSessionToken' > = {}, ): SeamHttpDevicesUnmanaged { const constructorOptions = { ...options, clientSessionToken } if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') } return new SeamHttpDevicesUnmanaged(constructorOptions) } static async fromPublishableKey( publishableKey: string, userIdentifierKey: string, options: SeamHttpFromPublishableKeyOptions = {}, ): Promise { warnOnInsecureuserIdentifierKey(userIdentifierKey) const clientOptions = parseOptions({ ...options, publishableKey }) if (isSeamHttpOptionsWithClient(clientOptions)) { throw new SeamHttpInvalidOptionsError( 'The client option cannot be used with SeamHttpDevicesUnmanaged.fromPublishableKey', ) } const client = createClient(clientOptions) const clientSessions = SeamHttpClientSessions.fromClient(client) const { token } = await clientSessions.getOrCreate({ user_identifier_key: userIdentifierKey, }) return SeamHttpDevicesUnmanaged.fromClientSessionToken(token, options) } static fromConsoleSessionToken( consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], options: Omit< SeamHttpOptionsWithConsoleSessionToken, 'consoleSessionToken' | 'workspaceId' > = {}, ): SeamHttpDevicesUnmanaged { const constructorOptions = { ...options, consoleSessionToken, workspaceId } if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing consoleSessionToken or workspaceId', ) } return new SeamHttpDevicesUnmanaged(constructorOptions) } static fromPersonalAccessToken( personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], options: Omit< SeamHttpOptionsWithPersonalAccessToken, 'personalAccessToken' | 'workspaceId' > = {}, ): SeamHttpDevicesUnmanaged { const constructorOptions = { ...options, personalAccessToken, workspaceId } if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing personalAccessToken or workspaceId', ) } return new SeamHttpDevicesUnmanaged(constructorOptions) } createPaginator( request: SeamHttpRequest, ): SeamPaginator { return new SeamPaginator(this, request) } async updateClientSessionToken( clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], ): Promise { const { headers } = this.client.defaults const authHeaders = getAuthHeadersForClientSessionToken({ clientSessionToken, }) for (const key of Object.keys(authHeaders)) { if (headers[key] == null) { throw new Error( 'Cannot update a clientSessionToken on a client created without a clientSessionToken', ) } } this.client.defaults.headers = { ...headers, ...authHeaders } const clientSessions = SeamHttpClientSessions.fromClient(this.client) await clientSessions.get() } /** * Returns a specified [unmanaged device](https://docs.seam.co/core-concepts/devices/managed-and-unmanaged-devices). * * An unmanaged device has a limited set of visible properties and a subset of supported events. You cannot control an unmanaged device. Any [access codes](https://docs.seam.co/low-level-apis/smart-locks/access-codes/migrating-existing-access-codes) on an unmanaged device are unmanaged. To control an unmanaged device with Seam, [convert it to a managed device](https://docs.seam.co/core-concepts/devices/managed-and-unmanaged-devices#convert-an-unmanaged-device-to-managed). * * You must specify either `device_id` or `name`. */ get( parameters?: DevicesUnmanagedGetParameters, options: DevicesUnmanagedGetOptions = {}, ): DevicesUnmanagedGetRequest { return new SeamHttpRequest(this, { pathname: '/devices/unmanaged/get', method: 'POST', body: parameters, responseKey: 'device', options, }) } /** * Returns a list of all [unmanaged devices](https://docs.seam.co/core-concepts/devices/managed-and-unmanaged-devices). * * An unmanaged device has a limited set of visible properties and a subset of supported events. You cannot control an unmanaged device. Any [access codes](https://docs.seam.co/low-level-apis/smart-locks/access-codes/migrating-existing-access-codes) on an unmanaged device are unmanaged. To control an unmanaged device with Seam, [convert it to a managed device](https://docs.seam.co/core-concepts/devices/managed-and-unmanaged-devices#convert-an-unmanaged-device-to-managed). */ list( parameters?: DevicesUnmanagedListParameters, options: DevicesUnmanagedListOptions = {}, ): DevicesUnmanagedListRequest { return new SeamHttpRequest(this, { pathname: '/devices/unmanaged/list', method: 'POST', body: parameters, responseKey: 'devices', options, }) } /** * Updates a specified [unmanaged device](https://docs.seam.co/core-concepts/devices/managed-and-unmanaged-devices). To convert an unmanaged device to managed, set `is_managed` to `true`. * * An unmanaged device has a limited set of visible properties and a subset of supported events. You cannot control an unmanaged device. Any [access codes](https://docs.seam.co/low-level-apis/smart-locks/access-codes/migrating-existing-access-codes) on an unmanaged device are unmanaged. To control an unmanaged device with Seam, [convert it to a managed device](https://docs.seam.co/core-concepts/devices/managed-and-unmanaged-devices#convert-an-unmanaged-device-to-managed). */ update( parameters: DevicesUnmanagedUpdateParameters, options: DevicesUnmanagedUpdateOptions = {}, ): DevicesUnmanagedUpdateRequest { return new SeamHttpRequest(this, { pathname: '/devices/unmanaged/update', method: 'PATCH', body: parameters, responseKey: undefined, options, }) } } export type DevicesUnmanagedGetParameters = { /** * ID of the unmanaged device that you want to get. */ device_id?: string | undefined /** * Name of the unmanaged device that you want to get. */ name?: string | undefined } /** * @deprecated Use DevicesUnmanagedGetRequest instead. */ export type DevicesUnmanagedGetResponse = { device: UnmanagedDevice } export type DevicesUnmanagedGetRequest = SeamHttpRequest< DevicesUnmanagedGetResponse, 'device' > export interface DevicesUnmanagedGetOptions {} export type DevicesUnmanagedListParameters = { /** * ID of the Connect Webview for which you want to list devices. */ connect_webview_id?: string | undefined /** * ID of the connected account for which you want to list devices. */ connected_account_id?: string | undefined /** * Array of IDs of the connected accounts for which you want to list devices. */ connected_account_ids?: Array | undefined /** * Timestamp by which to limit returned devices. Returns devices created before this timestamp. */ created_before?: string | undefined /** * Set of key:value [custom metadata](https://docs.seam.co/core-concepts/devices/adding-custom-metadata-to-a-device) pairs for which you want to list devices. */ custom_metadata_has?: Record | undefined /** * Customer key for which you want to list devices. */ customer_key?: string | undefined /** * Array of device IDs for which you want to list devices. */ device_ids?: Array | undefined /** * Device type for which you want to list devices. */ device_type?: | 'akuvox_lock' | 'august_lock' | 'brivo_access_point' | 'butterflymx_panel' | 'avigilon_alta_entry' | 'doorking_lock' | 'genie_door' | 'igloo_lock' | 'linear_lock' | 'lockly_lock' | 'kwikset_lock' | 'nuki_lock' | 'salto_lock' | 'schlage_lock' | 'smartthings_lock' | 'wyze_lock' | 'yale_lock' | 'two_n_intercom' | 'controlbyweb_device' | 'ttlock_lock' | 'igloohome_lock' | 'four_suites_door' | 'dormakaba_oracode_door' | 'tedee_lock' | 'akiles_lock' | 'ultraloq_lock' | 'keyincode_lock' | 'omnitec_lock' | 'kisi_lock' | 'aqara_lock' | 'keynest_key' | 'noiseaware_activity_zone' | 'minut_sensor' | 'ecobee_thermostat' | 'nest_thermostat' | 'honeywell_resideo_thermostat' | 'tado_thermostat' | 'sensi_thermostat' | 'smartthings_thermostat' | 'ios_phone' | 'android_phone' | 'ring_camera' | undefined /** * Array of device types for which you want to list devices. */ device_types?: | Array< | 'akuvox_lock' | 'august_lock' | 'brivo_access_point' | 'butterflymx_panel' | 'avigilon_alta_entry' | 'doorking_lock' | 'genie_door' | 'igloo_lock' | 'linear_lock' | 'lockly_lock' | 'kwikset_lock' | 'nuki_lock' | 'salto_lock' | 'schlage_lock' | 'smartthings_lock' | 'wyze_lock' | 'yale_lock' | 'two_n_intercom' | 'controlbyweb_device' | 'ttlock_lock' | 'igloohome_lock' | 'four_suites_door' | 'dormakaba_oracode_door' | 'tedee_lock' | 'akiles_lock' | 'ultraloq_lock' | 'keyincode_lock' | 'omnitec_lock' | 'kisi_lock' | 'aqara_lock' | 'keynest_key' | 'noiseaware_activity_zone' | 'minut_sensor' | 'ecobee_thermostat' | 'nest_thermostat' | 'honeywell_resideo_thermostat' | 'tado_thermostat' | 'sensi_thermostat' | 'smartthings_thermostat' | 'ios_phone' | 'android_phone' | 'ring_camera' > | undefined /** * Numerical limit on the number of devices to return. */ limit?: number | undefined /** * Manufacturer for which you want to list devices. */ manufacturer?: | 'akuvox' | 'august' | 'avigilon_alta' | 'brivo' | 'butterflymx' | 'doorking' | 'four_suites' | 'genie' | 'igloo' | 'keywe' | 'kwikset' | 'linear' | 'lockly' | 'nuki' | 'philia' | 'salto' | 'samsung' | 'schlage' | 'seam' | 'unknown' | 'wyze' | 'yale' | 'two_n' | 'ttlock' | 'igloohome' | 'controlbyweb' | 'dormakaba_oracode' | 'tedee' | 'keyincode' | 'akiles' | 'aqara' | 'ecobee' | 'honeywell_resideo' | 'keynest' | 'korelock' | 'minut' | 'nest' | 'noiseaware' | 'sensi' | 'smartthings' | 'tado' | 'ultraloq' | 'ring' | 'ical' | 'lodgify' | 'hostaway' | 'guesty' | 'acuity_scheduling' | 'omnitec' | 'kisi' | 'slack' | undefined /** * Identifies the specific page of results to return, obtained from the previous page's `next_page_cursor`. */ page_cursor?: string | undefined /** * String for which to search. Filters returned devices to include all records that satisfy a partial match using `device_id` (full or partial UUID prefix, minimum 4 characters), `connected_account_id`, `display_name`, `custom_metadata` or `location.location_name`. */ search?: string | undefined /** * ID of the space for which you want to list devices. */ space_id?: string | undefined /** * @deprecated Use `space_id`. */ unstable_location_id?: string | undefined /** * Your own internal user ID for the user for which you want to list devices. */ user_identifier_key?: string | undefined } /** * @deprecated Use DevicesUnmanagedListRequest instead. */ export type DevicesUnmanagedListResponse = { devices: Array } export type DevicesUnmanagedListRequest = SeamHttpRequest< DevicesUnmanagedListResponse, 'devices' > export interface DevicesUnmanagedListOptions {} export type DevicesUnmanagedUpdateParameters = { /** * Custom metadata that you want to associate with the device. Supports up to 50 JSON key:value pairs. */ custom_metadata?: Record | undefined /** * ID of the unmanaged device that you want to update. */ device_id: string /** * Indicates whether the device is managed. Set this parameter to `true` to convert an unmanaged device to managed. */ is_managed?: boolean | undefined } /** * @deprecated Use DevicesUnmanagedUpdateRequest instead. */ export type DevicesUnmanagedUpdateResponse = void export type DevicesUnmanagedUpdateRequest = SeamHttpRequest export interface DevicesUnmanagedUpdateOptions {}