Skip to content

Commit e0651c8

Browse files
committed
Only use POST or GET
1 parent 135e2a1 commit e0651c8

10 files changed

+33
-56
lines changed

generate-routes.ts

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@ const ignoredEndpointPaths = [
4141
'/noise_sensors/simulate/trigger_noise_threshold',
4242
]
4343

44-
const endpointMethods: Partial<Record<keyof typeof openapi.paths, Method>> = {
45-
'/access_codes/create_multiple': 'POST',
46-
'/access_codes/unmanaged/convert_to_managed': 'POST',
47-
// '/access_codes/update': 'PATCH',
48-
'/client_sessions/create': 'POST',
49-
// '/noise_sensors/noise_thresholds/update': 'PATCH',
50-
'/thermostats/climate_setting_schedules/delete': 'DELETE',
51-
// '/thermostats/climate_setting_schedules/update': 'PATCH',
52-
}
53-
5444
const endpointResources: Partial<
5545
Record<
5646
keyof typeof openapi.paths,
@@ -150,7 +140,7 @@ const createEndpoint = (
150140
throw new Error(`Did not find ${endpointPath} in OpenAPI spec`)
151141
}
152142
const spec = openapi.paths[endpointPath]
153-
const method = deriveSemanticMethod(endpointPath, Object.keys(spec))
143+
const method = deriveSemanticMethod(Object.keys(spec))
154144
const name = endpointPath.split(routePath)[1]?.slice(1)
155145
if (name == null) {
156146
throw new Error(`Could not parse name from ${endpointPath}`)
@@ -200,21 +190,8 @@ const deriveGroupFromRoutePath = (routePath: string): string | undefined => {
200190
return parts[0]
201191
}
202192

203-
const deriveSemanticMethod = (
204-
endpointPath: string,
205-
methods: string[],
206-
): Method => {
207-
if (isEndpointMethod(endpointPath)) {
208-
const endpointMethod = endpointMethods[endpointPath]
209-
if (endpointMethod == null) {
210-
throw new Error(`Got undefined method for ${endpointMethod}`)
211-
}
212-
return endpointMethod
213-
}
193+
const deriveSemanticMethod = (methods: string[]): Method => {
214194
if (methods.includes('get')) return 'GET'
215-
if (methods.includes('delete')) return 'DELETE'
216-
if (methods.includes('patch')) return 'PATCH'
217-
if (methods.includes('put')) return 'PUT'
218195
if (methods.includes('post')) return 'POST'
219196
throw new Error(`Could not find valid method in ${methods.join(', ')}`)
220197
}
@@ -223,9 +200,6 @@ const isEndpointResource = (
223200
key: string,
224201
): key is keyof typeof endpointResources => key in endpointResources
225202

226-
const isEndpointMethod = (key: string): key is keyof typeof endpointMethods =>
227-
key in endpointMethods
228-
229203
const isOpenApiPath = (key: string): key is keyof typeof openapi.paths =>
230204
key in openapi.paths
231205

src/lib/seam/connect/routes/access-codes-unmanaged.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class SeamHttpAccessCodesUnmanaged {
110110
async update(body: AccessCodesUnmanagedUpdateBody): Promise<void> {
111111
await this.client.request<AccessCodesUnmanagedUpdateResponse>({
112112
url: '/access_codes/unmanaged/update',
113-
method: 'patch',
113+
method: 'post',
114114
data: body,
115115
})
116116
}

src/lib/seam/connect/routes/access-codes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class SeamHttpAccessCodes {
149149
async update(body: AccessCodesUpdateBody): Promise<void> {
150150
await this.client.request<AccessCodesUpdateResponse>({
151151
url: '/access_codes/update',
152-
method: 'put',
152+
method: 'post',
153153
data: body,
154154
})
155155
}

src/lib/seam/connect/routes/acs-access-groups.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,15 @@ export class SeamHttpAcsAccessGroups {
6464
return new SeamHttpAcsAccessGroups(opts)
6565
}
6666

67-
async addUser(body: AcsAccessGroupsAddUserBody): Promise<void> {
68-
await this.client.request<AcsAccessGroupsAddUserResponse>({
67+
async addUser(
68+
body: AcsAccessGroupsAddUserBody,
69+
): Promise<AcsAccessGroupsAddUserResponse['acs_access_group']> {
70+
const { data } = await this.client.request<AcsAccessGroupsAddUserResponse>({
6971
url: '/acs/access_groups/add_user',
70-
method: 'patch',
72+
method: 'post',
7173
data: body,
7274
})
75+
return data.acs_access_group
7376
}
7477

7578
async create(
@@ -136,7 +139,7 @@ export class SeamHttpAcsAccessGroups {
136139
async update(body: AcsAccessGroupsUpdateBody): Promise<void> {
137140
await this.client.request<AcsAccessGroupsUpdateResponse>({
138141
url: '/acs/access_groups/update',
139-
method: 'patch',
142+
method: 'post',
140143
data: body,
141144
})
142145
}

src/lib/seam/connect/routes/acs-users.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class SeamHttpAcsUsers {
6767
async addToAccessGroup(body: AcsUsersAddToAccessGroupBody): Promise<void> {
6868
await this.client.request<AcsUsersAddToAccessGroupResponse>({
6969
url: '/acs/users/add_to_access_group',
70-
method: 'patch',
70+
method: 'post',
7171
data: body,
7272
})
7373
}
@@ -124,7 +124,7 @@ export class SeamHttpAcsUsers {
124124
async update(body: AcsUsersUpdateBody): Promise<void> {
125125
await this.client.request<AcsUsersUpdateResponse>({
126126
url: '/acs/users/update',
127-
method: 'patch',
127+
method: 'post',
128128
data: body,
129129
})
130130
}

src/lib/seam/connect/routes/client-sessions.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,16 @@ export class SeamHttpClientSessions {
9494
return data.client_session
9595
}
9696

97-
async grantAccess(body: ClientSessionsGrantAccessBody): Promise<void> {
98-
await this.client.request<ClientSessionsGrantAccessResponse>({
99-
url: '/client_sessions/grant_access',
100-
method: 'patch',
101-
data: body,
102-
})
97+
async grantAccess(
98+
body: ClientSessionsGrantAccessBody,
99+
): Promise<ClientSessionsGrantAccessResponse['client_session']> {
100+
const { data } =
101+
await this.client.request<ClientSessionsGrantAccessResponse>({
102+
url: '/client_sessions/grant_access',
103+
method: 'post',
104+
data: body,
105+
})
106+
return data.client_session
103107
}
104108

105109
async list(

src/lib/seam/connect/routes/devices-unmanaged.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class SeamHttpDevicesUnmanaged {
8989
async update(body: DevicesUnmanagedUpdateBody): Promise<void> {
9090
await this.client.request<DevicesUnmanagedUpdateResponse>({
9191
url: '/devices/unmanaged/update',
92-
method: 'patch',
92+
method: 'post',
9393
data: body,
9494
})
9595
}

src/lib/seam/connect/routes/devices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class SeamHttpDevices {
105105
async update(body: DevicesUpdateBody): Promise<void> {
106106
await this.client.request<DevicesUpdateResponse>({
107107
url: '/devices/update',
108-
method: 'patch',
108+
method: 'post',
109109
data: body,
110110
})
111111
}

src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class SeamHttpNoiseSensorsNoiseThresholds {
107107
async update(body: NoiseSensorsNoiseThresholdsUpdateBody): Promise<void> {
108108
await this.client.request<NoiseSensorsNoiseThresholdsUpdateResponse>({
109109
url: '/noise_sensors/noise_thresholds/update',
110-
method: 'put',
110+
method: 'post',
111111
data: body,
112112
})
113113
}

src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
* Do not edit this file or add other files to this directory.
44
*/
55

6-
import type {
7-
RouteRequestBody,
8-
RouteRequestParams,
9-
RouteResponse,
10-
} from '@seamapi/types/connect'
6+
import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect'
117
import type { Axios } from 'axios'
128
import type { SetNonNullable } from 'type-fest'
139

@@ -85,13 +81,13 @@ export class SeamHttpThermostatsClimateSettingSchedules {
8581
}
8682

8783
async delete(
88-
params?: ThermostatsClimateSettingSchedulesDeleteParams,
84+
body: ThermostatsClimateSettingSchedulesDeleteBody,
8985
): Promise<void> {
9086
await this.client.request<ThermostatsClimateSettingSchedulesDeleteResponse>(
9187
{
9288
url: '/thermostats/climate_setting_schedules/delete',
93-
method: 'delete',
94-
params,
89+
method: 'post',
90+
data: body,
9591
},
9692
)
9793
}
@@ -132,7 +128,7 @@ export class SeamHttpThermostatsClimateSettingSchedules {
132128
await this.client.request<ThermostatsClimateSettingSchedulesUpdateResponse>(
133129
{
134130
url: '/thermostats/climate_setting_schedules/update',
135-
method: 'put',
131+
method: 'post',
136132
data: body,
137133
},
138134
)
@@ -147,8 +143,8 @@ export type ThermostatsClimateSettingSchedulesCreateResponse = SetNonNullable<
147143
Required<RouteResponse<'/thermostats/climate_setting_schedules/create'>>
148144
>
149145

150-
export type ThermostatsClimateSettingSchedulesDeleteParams = SetNonNullable<
151-
Required<RouteRequestParams<'/thermostats/climate_setting_schedules/delete'>>
146+
export type ThermostatsClimateSettingSchedulesDeleteBody = SetNonNullable<
147+
Required<RouteRequestBody<'/thermostats/climate_setting_schedules/delete'>>
152148
>
153149

154150
export type ThermostatsClimateSettingSchedulesDeleteResponse = SetNonNullable<

0 commit comments

Comments
 (0)