@seamapi/http 0.23.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +15 -0
  2. package/dist/connect.cjs +847 -727
  3. package/dist/connect.cjs.map +1 -1
  4. package/dist/connect.d.cts +167 -126
  5. package/lib/seam/connect/routes/access-codes-unmanaged.d.ts +6 -5
  6. package/lib/seam/connect/routes/access-codes-unmanaged.js +26 -22
  7. package/lib/seam/connect/routes/access-codes-unmanaged.js.map +1 -1
  8. package/lib/seam/connect/routes/access-codes.d.ts +9 -8
  9. package/lib/seam/connect/routes/access-codes.js +41 -38
  10. package/lib/seam/connect/routes/access-codes.js.map +1 -1
  11. package/lib/seam/connect/routes/acs-access-groups.d.ts +6 -5
  12. package/lib/seam/connect/routes/acs-access-groups.js +26 -23
  13. package/lib/seam/connect/routes/acs-access-groups.js.map +1 -1
  14. package/lib/seam/connect/routes/acs-credential-pools.d.ts +2 -1
  15. package/lib/seam/connect/routes/acs-credential-pools.js +6 -5
  16. package/lib/seam/connect/routes/acs-credential-pools.js.map +1 -1
  17. package/lib/seam/connect/routes/acs-credential-provisioning-automations.d.ts +2 -1
  18. package/lib/seam/connect/routes/acs-credential-provisioning-automations.js +6 -5
  19. package/lib/seam/connect/routes/acs-credential-provisioning-automations.js.map +1 -1
  20. package/lib/seam/connect/routes/acs-credentials.d.ts +8 -7
  21. package/lib/seam/connect/routes/acs-credentials.js +36 -34
  22. package/lib/seam/connect/routes/acs-credentials.js.map +1 -1
  23. package/lib/seam/connect/routes/acs-entrances.d.ts +5 -4
  24. package/lib/seam/connect/routes/acs-entrances.js +21 -19
  25. package/lib/seam/connect/routes/acs-entrances.js.map +1 -1
  26. package/lib/seam/connect/routes/acs-systems.d.ts +3 -2
  27. package/lib/seam/connect/routes/acs-systems.js +11 -10
  28. package/lib/seam/connect/routes/acs-systems.js.map +1 -1
  29. package/lib/seam/connect/routes/acs-users.d.ts +12 -11
  30. package/lib/seam/connect/routes/acs-users.js +56 -48
  31. package/lib/seam/connect/routes/acs-users.js.map +1 -1
  32. package/lib/seam/connect/routes/action-attempts.d.ts +3 -2
  33. package/lib/seam/connect/routes/action-attempts.js +12 -18
  34. package/lib/seam/connect/routes/action-attempts.js.map +1 -1
  35. package/lib/seam/connect/routes/client-sessions.d.ts +8 -7
  36. package/lib/seam/connect/routes/client-sessions.js +36 -33
  37. package/lib/seam/connect/routes/client-sessions.js.map +1 -1
  38. package/lib/seam/connect/routes/connect-webviews.d.ts +6 -5
  39. package/lib/seam/connect/routes/connect-webviews.js +25 -22
  40. package/lib/seam/connect/routes/connect-webviews.js.map +1 -1
  41. package/lib/seam/connect/routes/connected-accounts.d.ts +5 -4
  42. package/lib/seam/connect/routes/connected-accounts.js +21 -19
  43. package/lib/seam/connect/routes/connected-accounts.js.map +1 -1
  44. package/lib/seam/connect/routes/devices-simulate.d.ts +21 -0
  45. package/lib/seam/connect/routes/devices-simulate.js +88 -0
  46. package/lib/seam/connect/routes/devices-simulate.js.map +1 -0
  47. package/lib/seam/connect/routes/devices-unmanaged.d.ts +4 -3
  48. package/lib/seam/connect/routes/devices-unmanaged.js +16 -14
  49. package/lib/seam/connect/routes/devices-unmanaged.js.map +1 -1
  50. package/lib/seam/connect/routes/devices.d.ts +8 -5
  51. package/lib/seam/connect/routes/devices.js +30 -23
  52. package/lib/seam/connect/routes/devices.js.map +1 -1
  53. package/lib/seam/connect/routes/events.d.ts +3 -2
  54. package/lib/seam/connect/routes/events.js +11 -10
  55. package/lib/seam/connect/routes/events.js.map +1 -1
  56. package/lib/seam/connect/routes/index.d.ts +1 -0
  57. package/lib/seam/connect/routes/index.js +1 -0
  58. package/lib/seam/connect/routes/index.js.map +1 -1
  59. package/lib/seam/connect/routes/locks.d.ts +5 -4
  60. package/lib/seam/connect/routes/locks.js +23 -36
  61. package/lib/seam/connect/routes/locks.js.map +1 -1
  62. package/lib/seam/connect/routes/networks.d.ts +3 -2
  63. package/lib/seam/connect/routes/networks.js +11 -10
  64. package/lib/seam/connect/routes/networks.js.map +1 -1
  65. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +6 -5
  66. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js +26 -23
  67. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -1
  68. package/lib/seam/connect/routes/phones-simulate.d.ts +2 -1
  69. package/lib/seam/connect/routes/phones-simulate.js +6 -5
  70. package/lib/seam/connect/routes/phones-simulate.js.map +1 -1
  71. package/lib/seam/connect/routes/phones.d.ts +3 -2
  72. package/lib/seam/connect/routes/phones.js +11 -9
  73. package/lib/seam/connect/routes/phones.js.map +1 -1
  74. package/lib/seam/connect/routes/thermostats-climate-setting-schedules.d.ts +6 -5
  75. package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js +26 -23
  76. package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js.map +1 -1
  77. package/lib/seam/connect/routes/thermostats.d.ts +9 -8
  78. package/lib/seam/connect/routes/thermostats.js +46 -76
  79. package/lib/seam/connect/routes/thermostats.js.map +1 -1
  80. package/lib/seam/connect/routes/user-identities-enrollment-automations.d.ts +5 -4
  81. package/lib/seam/connect/routes/user-identities-enrollment-automations.js +21 -19
  82. package/lib/seam/connect/routes/user-identities-enrollment-automations.js.map +1 -1
  83. package/lib/seam/connect/routes/user-identities.d.ts +13 -12
  84. package/lib/seam/connect/routes/user-identities.js +61 -54
  85. package/lib/seam/connect/routes/user-identities.js.map +1 -1
  86. package/lib/seam/connect/routes/webhooks.d.ts +6 -5
  87. package/lib/seam/connect/routes/webhooks.js +26 -23
  88. package/lib/seam/connect/routes/webhooks.js.map +1 -1
  89. package/lib/seam/connect/routes/workspaces.d.ts +5 -4
  90. package/lib/seam/connect/routes/workspaces.js +21 -19
  91. package/lib/seam/connect/routes/workspaces.js.map +1 -1
  92. package/lib/seam/connect/seam-http-request.d.ts +26 -0
  93. package/lib/seam/connect/seam-http-request.js +87 -0
  94. package/lib/seam/connect/seam-http-request.js.map +1 -0
  95. package/lib/version.d.ts +1 -1
  96. package/lib/version.js +1 -1
  97. package/package.json +4 -4
  98. package/src/lib/seam/connect/routes/access-codes-unmanaged.ts +37 -34
  99. package/src/lib/seam/connect/routes/access-codes.ts +56 -60
  100. package/src/lib/seam/connect/routes/acs-access-groups.ts +33 -32
  101. package/src/lib/seam/connect/routes/acs-credential-pools.ts +7 -7
  102. package/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts +11 -13
  103. package/src/lib/seam/connect/routes/acs-credentials.ts +42 -46
  104. package/src/lib/seam/connect/routes/acs-entrances.ts +31 -28
  105. package/src/lib/seam/connect/routes/acs-systems.ts +13 -14
  106. package/src/lib/seam/connect/routes/acs-users.ts +66 -61
  107. package/src/lib/seam/connect/routes/action-attempts.ts +14 -26
  108. package/src/lib/seam/connect/routes/client-sessions.ts +45 -49
  109. package/src/lib/seam/connect/routes/connect-webviews.ts +28 -28
  110. package/src/lib/seam/connect/routes/connected-accounts.ts +26 -29
  111. package/src/lib/seam/connect/routes/devices-simulate.ts +174 -0
  112. package/src/lib/seam/connect/routes/devices-unmanaged.ts +18 -18
  113. package/src/lib/seam/connect/routes/devices.ts +35 -31
  114. package/src/lib/seam/connect/routes/events.ts +11 -12
  115. package/src/lib/seam/connect/routes/index.ts +1 -0
  116. package/src/lib/seam/connect/routes/locks.ts +25 -50
  117. package/src/lib/seam/connect/routes/networks.ts +14 -13
  118. package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +48 -38
  119. package/src/lib/seam/connect/routes/phones-simulate.ts +9 -10
  120. package/src/lib/seam/connect/routes/phones.ts +11 -10
  121. package/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +47 -55
  122. package/src/lib/seam/connect/routes/thermostats.ts +53 -110
  123. package/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts +39 -48
  124. package/src/lib/seam/connect/routes/user-identities.ts +81 -78
  125. package/src/lib/seam/connect/routes/webhooks.ts +30 -28
  126. package/src/lib/seam/connect/routes/workspaces.ts +26 -25
  127. package/src/lib/seam/connect/seam-http-request.ts +144 -0
  128. package/src/lib/version.ts +1 -1
@@ -31,6 +31,7 @@ import {
31
31
  limitToSeamHttpRequestOptions,
32
32
  parseOptions,
33
33
  } from 'lib/seam/connect/parse-options.js'
34
+ import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
34
35
 
35
36
  import { SeamHttpClientSessions } from './client-sessions.js'
36
37
 
@@ -153,26 +154,26 @@ export class SeamHttpNetworks {
153
154
  await clientSessions.get()
154
155
  }
155
156
 
156
- async get(body?: NetworksGetParams): Promise<NetworksGetResponse['network']> {
157
- const { data } = await this.client.request<NetworksGetResponse>({
158
- url: '/networks/get',
157
+ get(
158
+ body?: NetworksGetParams,
159
+ ): SeamHttpRequest<NetworksGetResponse, 'network'> {
160
+ return new SeamHttpRequest(this, {
161
+ path: '/networks/get',
159
162
  method: 'post',
160
- data: body,
163
+ body,
164
+ responseKey: 'network',
161
165
  })
162
-
163
- return data.network
164
166
  }
165
167
 
166
- async list(
168
+ list(
167
169
  body?: NetworksListParams,
168
- ): Promise<NetworksListResponse['networks']> {
169
- const { data } = await this.client.request<NetworksListResponse>({
170
- url: '/networks/list',
170
+ ): SeamHttpRequest<NetworksListResponse, 'networks'> {
171
+ return new SeamHttpRequest(this, {
172
+ path: '/networks/list',
171
173
  method: 'post',
172
- data: body,
174
+ body,
175
+ responseKey: 'networks',
173
176
  })
174
-
175
- return data.networks
176
177
  }
177
178
  }
178
179
 
@@ -31,6 +31,7 @@ import {
31
31
  limitToSeamHttpRequestOptions,
32
32
  parseOptions,
33
33
  } from 'lib/seam/connect/parse-options.js'
34
+ import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
34
35
 
35
36
  import { SeamHttpClientSessions } from './client-sessions.js'
36
37
 
@@ -156,58 +157,67 @@ export class SeamHttpNoiseSensorsNoiseThresholds {
156
157
  await clientSessions.get()
157
158
  }
158
159
 
159
- async create(
160
+ create(
160
161
  body?: NoiseSensorsNoiseThresholdsCreateBody,
161
- ): Promise<NoiseSensorsNoiseThresholdsCreateResponse['noise_threshold']> {
162
- const { data } =
163
- await this.client.request<NoiseSensorsNoiseThresholdsCreateResponse>({
164
- url: '/noise_sensors/noise_thresholds/create',
165
- method: 'post',
166
- data: body,
167
- })
168
-
169
- return data.noise_threshold
162
+ ): SeamHttpRequest<
163
+ NoiseSensorsNoiseThresholdsCreateResponse,
164
+ 'noise_threshold'
165
+ > {
166
+ return new SeamHttpRequest(this, {
167
+ path: '/noise_sensors/noise_thresholds/create',
168
+ method: 'post',
169
+ body,
170
+ responseKey: 'noise_threshold',
171
+ })
170
172
  }
171
173
 
172
- async delete(body?: NoiseSensorsNoiseThresholdsDeleteBody): Promise<void> {
173
- await this.client.request<NoiseSensorsNoiseThresholdsDeleteResponse>({
174
- url: '/noise_sensors/noise_thresholds/delete',
174
+ delete(
175
+ body?: NoiseSensorsNoiseThresholdsDeleteBody,
176
+ ): SeamHttpRequest<void, undefined> {
177
+ return new SeamHttpRequest(this, {
178
+ path: '/noise_sensors/noise_thresholds/delete',
175
179
  method: 'post',
176
- data: body,
180
+ body,
181
+ responseKey: undefined,
177
182
  })
178
183
  }
179
184
 
180
- async get(
185
+ get(
181
186
  body?: NoiseSensorsNoiseThresholdsGetParams,
182
- ): Promise<NoiseSensorsNoiseThresholdsGetResponse['noise_threshold']> {
183
- const { data } =
184
- await this.client.request<NoiseSensorsNoiseThresholdsGetResponse>({
185
- url: '/noise_sensors/noise_thresholds/get',
186
- method: 'post',
187
- data: body,
188
- })
189
-
190
- return data.noise_threshold
187
+ ): SeamHttpRequest<
188
+ NoiseSensorsNoiseThresholdsGetResponse,
189
+ 'noise_threshold'
190
+ > {
191
+ return new SeamHttpRequest(this, {
192
+ path: '/noise_sensors/noise_thresholds/get',
193
+ method: 'post',
194
+ body,
195
+ responseKey: 'noise_threshold',
196
+ })
191
197
  }
192
198
 
193
- async list(
199
+ list(
194
200
  body?: NoiseSensorsNoiseThresholdsListParams,
195
- ): Promise<NoiseSensorsNoiseThresholdsListResponse['noise_thresholds']> {
196
- const { data } =
197
- await this.client.request<NoiseSensorsNoiseThresholdsListResponse>({
198
- url: '/noise_sensors/noise_thresholds/list',
199
- method: 'post',
200
- data: body,
201
- })
202
-
203
- return data.noise_thresholds
201
+ ): SeamHttpRequest<
202
+ NoiseSensorsNoiseThresholdsListResponse,
203
+ 'noise_thresholds'
204
+ > {
205
+ return new SeamHttpRequest(this, {
206
+ path: '/noise_sensors/noise_thresholds/list',
207
+ method: 'post',
208
+ body,
209
+ responseKey: 'noise_thresholds',
210
+ })
204
211
  }
205
212
 
206
- async update(body?: NoiseSensorsNoiseThresholdsUpdateBody): Promise<void> {
207
- await this.client.request<NoiseSensorsNoiseThresholdsUpdateResponse>({
208
- url: '/noise_sensors/noise_thresholds/update',
213
+ update(
214
+ body?: NoiseSensorsNoiseThresholdsUpdateBody,
215
+ ): SeamHttpRequest<void, undefined> {
216
+ return new SeamHttpRequest(this, {
217
+ path: '/noise_sensors/noise_thresholds/update',
209
218
  method: 'post',
210
- data: body,
219
+ body,
220
+ responseKey: undefined,
211
221
  })
212
222
  }
213
223
  }
@@ -31,6 +31,7 @@ import {
31
31
  limitToSeamHttpRequestOptions,
32
32
  parseOptions,
33
33
  } from 'lib/seam/connect/parse-options.js'
34
+ import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
34
35
 
35
36
  import { SeamHttpClientSessions } from './client-sessions.js'
36
37
 
@@ -153,17 +154,15 @@ export class SeamHttpPhonesSimulate {
153
154
  await clientSessions.get()
154
155
  }
155
156
 
156
- async createSandboxPhone(
157
+ createSandboxPhone(
157
158
  body?: PhonesSimulateCreateSandboxPhoneBody,
158
- ): Promise<PhonesSimulateCreateSandboxPhoneResponse['phone']> {
159
- const { data } =
160
- await this.client.request<PhonesSimulateCreateSandboxPhoneResponse>({
161
- url: '/phones/simulate/create_sandbox_phone',
162
- method: 'post',
163
- data: body,
164
- })
165
-
166
- return data.phone
159
+ ): SeamHttpRequest<PhonesSimulateCreateSandboxPhoneResponse, 'phone'> {
160
+ return new SeamHttpRequest(this, {
161
+ path: '/phones/simulate/create_sandbox_phone',
162
+ method: 'post',
163
+ body,
164
+ responseKey: 'phone',
165
+ })
167
166
  }
168
167
  }
169
168
 
@@ -31,6 +31,7 @@ import {
31
31
  limitToSeamHttpRequestOptions,
32
32
  parseOptions,
33
33
  } from 'lib/seam/connect/parse-options.js'
34
+ import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
34
35
 
35
36
  import { SeamHttpClientSessions } from './client-sessions.js'
36
37
  import { SeamHttpPhonesSimulate } from './phones-simulate.js'
@@ -158,22 +159,22 @@ export class SeamHttpPhones {
158
159
  return SeamHttpPhonesSimulate.fromClient(this.client, this.defaults)
159
160
  }
160
161
 
161
- async deactivate(body?: PhonesDeactivateBody): Promise<void> {
162
- await this.client.request<PhonesDeactivateResponse>({
163
- url: '/phones/deactivate',
162
+ deactivate(body?: PhonesDeactivateBody): SeamHttpRequest<void, undefined> {
163
+ return new SeamHttpRequest(this, {
164
+ path: '/phones/deactivate',
164
165
  method: 'post',
165
- data: body,
166
+ body,
167
+ responseKey: undefined,
166
168
  })
167
169
  }
168
170
 
169
- async list(body?: PhonesListParams): Promise<PhonesListResponse['phones']> {
170
- const { data } = await this.client.request<PhonesListResponse>({
171
- url: '/phones/list',
171
+ list(body?: PhonesListParams): SeamHttpRequest<PhonesListResponse, 'phones'> {
172
+ return new SeamHttpRequest(this, {
173
+ path: '/phones/list',
172
174
  method: 'post',
173
- data: body,
175
+ body,
176
+ responseKey: 'phones',
174
177
  })
175
-
176
- return data.phones
177
178
  }
178
179
  }
179
180
 
@@ -31,6 +31,7 @@ import {
31
31
  limitToSeamHttpRequestOptions,
32
32
  parseOptions,
33
33
  } from 'lib/seam/connect/parse-options.js'
34
+ import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
34
35
 
35
36
  import { SeamHttpClientSessions } from './client-sessions.js'
36
37
 
@@ -156,77 +157,68 @@ export class SeamHttpThermostatsClimateSettingSchedules {
156
157
  await clientSessions.get()
157
158
  }
158
159
 
159
- async create(
160
+ create(
160
161
  body?: ThermostatsClimateSettingSchedulesCreateBody,
161
- ): Promise<
162
- ThermostatsClimateSettingSchedulesCreateResponse['climate_setting_schedule']
162
+ ): SeamHttpRequest<
163
+ ThermostatsClimateSettingSchedulesCreateResponse,
164
+ 'climate_setting_schedule'
163
165
  > {
164
- const { data } =
165
- await this.client.request<ThermostatsClimateSettingSchedulesCreateResponse>(
166
- {
167
- url: '/thermostats/climate_setting_schedules/create',
168
- method: 'post',
169
- data: body,
170
- },
171
- )
172
-
173
- return data.climate_setting_schedule
166
+ return new SeamHttpRequest(this, {
167
+ path: '/thermostats/climate_setting_schedules/create',
168
+ method: 'post',
169
+ body,
170
+ responseKey: 'climate_setting_schedule',
171
+ })
174
172
  }
175
173
 
176
- async delete(
174
+ delete(
177
175
  body?: ThermostatsClimateSettingSchedulesDeleteBody,
178
- ): Promise<void> {
179
- await this.client.request<ThermostatsClimateSettingSchedulesDeleteResponse>(
180
- {
181
- url: '/thermostats/climate_setting_schedules/delete',
182
- method: 'post',
183
- data: body,
184
- },
185
- )
176
+ ): SeamHttpRequest<void, undefined> {
177
+ return new SeamHttpRequest(this, {
178
+ path: '/thermostats/climate_setting_schedules/delete',
179
+ method: 'post',
180
+ body,
181
+ responseKey: undefined,
182
+ })
186
183
  }
187
184
 
188
- async get(
185
+ get(
189
186
  body?: ThermostatsClimateSettingSchedulesGetParams,
190
- ): Promise<
191
- ThermostatsClimateSettingSchedulesGetResponse['climate_setting_schedule']
187
+ ): SeamHttpRequest<
188
+ ThermostatsClimateSettingSchedulesGetResponse,
189
+ 'climate_setting_schedule'
192
190
  > {
193
- const { data } =
194
- await this.client.request<ThermostatsClimateSettingSchedulesGetResponse>({
195
- url: '/thermostats/climate_setting_schedules/get',
196
- method: 'post',
197
- data: body,
198
- })
199
-
200
- return data.climate_setting_schedule
191
+ return new SeamHttpRequest(this, {
192
+ path: '/thermostats/climate_setting_schedules/get',
193
+ method: 'post',
194
+ body,
195
+ responseKey: 'climate_setting_schedule',
196
+ })
201
197
  }
202
198
 
203
- async list(
199
+ list(
204
200
  body?: ThermostatsClimateSettingSchedulesListParams,
205
- ): Promise<
206
- ThermostatsClimateSettingSchedulesListResponse['climate_setting_schedules']
201
+ ): SeamHttpRequest<
202
+ ThermostatsClimateSettingSchedulesListResponse,
203
+ 'climate_setting_schedules'
207
204
  > {
208
- const { data } =
209
- await this.client.request<ThermostatsClimateSettingSchedulesListResponse>(
210
- {
211
- url: '/thermostats/climate_setting_schedules/list',
212
- method: 'post',
213
- data: body,
214
- },
215
- )
216
-
217
- return data.climate_setting_schedules
205
+ return new SeamHttpRequest(this, {
206
+ path: '/thermostats/climate_setting_schedules/list',
207
+ method: 'post',
208
+ body,
209
+ responseKey: 'climate_setting_schedules',
210
+ })
218
211
  }
219
212
 
220
- async update(
213
+ update(
221
214
  body?: ThermostatsClimateSettingSchedulesUpdateBody,
222
- ): Promise<void> {
223
- await this.client.request<ThermostatsClimateSettingSchedulesUpdateResponse>(
224
- {
225
- url: '/thermostats/climate_setting_schedules/update',
226
- method: 'post',
227
- data: body,
228
- },
229
- )
215
+ ): SeamHttpRequest<void, undefined> {
216
+ return new SeamHttpRequest(this, {
217
+ path: '/thermostats/climate_setting_schedules/update',
218
+ method: 'post',
219
+ body,
220
+ responseKey: undefined,
221
+ })
230
222
  }
231
223
  }
232
224
 
@@ -31,9 +31,8 @@ import {
31
31
  limitToSeamHttpRequestOptions,
32
32
  parseOptions,
33
33
  } from 'lib/seam/connect/parse-options.js'
34
- import { resolveActionAttempt } from 'lib/seam/connect/resolve-action-attempt.js'
34
+ import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
35
35
 
36
- import { SeamHttpActionAttempts } from './action-attempts.js'
37
36
  import { SeamHttpClientSessions } from './client-sessions.js'
38
37
  import { SeamHttpThermostatsClimateSettingSchedules } from './thermostats-climate-setting-schedules.js'
39
38
 
@@ -163,155 +162,99 @@ export class SeamHttpThermostats {
163
162
  )
164
163
  }
165
164
 
166
- async cool(
165
+ cool(
167
166
  body?: ThermostatsCoolBody,
168
167
  options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'> = {},
169
- ): Promise<ThermostatsCoolResponse['action_attempt']> {
170
- const { data } = await this.client.request<ThermostatsCoolResponse>({
171
- url: '/thermostats/cool',
168
+ ): SeamHttpRequest<ThermostatsCoolResponse, 'action_attempt'> {
169
+ return new SeamHttpRequest(this, {
170
+ path: '/thermostats/cool',
172
171
  method: 'post',
173
- data: body,
172
+ body,
173
+ responseKey: 'action_attempt',
174
+ options,
174
175
  })
175
- const waitForActionAttempt =
176
- options.waitForActionAttempt ?? this.defaults.waitForActionAttempt
177
- if (waitForActionAttempt !== false) {
178
- return await resolveActionAttempt(
179
- data.action_attempt,
180
- SeamHttpActionAttempts.fromClient(this.client, {
181
- ...this.defaults,
182
- waitForActionAttempt: false,
183
- }),
184
- typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt,
185
- )
186
- }
187
- return data.action_attempt
188
176
  }
189
177
 
190
- async get(
178
+ get(
191
179
  body?: ThermostatsGetParams,
192
- ): Promise<ThermostatsGetResponse['thermostat']> {
193
- const { data } = await this.client.request<ThermostatsGetResponse>({
194
- url: '/thermostats/get',
180
+ ): SeamHttpRequest<ThermostatsGetResponse, 'thermostat'> {
181
+ return new SeamHttpRequest(this, {
182
+ path: '/thermostats/get',
195
183
  method: 'post',
196
- data: body,
184
+ body,
185
+ responseKey: 'thermostat',
197
186
  })
198
-
199
- return data.thermostat
200
187
  }
201
188
 
202
- async heat(
189
+ heat(
203
190
  body?: ThermostatsHeatBody,
204
191
  options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'> = {},
205
- ): Promise<ThermostatsHeatResponse['action_attempt']> {
206
- const { data } = await this.client.request<ThermostatsHeatResponse>({
207
- url: '/thermostats/heat',
192
+ ): SeamHttpRequest<ThermostatsHeatResponse, 'action_attempt'> {
193
+ return new SeamHttpRequest(this, {
194
+ path: '/thermostats/heat',
208
195
  method: 'post',
209
- data: body,
196
+ body,
197
+ responseKey: 'action_attempt',
198
+ options,
210
199
  })
211
- const waitForActionAttempt =
212
- options.waitForActionAttempt ?? this.defaults.waitForActionAttempt
213
- if (waitForActionAttempt !== false) {
214
- return await resolveActionAttempt(
215
- data.action_attempt,
216
- SeamHttpActionAttempts.fromClient(this.client, {
217
- ...this.defaults,
218
- waitForActionAttempt: false,
219
- }),
220
- typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt,
221
- )
222
- }
223
- return data.action_attempt
224
200
  }
225
201
 
226
- async heatCool(
202
+ heatCool(
227
203
  body?: ThermostatsHeatCoolBody,
228
204
  options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'> = {},
229
- ): Promise<ThermostatsHeatCoolResponse['action_attempt']> {
230
- const { data } = await this.client.request<ThermostatsHeatCoolResponse>({
231
- url: '/thermostats/heat_cool',
205
+ ): SeamHttpRequest<ThermostatsHeatCoolResponse, 'action_attempt'> {
206
+ return new SeamHttpRequest(this, {
207
+ path: '/thermostats/heat_cool',
232
208
  method: 'post',
233
- data: body,
209
+ body,
210
+ responseKey: 'action_attempt',
211
+ options,
234
212
  })
235
- const waitForActionAttempt =
236
- options.waitForActionAttempt ?? this.defaults.waitForActionAttempt
237
- if (waitForActionAttempt !== false) {
238
- return await resolveActionAttempt(
239
- data.action_attempt,
240
- SeamHttpActionAttempts.fromClient(this.client, {
241
- ...this.defaults,
242
- waitForActionAttempt: false,
243
- }),
244
- typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt,
245
- )
246
- }
247
- return data.action_attempt
248
213
  }
249
214
 
250
- async list(
215
+ list(
251
216
  body?: ThermostatsListParams,
252
- ): Promise<ThermostatsListResponse['thermostats']> {
253
- const { data } = await this.client.request<ThermostatsListResponse>({
254
- url: '/thermostats/list',
217
+ ): SeamHttpRequest<ThermostatsListResponse, 'thermostats'> {
218
+ return new SeamHttpRequest(this, {
219
+ path: '/thermostats/list',
255
220
  method: 'post',
256
- data: body,
221
+ body,
222
+ responseKey: 'thermostats',
257
223
  })
258
-
259
- return data.thermostats
260
224
  }
261
225
 
262
- async off(
226
+ off(
263
227
  body?: ThermostatsOffBody,
264
228
  options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'> = {},
265
- ): Promise<ThermostatsOffResponse['action_attempt']> {
266
- const { data } = await this.client.request<ThermostatsOffResponse>({
267
- url: '/thermostats/off',
229
+ ): SeamHttpRequest<ThermostatsOffResponse, 'action_attempt'> {
230
+ return new SeamHttpRequest(this, {
231
+ path: '/thermostats/off',
268
232
  method: 'post',
269
- data: body,
233
+ body,
234
+ responseKey: 'action_attempt',
235
+ options,
270
236
  })
271
- const waitForActionAttempt =
272
- options.waitForActionAttempt ?? this.defaults.waitForActionAttempt
273
- if (waitForActionAttempt !== false) {
274
- return await resolveActionAttempt(
275
- data.action_attempt,
276
- SeamHttpActionAttempts.fromClient(this.client, {
277
- ...this.defaults,
278
- waitForActionAttempt: false,
279
- }),
280
- typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt,
281
- )
282
- }
283
- return data.action_attempt
284
237
  }
285
238
 
286
- async setFanMode(
239
+ setFanMode(
287
240
  body?: ThermostatsSetFanModeBody,
288
241
  options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'> = {},
289
- ): Promise<ThermostatsSetFanModeResponse['action_attempt']> {
290
- const { data } = await this.client.request<ThermostatsSetFanModeResponse>({
291
- url: '/thermostats/set_fan_mode',
242
+ ): SeamHttpRequest<ThermostatsSetFanModeResponse, 'action_attempt'> {
243
+ return new SeamHttpRequest(this, {
244
+ path: '/thermostats/set_fan_mode',
292
245
  method: 'post',
293
- data: body,
246
+ body,
247
+ responseKey: 'action_attempt',
248
+ options,
294
249
  })
295
- const waitForActionAttempt =
296
- options.waitForActionAttempt ?? this.defaults.waitForActionAttempt
297
- if (waitForActionAttempt !== false) {
298
- return await resolveActionAttempt(
299
- data.action_attempt,
300
- SeamHttpActionAttempts.fromClient(this.client, {
301
- ...this.defaults,
302
- waitForActionAttempt: false,
303
- }),
304
- typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt,
305
- )
306
- }
307
- return data.action_attempt
308
250
  }
309
251
 
310
- async update(body?: ThermostatsUpdateBody): Promise<void> {
311
- await this.client.request<ThermostatsUpdateResponse>({
312
- url: '/thermostats/update',
252
+ update(body?: ThermostatsUpdateBody): SeamHttpRequest<void, undefined> {
253
+ return new SeamHttpRequest(this, {
254
+ path: '/thermostats/update',
313
255
  method: 'post',
314
- data: body,
256
+ body,
257
+ responseKey: undefined,
315
258
  })
316
259
  }
317
260
  }