/* * 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 { NoiseThreshold } from 'lib/seam/connect/resources/noise-threshold.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 SeamHttpNoiseSensorsNoiseThresholds { 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 = {}, ): SeamHttpNoiseSensorsNoiseThresholds { const constructorOptions = { ...options, client } if (!isSeamHttpOptionsWithClient(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing client') } return new SeamHttpNoiseSensorsNoiseThresholds(constructorOptions) } static fromApiKey( apiKey: SeamHttpOptionsWithApiKey['apiKey'], options: Omit = {}, ): SeamHttpNoiseSensorsNoiseThresholds { const constructorOptions = { ...options, apiKey } if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing apiKey') } return new SeamHttpNoiseSensorsNoiseThresholds(constructorOptions) } static fromClientSessionToken( clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], options: Omit< SeamHttpOptionsWithClientSessionToken, 'clientSessionToken' > = {}, ): SeamHttpNoiseSensorsNoiseThresholds { const constructorOptions = { ...options, clientSessionToken } if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') } return new SeamHttpNoiseSensorsNoiseThresholds(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 SeamHttpNoiseSensorsNoiseThresholds.fromPublishableKey', ) } const client = createClient(clientOptions) const clientSessions = SeamHttpClientSessions.fromClient(client) const { token } = await clientSessions.getOrCreate({ user_identifier_key: userIdentifierKey, }) return SeamHttpNoiseSensorsNoiseThresholds.fromClientSessionToken( token, options, ) } static fromConsoleSessionToken( consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], options: Omit< SeamHttpOptionsWithConsoleSessionToken, 'consoleSessionToken' | 'workspaceId' > = {}, ): SeamHttpNoiseSensorsNoiseThresholds { const constructorOptions = { ...options, consoleSessionToken, workspaceId } if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing consoleSessionToken or workspaceId', ) } return new SeamHttpNoiseSensorsNoiseThresholds(constructorOptions) } static fromPersonalAccessToken( personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], options: Omit< SeamHttpOptionsWithPersonalAccessToken, 'personalAccessToken' | 'workspaceId' > = {}, ): SeamHttpNoiseSensorsNoiseThresholds { const constructorOptions = { ...options, personalAccessToken, workspaceId } if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing personalAccessToken or workspaceId', ) } return new SeamHttpNoiseSensorsNoiseThresholds(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() } /** * Creates a new [noise threshold](https://docs.seam.co/capability-guides/noise-sensors/configure-noise-threshold-settings) for a [noise sensor](https://docs.seam.co/capability-guides/noise-sensors). Thresholds represent the limits of noise tolerated at a property, which can be customized for each hour of the day. Each device has its own default thresholds, but you can use the Seam API to modify them. */ create( parameters: NoiseSensorsNoiseThresholdsCreateParameters, options: NoiseSensorsNoiseThresholdsCreateOptions = {}, ): NoiseSensorsNoiseThresholdsCreateRequest { return new SeamHttpRequest(this, { pathname: '/noise_sensors/noise_thresholds/create', method: 'POST', body: parameters, responseKey: 'noise_threshold', options, }) } /** * Deletes a [noise threshold](https://docs.seam.co/capability-guides/noise-sensors/configure-noise-threshold-settings) from a [noise sensor](https://docs.seam.co/capability-guides/noise-sensors). */ delete( parameters: NoiseSensorsNoiseThresholdsDeleteParameters, options: NoiseSensorsNoiseThresholdsDeleteOptions = {}, ): NoiseSensorsNoiseThresholdsDeleteRequest { return new SeamHttpRequest(this, { pathname: '/noise_sensors/noise_thresholds/delete', method: 'POST', body: parameters, responseKey: undefined, options, }) } /** * Returns a specified [noise threshold](https://docs.seam.co/capability-guides/noise-sensors/configure-noise-threshold-settings) for a [noise sensor](https://docs.seam.co/capability-guides/noise-sensors). */ get( parameters: NoiseSensorsNoiseThresholdsGetParameters, options: NoiseSensorsNoiseThresholdsGetOptions = {}, ): NoiseSensorsNoiseThresholdsGetRequest { return new SeamHttpRequest(this, { pathname: '/noise_sensors/noise_thresholds/get', method: 'POST', body: parameters, responseKey: 'noise_threshold', options, }) } /** * Returns a list of all [noise thresholds](https://docs.seam.co/capability-guides/noise-sensors/configure-noise-threshold-settings) for a [noise sensor](https://docs.seam.co/capability-guides/noise-sensors). */ list( parameters: NoiseSensorsNoiseThresholdsListParameters, options: NoiseSensorsNoiseThresholdsListOptions = {}, ): NoiseSensorsNoiseThresholdsListRequest { return new SeamHttpRequest(this, { pathname: '/noise_sensors/noise_thresholds/list', method: 'POST', body: parameters, responseKey: 'noise_thresholds', options, }) } /** * Updates a [noise threshold](https://docs.seam.co/capability-guides/noise-sensors/configure-noise-threshold-settings) for a [noise sensor](https://docs.seam.co/capability-guides/noise-sensors). */ update( parameters: NoiseSensorsNoiseThresholdsUpdateParameters, options: NoiseSensorsNoiseThresholdsUpdateOptions = {}, ): NoiseSensorsNoiseThresholdsUpdateRequest { return new SeamHttpRequest(this, { pathname: '/noise_sensors/noise_thresholds/update', method: 'PUT', body: parameters, responseKey: undefined, options, }) } } export type NoiseSensorsNoiseThresholdsCreateParameters = { /** * ID of the device for which you want to create a noise threshold. */ device_id: string /** * Time at which the new noise threshold should become inactive daily. */ ends_daily_at: string /** * Name of the new noise threshold. */ name?: string | undefined /** * Noise level in decibels for the new noise threshold. */ noise_threshold_decibels?: number | undefined /** * Noise level in Noiseaware Noise Risk Score (NRS) for the new noise threshold. This parameter is only relevant for [Noiseaware sensors](https://docs.seam.co/device-and-system-integration-guides/noiseaware-sensors). */ noise_threshold_nrs?: number | undefined /** * Time at which the new noise threshold should become active daily. */ starts_daily_at: string } /** * @deprecated Use NoiseSensorsNoiseThresholdsCreateRequest instead. */ export type NoiseSensorsNoiseThresholdsCreateResponse = { noise_threshold: NoiseThreshold } export type NoiseSensorsNoiseThresholdsCreateRequest = SeamHttpRequest< NoiseSensorsNoiseThresholdsCreateResponse, 'noise_threshold' > export interface NoiseSensorsNoiseThresholdsCreateOptions {} export type NoiseSensorsNoiseThresholdsDeleteParameters = { /** * ID of the device that contains the noise threshold that you want to delete. */ device_id: string /** * ID of the noise threshold that you want to delete. */ noise_threshold_id: string } /** * @deprecated Use NoiseSensorsNoiseThresholdsDeleteRequest instead. */ export type NoiseSensorsNoiseThresholdsDeleteResponse = void export type NoiseSensorsNoiseThresholdsDeleteRequest = SeamHttpRequest< void, undefined > export interface NoiseSensorsNoiseThresholdsDeleteOptions {} export type NoiseSensorsNoiseThresholdsGetParameters = { /** * ID of the noise threshold that you want to get. */ noise_threshold_id: string } /** * @deprecated Use NoiseSensorsNoiseThresholdsGetRequest instead. */ export type NoiseSensorsNoiseThresholdsGetResponse = { noise_threshold: NoiseThreshold } export type NoiseSensorsNoiseThresholdsGetRequest = SeamHttpRequest< NoiseSensorsNoiseThresholdsGetResponse, 'noise_threshold' > export interface NoiseSensorsNoiseThresholdsGetOptions {} export type NoiseSensorsNoiseThresholdsListParameters = { /** * ID of the device for which you want to list noise thresholds. */ device_id: string } /** * @deprecated Use NoiseSensorsNoiseThresholdsListRequest instead. */ export type NoiseSensorsNoiseThresholdsListResponse = { noise_thresholds: Array } export type NoiseSensorsNoiseThresholdsListRequest = SeamHttpRequest< NoiseSensorsNoiseThresholdsListResponse, 'noise_thresholds' > export interface NoiseSensorsNoiseThresholdsListOptions {} export type NoiseSensorsNoiseThresholdsUpdateParameters = { /** * ID of the device that contains the noise threshold that you want to update. */ device_id: string /** * Time at which the noise threshold should become inactive daily. */ ends_daily_at?: string | undefined /** * Name of the noise threshold that you want to update. */ name?: string | undefined /** * Noise level in decibels for the noise threshold. */ noise_threshold_decibels?: number | undefined /** * ID of the noise threshold that you want to update. */ noise_threshold_id: string /** * Noise level in Noiseaware Noise Risk Score (NRS) for the noise threshold. This parameter is only relevant for [Noiseaware sensors](https://docs.seam.co/device-and-system-integration-guides/noiseaware-sensors). */ noise_threshold_nrs?: number | undefined /** * Time at which the noise threshold should become active daily. */ starts_daily_at?: string | undefined } /** * @deprecated Use NoiseSensorsNoiseThresholdsUpdateRequest instead. */ export type NoiseSensorsNoiseThresholdsUpdateResponse = void export type NoiseSensorsNoiseThresholdsUpdateRequest = SeamHttpRequest< void, undefined > export interface NoiseSensorsNoiseThresholdsUpdateOptions {}