/* * 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 { Device } from 'lib/seam/connect/resources/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' import { SeamHttpNoiseSensorsNoiseThresholds } from './noise-thresholds/index.js' import { SeamHttpNoiseSensorsSimulate } from './simulate/index.js' export class SeamHttpNoiseSensors { 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 = {}, ): SeamHttpNoiseSensors { const constructorOptions = { ...options, client } if (!isSeamHttpOptionsWithClient(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing client') } return new SeamHttpNoiseSensors(constructorOptions) } static fromApiKey( apiKey: SeamHttpOptionsWithApiKey['apiKey'], options: Omit = {}, ): SeamHttpNoiseSensors { const constructorOptions = { ...options, apiKey } if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing apiKey') } return new SeamHttpNoiseSensors(constructorOptions) } static fromClientSessionToken( clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], options: Omit< SeamHttpOptionsWithClientSessionToken, 'clientSessionToken' > = {}, ): SeamHttpNoiseSensors { const constructorOptions = { ...options, clientSessionToken } if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') } return new SeamHttpNoiseSensors(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 SeamHttpNoiseSensors.fromPublishableKey', ) } const client = createClient(clientOptions) const clientSessions = SeamHttpClientSessions.fromClient(client) const { token } = await clientSessions.getOrCreate({ user_identifier_key: userIdentifierKey, }) return SeamHttpNoiseSensors.fromClientSessionToken(token, options) } static fromConsoleSessionToken( consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], options: Omit< SeamHttpOptionsWithConsoleSessionToken, 'consoleSessionToken' | 'workspaceId' > = {}, ): SeamHttpNoiseSensors { const constructorOptions = { ...options, consoleSessionToken, workspaceId } if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing consoleSessionToken or workspaceId', ) } return new SeamHttpNoiseSensors(constructorOptions) } static fromPersonalAccessToken( personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], options: Omit< SeamHttpOptionsWithPersonalAccessToken, 'personalAccessToken' | 'workspaceId' > = {}, ): SeamHttpNoiseSensors { const constructorOptions = { ...options, personalAccessToken, workspaceId } if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing personalAccessToken or workspaceId', ) } return new SeamHttpNoiseSensors(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() } get noiseThresholds(): SeamHttpNoiseSensorsNoiseThresholds { return SeamHttpNoiseSensorsNoiseThresholds.fromClient( this.client, this.defaults, ) } get simulate(): SeamHttpNoiseSensorsSimulate { return SeamHttpNoiseSensorsSimulate.fromClient(this.client, this.defaults) } /** * Returns a list of all [noise sensors](https://docs.seam.co/capability-guides/noise-sensors). */ list( parameters?: NoiseSensorsListParameters, options: NoiseSensorsListOptions = {}, ): NoiseSensorsListRequest { return new SeamHttpRequest(this, { pathname: '/noise_sensors/list', method: 'POST', body: parameters, responseKey: 'devices', options, }) } } export type NoiseSensorsListParameters = { /** * 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 of the noise sensors that you want to list. */ device_type?: 'noiseaware_activity_zone' | 'minut_sensor' | undefined /** * Device types of the noise sensors that you want to list. */ device_types?: Array<'noiseaware_activity_zone' | 'minut_sensor'> | undefined /** * Numerical limit on the number of devices to return. */ limit?: number | undefined /** * Manufacturers of the noise sensors that you want to list. */ manufacturer?: 'minut' | 'noiseaware' | 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 NoiseSensorsListRequest instead. */ export type NoiseSensorsListResponse = { devices: Array } export type NoiseSensorsListRequest = SeamHttpRequest< NoiseSensorsListResponse, 'devices' > export interface NoiseSensorsListOptions {}