/* * Automatically generated by codegen/smith.ts. * Do not edit this file or add other files to this directory. */ import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect' 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 { 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 type { SetNonNullable } from 'lib/types.js' export class SeamHttpThermostatsSchedules { 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 = {}, ): SeamHttpThermostatsSchedules { const constructorOptions = { ...options, client } if (!isSeamHttpOptionsWithClient(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing client') } return new SeamHttpThermostatsSchedules(constructorOptions) } static fromApiKey( apiKey: SeamHttpOptionsWithApiKey['apiKey'], options: Omit = {}, ): SeamHttpThermostatsSchedules { const constructorOptions = { ...options, apiKey } if (!isSeamHttpOptionsWithApiKey(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing apiKey') } return new SeamHttpThermostatsSchedules(constructorOptions) } static fromClientSessionToken( clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'], options: Omit< SeamHttpOptionsWithClientSessionToken, 'clientSessionToken' > = {}, ): SeamHttpThermostatsSchedules { const constructorOptions = { ...options, clientSessionToken } if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError('Missing clientSessionToken') } return new SeamHttpThermostatsSchedules(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 SeamHttpThermostatsSchedules.fromPublishableKey', ) } const client = createClient(clientOptions) const clientSessions = SeamHttpClientSessions.fromClient(client) const { token } = await clientSessions.getOrCreate({ user_identifier_key: userIdentifierKey, }) return SeamHttpThermostatsSchedules.fromClientSessionToken(token, options) } static fromConsoleSessionToken( consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'], workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'], options: Omit< SeamHttpOptionsWithConsoleSessionToken, 'consoleSessionToken' | 'workspaceId' > = {}, ): SeamHttpThermostatsSchedules { const constructorOptions = { ...options, consoleSessionToken, workspaceId } if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing consoleSessionToken or workspaceId', ) } return new SeamHttpThermostatsSchedules(constructorOptions) } static fromPersonalAccessToken( personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'], workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'], options: Omit< SeamHttpOptionsWithPersonalAccessToken, 'personalAccessToken' | 'workspaceId' > = {}, ): SeamHttpThermostatsSchedules { const constructorOptions = { ...options, personalAccessToken, workspaceId } if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) { throw new SeamHttpInvalidOptionsError( 'Missing personalAccessToken or workspaceId', ) } return new SeamHttpThermostatsSchedules(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() } create( parameters?: ThermostatsSchedulesCreateParameters, options: ThermostatsSchedulesCreateOptions = {}, ): ThermostatsSchedulesCreateRequest { return new SeamHttpRequest(this, { pathname: '/thermostats/schedules/create', method: 'POST', body: parameters, responseKey: 'thermostat_schedule', options, }) } delete( parameters?: ThermostatsSchedulesDeleteParameters, options: ThermostatsSchedulesDeleteOptions = {}, ): ThermostatsSchedulesDeleteRequest { return new SeamHttpRequest(this, { pathname: '/thermostats/schedules/delete', method: 'POST', body: parameters, responseKey: undefined, options, }) } get( parameters?: ThermostatsSchedulesGetParameters, options: ThermostatsSchedulesGetOptions = {}, ): ThermostatsSchedulesGetRequest { return new SeamHttpRequest(this, { pathname: '/thermostats/schedules/get', method: 'POST', body: parameters, responseKey: 'thermostat_schedule', options, }) } list( parameters?: ThermostatsSchedulesListParameters, options: ThermostatsSchedulesListOptions = {}, ): ThermostatsSchedulesListRequest { return new SeamHttpRequest(this, { pathname: '/thermostats/schedules/list', method: 'POST', body: parameters, responseKey: 'thermostat_schedules', options, }) } update( parameters?: ThermostatsSchedulesUpdateParameters, options: ThermostatsSchedulesUpdateOptions = {}, ): ThermostatsSchedulesUpdateRequest { return new SeamHttpRequest(this, { pathname: '/thermostats/schedules/update', method: 'PATCH', body: parameters, responseKey: undefined, options, }) } } export type ThermostatsSchedulesCreateParameters = RouteRequestBody<'/thermostats/schedules/create'> /** * @deprecated Use ThermostatsSchedulesCreateParameters instead. */ export type ThermostatsSchedulesCreateBody = ThermostatsSchedulesCreateParameters /** * @deprecated Use ThermostatsSchedulesCreateRequest instead. */ export type ThermostatsSchedulesCreateResponse = SetNonNullable< Required> > export type ThermostatsSchedulesCreateRequest = SeamHttpRequest< ThermostatsSchedulesCreateResponse, 'thermostat_schedule' > export interface ThermostatsSchedulesCreateOptions {} export type ThermostatsSchedulesDeleteParameters = RouteRequestBody<'/thermostats/schedules/delete'> /** * @deprecated Use ThermostatsSchedulesDeleteParameters instead. */ export type ThermostatsSchedulesDeleteParams = ThermostatsSchedulesDeleteParameters /** * @deprecated Use ThermostatsSchedulesDeleteRequest instead. */ export type ThermostatsSchedulesDeleteResponse = SetNonNullable< Required> > export type ThermostatsSchedulesDeleteRequest = SeamHttpRequest export interface ThermostatsSchedulesDeleteOptions {} export type ThermostatsSchedulesGetParameters = RouteRequestBody<'/thermostats/schedules/get'> /** * @deprecated Use ThermostatsSchedulesGetParameters instead. */ export type ThermostatsSchedulesGetParams = ThermostatsSchedulesGetParameters /** * @deprecated Use ThermostatsSchedulesGetRequest instead. */ export type ThermostatsSchedulesGetResponse = SetNonNullable< Required> > export type ThermostatsSchedulesGetRequest = SeamHttpRequest< ThermostatsSchedulesGetResponse, 'thermostat_schedule' > export interface ThermostatsSchedulesGetOptions {} export type ThermostatsSchedulesListParameters = RouteRequestBody<'/thermostats/schedules/list'> /** * @deprecated Use ThermostatsSchedulesListParameters instead. */ export type ThermostatsSchedulesListParams = ThermostatsSchedulesListParameters /** * @deprecated Use ThermostatsSchedulesListRequest instead. */ export type ThermostatsSchedulesListResponse = SetNonNullable< Required> > export type ThermostatsSchedulesListRequest = SeamHttpRequest< ThermostatsSchedulesListResponse, 'thermostat_schedules' > export interface ThermostatsSchedulesListOptions {} export type ThermostatsSchedulesUpdateParameters = RouteRequestBody<'/thermostats/schedules/update'> /** * @deprecated Use ThermostatsSchedulesUpdateParameters instead. */ export type ThermostatsSchedulesUpdateBody = ThermostatsSchedulesUpdateParameters /** * @deprecated Use ThermostatsSchedulesUpdateRequest instead. */ export type ThermostatsSchedulesUpdateResponse = SetNonNullable< Required> > export type ThermostatsSchedulesUpdateRequest = SeamHttpRequest export interface ThermostatsSchedulesUpdateOptions {}