@seamapi/http 0.13.0 → 0.14.1

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 (51) hide show
  1. package/README.md +3 -3
  2. package/dist/connect.cjs +296 -16
  3. package/dist/connect.cjs.map +1 -1
  4. package/dist/connect.d.cts +79 -12
  5. package/lib/seam/connect/parse-options.js +9 -0
  6. package/lib/seam/connect/parse-options.js.map +1 -1
  7. package/lib/seam/connect/routes/connected-accounts.d.ts +3 -3
  8. package/lib/seam/connect/routes/connected-accounts.js +3 -3
  9. package/lib/seam/connect/routes/connected-accounts.js.map +1 -1
  10. package/lib/seam/connect/routes/index.d.ts +3 -0
  11. package/lib/seam/connect/routes/index.js +3 -0
  12. package/lib/seam/connect/routes/index.js.map +1 -1
  13. package/lib/seam/connect/routes/networks.d.ts +23 -0
  14. package/lib/seam/connect/routes/networks.js +81 -0
  15. package/lib/seam/connect/routes/networks.js.map +1 -0
  16. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +1 -1
  17. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js +2 -1
  18. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -1
  19. package/lib/seam/connect/routes/phones.d.ts +19 -0
  20. package/lib/seam/connect/routes/phones.js +73 -0
  21. package/lib/seam/connect/routes/phones.js.map +1 -0
  22. package/lib/seam/connect/routes/user-identities-enrollment-automations.d.ts +27 -0
  23. package/lib/seam/connect/routes/user-identities-enrollment-automations.js +89 -0
  24. package/lib/seam/connect/routes/user-identities-enrollment-automations.js.map +1 -0
  25. package/lib/seam/connect/routes/user-identities.d.ts +9 -3
  26. package/lib/seam/connect/routes/user-identities.js +15 -3
  27. package/lib/seam/connect/routes/user-identities.js.map +1 -1
  28. package/lib/seam/connect/routes/webhooks.d.ts +3 -3
  29. package/lib/seam/connect/routes/webhooks.js +3 -3
  30. package/lib/seam/connect/routes/webhooks.js.map +1 -1
  31. package/lib/seam/connect/routes/workspaces.d.ts +5 -5
  32. package/lib/seam/connect/routes/workspaces.js +6 -6
  33. package/lib/seam/connect/routes/workspaces.js.map +1 -1
  34. package/lib/seam/connect/seam-http.d.ts +3 -1
  35. package/lib/seam/connect/seam-http.js +7 -1
  36. package/lib/seam/connect/seam-http.js.map +1 -1
  37. package/lib/version.d.ts +1 -1
  38. package/lib/version.js +1 -1
  39. package/package.json +3 -3
  40. package/src/lib/seam/connect/parse-options.ts +17 -0
  41. package/src/lib/seam/connect/routes/connected-accounts.ts +5 -9
  42. package/src/lib/seam/connect/routes/index.ts +3 -0
  43. package/src/lib/seam/connect/routes/networks.ts +171 -0
  44. package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +11 -6
  45. package/src/lib/seam/connect/routes/phones.ts +151 -0
  46. package/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts +214 -0
  47. package/src/lib/seam/connect/routes/user-identities.ts +35 -10
  48. package/src/lib/seam/connect/routes/webhooks.ts +5 -9
  49. package/src/lib/seam/connect/routes/workspaces.ts +9 -13
  50. package/src/lib/seam/connect/seam-http.ts +10 -0
  51. package/src/lib/version.ts +1 -1
@@ -3,11 +3,7 @@
3
3
  * Do not edit this file or add other files to this directory.
4
4
  */
5
5
 
6
- import type {
7
- RouteRequestBody,
8
- RouteRequestParams,
9
- RouteResponse,
10
- } from '@seamapi/types/connect'
6
+ import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect'
11
7
  import type { SetNonNullable } from 'type-fest'
12
8
 
13
9
  import { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
@@ -156,12 +152,12 @@ export class SeamHttpConnectedAccounts {
156
152
  }
157
153
 
158
154
  async list(
159
- params?: ConnectedAccountsListParams,
155
+ body?: ConnectedAccountsListParams,
160
156
  ): Promise<ConnectedAccountsListResponse['connected_accounts']> {
161
157
  const { data } = await this.client.request<ConnectedAccountsListResponse>({
162
158
  url: '/connected_accounts/list',
163
- method: 'get',
164
- params,
159
+ method: 'post',
160
+ data: body,
165
161
  })
166
162
 
167
163
  return data.connected_accounts
@@ -201,7 +197,7 @@ export type ConnectedAccountsGetResponse = SetNonNullable<
201
197
  export type ConnectedAccountsGetOptions = never
202
198
 
203
199
  export type ConnectedAccountsListParams =
204
- RouteRequestParams<'/connected_accounts/list'>
200
+ RouteRequestBody<'/connected_accounts/list'>
205
201
 
206
202
  export type ConnectedAccountsListResponse = SetNonNullable<
207
203
  Required<RouteResponse<'/connected_accounts/list'>>
@@ -16,10 +16,13 @@ export * from './devices.js'
16
16
  export * from './devices-unmanaged.js'
17
17
  export * from './events.js'
18
18
  export * from './locks.js'
19
+ export * from './networks.js'
19
20
  export * from './noise-sensors.js'
20
21
  export * from './noise-sensors-noise-thresholds.js'
22
+ export * from './phones.js'
21
23
  export * from './thermostats.js'
22
24
  export * from './thermostats-climate-setting-schedules.js'
23
25
  export * from './user-identities.js'
26
+ export * from './user-identities-enrollment-automations.js'
24
27
  export * from './webhooks.js'
25
28
  export * from './workspaces.js'
@@ -0,0 +1,171 @@
1
+ /*
2
+ * Automatically generated by generate-routes.ts.
3
+ * Do not edit this file or add other files to this directory.
4
+ */
5
+
6
+ import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect'
7
+ import type { SetNonNullable } from 'type-fest'
8
+
9
+ import { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
10
+ import { type Client, createClient } from 'lib/seam/connect/client.js'
11
+ import {
12
+ isSeamHttpOptionsWithApiKey,
13
+ isSeamHttpOptionsWithClient,
14
+ isSeamHttpOptionsWithClientSessionToken,
15
+ isSeamHttpOptionsWithConsoleSessionToken,
16
+ isSeamHttpOptionsWithPersonalAccessToken,
17
+ type SeamHttpFromPublishableKeyOptions,
18
+ SeamHttpInvalidOptionsError,
19
+ type SeamHttpOptions,
20
+ type SeamHttpOptionsWithApiKey,
21
+ type SeamHttpOptionsWithClient,
22
+ type SeamHttpOptionsWithClientSessionToken,
23
+ type SeamHttpOptionsWithConsoleSessionToken,
24
+ type SeamHttpOptionsWithPersonalAccessToken,
25
+ type SeamHttpRequestOptions,
26
+ } from 'lib/seam/connect/options.js'
27
+ import {
28
+ limitToSeamHttpRequestOptions,
29
+ parseOptions,
30
+ } from 'lib/seam/connect/parse-options.js'
31
+
32
+ import { SeamHttpClientSessions } from './client-sessions.js'
33
+
34
+ export class SeamHttpNetworks {
35
+ client: Client
36
+ readonly defaults: Required<SeamHttpRequestOptions>
37
+
38
+ constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
39
+ const options = parseOptions(apiKeyOrOptions)
40
+ this.client = 'client' in options ? options.client : createClient(options)
41
+ this.defaults = limitToSeamHttpRequestOptions(options)
42
+ }
43
+
44
+ static fromClient(
45
+ client: SeamHttpOptionsWithClient['client'],
46
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
47
+ ): SeamHttpNetworks {
48
+ const constructorOptions = { ...options, client }
49
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
50
+ throw new SeamHttpInvalidOptionsError('Missing client')
51
+ }
52
+ return new SeamHttpNetworks(constructorOptions)
53
+ }
54
+
55
+ static fromApiKey(
56
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
57
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
58
+ ): SeamHttpNetworks {
59
+ const constructorOptions = { ...options, apiKey }
60
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
61
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
62
+ }
63
+ return new SeamHttpNetworks(constructorOptions)
64
+ }
65
+
66
+ static fromClientSessionToken(
67
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
68
+ options: Omit<
69
+ SeamHttpOptionsWithClientSessionToken,
70
+ 'clientSessionToken'
71
+ > = {},
72
+ ): SeamHttpNetworks {
73
+ const constructorOptions = { ...options, clientSessionToken }
74
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
75
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
76
+ }
77
+ return new SeamHttpNetworks(constructorOptions)
78
+ }
79
+
80
+ static async fromPublishableKey(
81
+ publishableKey: string,
82
+ userIdentifierKey: string,
83
+ options: SeamHttpFromPublishableKeyOptions = {},
84
+ ): Promise<SeamHttpNetworks> {
85
+ warnOnInsecureuserIdentifierKey(userIdentifierKey)
86
+ const clientOptions = parseOptions({ ...options, publishableKey })
87
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
88
+ throw new SeamHttpInvalidOptionsError(
89
+ 'The client option cannot be used with SeamHttp.fromPublishableKey',
90
+ )
91
+ }
92
+ const client = createClient(clientOptions)
93
+ const clientSessions = SeamHttpClientSessions.fromClient(client)
94
+ const { token } = await clientSessions.getOrCreate({
95
+ user_identifier_key: userIdentifierKey,
96
+ })
97
+ return SeamHttpNetworks.fromClientSessionToken(token, options)
98
+ }
99
+
100
+ static fromConsoleSessionToken(
101
+ consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
102
+ workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
103
+ options: Omit<
104
+ SeamHttpOptionsWithConsoleSessionToken,
105
+ 'consoleSessionToken' | 'workspaceId'
106
+ > = {},
107
+ ): SeamHttpNetworks {
108
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId }
109
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
110
+ throw new SeamHttpInvalidOptionsError(
111
+ 'Missing consoleSessionToken or workspaceId',
112
+ )
113
+ }
114
+ return new SeamHttpNetworks(constructorOptions)
115
+ }
116
+
117
+ static fromPersonalAccessToken(
118
+ personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
119
+ workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
120
+ options: Omit<
121
+ SeamHttpOptionsWithPersonalAccessToken,
122
+ 'personalAccessToken' | 'workspaceId'
123
+ > = {},
124
+ ): SeamHttpNetworks {
125
+ const constructorOptions = { ...options, personalAccessToken, workspaceId }
126
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
127
+ throw new SeamHttpInvalidOptionsError(
128
+ 'Missing personalAccessToken or workspaceId',
129
+ )
130
+ }
131
+ return new SeamHttpNetworks(constructorOptions)
132
+ }
133
+
134
+ async get(body?: NetworksGetParams): Promise<NetworksGetResponse['network']> {
135
+ const { data } = await this.client.request<NetworksGetResponse>({
136
+ url: '/networks/get',
137
+ method: 'post',
138
+ data: body,
139
+ })
140
+
141
+ return data.network
142
+ }
143
+
144
+ async list(
145
+ body?: NetworksListParams,
146
+ ): Promise<NetworksListResponse['networks']> {
147
+ const { data } = await this.client.request<NetworksListResponse>({
148
+ url: '/networks/list',
149
+ method: 'post',
150
+ data: body,
151
+ })
152
+
153
+ return data.networks
154
+ }
155
+ }
156
+
157
+ export type NetworksGetParams = RouteRequestBody<'/networks/get'>
158
+
159
+ export type NetworksGetResponse = SetNonNullable<
160
+ Required<RouteResponse<'/networks/get'>>
161
+ >
162
+
163
+ export type NetworksGetOptions = never
164
+
165
+ export type NetworksListParams = RouteRequestBody<'/networks/list'>
166
+
167
+ export type NetworksListResponse = SetNonNullable<
168
+ Required<RouteResponse<'/networks/list'>>
169
+ >
170
+
171
+ export type NetworksListOptions = never
@@ -134,12 +134,17 @@ export class SeamHttpNoiseSensorsNoiseThresholds {
134
134
  return new SeamHttpNoiseSensorsNoiseThresholds(constructorOptions)
135
135
  }
136
136
 
137
- async create(body?: NoiseSensorsNoiseThresholdsCreateBody): Promise<void> {
138
- await this.client.request<NoiseSensorsNoiseThresholdsCreateResponse>({
139
- url: '/noise_sensors/noise_thresholds/create',
140
- method: 'post',
141
- data: body,
142
- })
137
+ async create(
138
+ body?: NoiseSensorsNoiseThresholdsCreateBody,
139
+ ): Promise<NoiseSensorsNoiseThresholdsCreateResponse['noise_threshold']> {
140
+ const { data } =
141
+ await this.client.request<NoiseSensorsNoiseThresholdsCreateResponse>({
142
+ url: '/noise_sensors/noise_thresholds/create',
143
+ method: 'post',
144
+ data: body,
145
+ })
146
+
147
+ return data.noise_threshold
143
148
  }
144
149
 
145
150
  async delete(body?: NoiseSensorsNoiseThresholdsDeleteBody): Promise<void> {
@@ -0,0 +1,151 @@
1
+ /*
2
+ * Automatically generated by generate-routes.ts.
3
+ * Do not edit this file or add other files to this directory.
4
+ */
5
+
6
+ import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect'
7
+ import type { SetNonNullable } from 'type-fest'
8
+
9
+ import { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
10
+ import { type Client, createClient } from 'lib/seam/connect/client.js'
11
+ import {
12
+ isSeamHttpOptionsWithApiKey,
13
+ isSeamHttpOptionsWithClient,
14
+ isSeamHttpOptionsWithClientSessionToken,
15
+ isSeamHttpOptionsWithConsoleSessionToken,
16
+ isSeamHttpOptionsWithPersonalAccessToken,
17
+ type SeamHttpFromPublishableKeyOptions,
18
+ SeamHttpInvalidOptionsError,
19
+ type SeamHttpOptions,
20
+ type SeamHttpOptionsWithApiKey,
21
+ type SeamHttpOptionsWithClient,
22
+ type SeamHttpOptionsWithClientSessionToken,
23
+ type SeamHttpOptionsWithConsoleSessionToken,
24
+ type SeamHttpOptionsWithPersonalAccessToken,
25
+ type SeamHttpRequestOptions,
26
+ } from 'lib/seam/connect/options.js'
27
+ import {
28
+ limitToSeamHttpRequestOptions,
29
+ parseOptions,
30
+ } from 'lib/seam/connect/parse-options.js'
31
+
32
+ import { SeamHttpClientSessions } from './client-sessions.js'
33
+
34
+ export class SeamHttpPhones {
35
+ client: Client
36
+ readonly defaults: Required<SeamHttpRequestOptions>
37
+
38
+ constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
39
+ const options = parseOptions(apiKeyOrOptions)
40
+ this.client = 'client' in options ? options.client : createClient(options)
41
+ this.defaults = limitToSeamHttpRequestOptions(options)
42
+ }
43
+
44
+ static fromClient(
45
+ client: SeamHttpOptionsWithClient['client'],
46
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
47
+ ): SeamHttpPhones {
48
+ const constructorOptions = { ...options, client }
49
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
50
+ throw new SeamHttpInvalidOptionsError('Missing client')
51
+ }
52
+ return new SeamHttpPhones(constructorOptions)
53
+ }
54
+
55
+ static fromApiKey(
56
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
57
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
58
+ ): SeamHttpPhones {
59
+ const constructorOptions = { ...options, apiKey }
60
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
61
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
62
+ }
63
+ return new SeamHttpPhones(constructorOptions)
64
+ }
65
+
66
+ static fromClientSessionToken(
67
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
68
+ options: Omit<
69
+ SeamHttpOptionsWithClientSessionToken,
70
+ 'clientSessionToken'
71
+ > = {},
72
+ ): SeamHttpPhones {
73
+ const constructorOptions = { ...options, clientSessionToken }
74
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
75
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
76
+ }
77
+ return new SeamHttpPhones(constructorOptions)
78
+ }
79
+
80
+ static async fromPublishableKey(
81
+ publishableKey: string,
82
+ userIdentifierKey: string,
83
+ options: SeamHttpFromPublishableKeyOptions = {},
84
+ ): Promise<SeamHttpPhones> {
85
+ warnOnInsecureuserIdentifierKey(userIdentifierKey)
86
+ const clientOptions = parseOptions({ ...options, publishableKey })
87
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
88
+ throw new SeamHttpInvalidOptionsError(
89
+ 'The client option cannot be used with SeamHttp.fromPublishableKey',
90
+ )
91
+ }
92
+ const client = createClient(clientOptions)
93
+ const clientSessions = SeamHttpClientSessions.fromClient(client)
94
+ const { token } = await clientSessions.getOrCreate({
95
+ user_identifier_key: userIdentifierKey,
96
+ })
97
+ return SeamHttpPhones.fromClientSessionToken(token, options)
98
+ }
99
+
100
+ static fromConsoleSessionToken(
101
+ consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
102
+ workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
103
+ options: Omit<
104
+ SeamHttpOptionsWithConsoleSessionToken,
105
+ 'consoleSessionToken' | 'workspaceId'
106
+ > = {},
107
+ ): SeamHttpPhones {
108
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId }
109
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
110
+ throw new SeamHttpInvalidOptionsError(
111
+ 'Missing consoleSessionToken or workspaceId',
112
+ )
113
+ }
114
+ return new SeamHttpPhones(constructorOptions)
115
+ }
116
+
117
+ static fromPersonalAccessToken(
118
+ personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
119
+ workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
120
+ options: Omit<
121
+ SeamHttpOptionsWithPersonalAccessToken,
122
+ 'personalAccessToken' | 'workspaceId'
123
+ > = {},
124
+ ): SeamHttpPhones {
125
+ const constructorOptions = { ...options, personalAccessToken, workspaceId }
126
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
127
+ throw new SeamHttpInvalidOptionsError(
128
+ 'Missing personalAccessToken or workspaceId',
129
+ )
130
+ }
131
+ return new SeamHttpPhones(constructorOptions)
132
+ }
133
+
134
+ async list(body?: PhonesListParams): Promise<PhonesListResponse['phones']> {
135
+ const { data } = await this.client.request<PhonesListResponse>({
136
+ url: '/phones/list',
137
+ method: 'post',
138
+ data: body,
139
+ })
140
+
141
+ return data.phones
142
+ }
143
+ }
144
+
145
+ export type PhonesListParams = RouteRequestBody<'/phones/list'>
146
+
147
+ export type PhonesListResponse = SetNonNullable<
148
+ Required<RouteResponse<'/phones/list'>>
149
+ >
150
+
151
+ export type PhonesListOptions = never
@@ -0,0 +1,214 @@
1
+ /*
2
+ * Automatically generated by generate-routes.ts.
3
+ * Do not edit this file or add other files to this directory.
4
+ */
5
+
6
+ import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect'
7
+ import type { SetNonNullable } from 'type-fest'
8
+
9
+ import { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
10
+ import { type Client, createClient } from 'lib/seam/connect/client.js'
11
+ import {
12
+ isSeamHttpOptionsWithApiKey,
13
+ isSeamHttpOptionsWithClient,
14
+ isSeamHttpOptionsWithClientSessionToken,
15
+ isSeamHttpOptionsWithConsoleSessionToken,
16
+ isSeamHttpOptionsWithPersonalAccessToken,
17
+ type SeamHttpFromPublishableKeyOptions,
18
+ SeamHttpInvalidOptionsError,
19
+ type SeamHttpOptions,
20
+ type SeamHttpOptionsWithApiKey,
21
+ type SeamHttpOptionsWithClient,
22
+ type SeamHttpOptionsWithClientSessionToken,
23
+ type SeamHttpOptionsWithConsoleSessionToken,
24
+ type SeamHttpOptionsWithPersonalAccessToken,
25
+ type SeamHttpRequestOptions,
26
+ } from 'lib/seam/connect/options.js'
27
+ import {
28
+ limitToSeamHttpRequestOptions,
29
+ parseOptions,
30
+ } from 'lib/seam/connect/parse-options.js'
31
+
32
+ import { SeamHttpClientSessions } from './client-sessions.js'
33
+
34
+ export class SeamHttpUserIdentitiesEnrollmentAutomations {
35
+ client: Client
36
+ readonly defaults: Required<SeamHttpRequestOptions>
37
+
38
+ constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
39
+ const options = parseOptions(apiKeyOrOptions)
40
+ this.client = 'client' in options ? options.client : createClient(options)
41
+ this.defaults = limitToSeamHttpRequestOptions(options)
42
+ }
43
+
44
+ static fromClient(
45
+ client: SeamHttpOptionsWithClient['client'],
46
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
47
+ ): SeamHttpUserIdentitiesEnrollmentAutomations {
48
+ const constructorOptions = { ...options, client }
49
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
50
+ throw new SeamHttpInvalidOptionsError('Missing client')
51
+ }
52
+ return new SeamHttpUserIdentitiesEnrollmentAutomations(constructorOptions)
53
+ }
54
+
55
+ static fromApiKey(
56
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
57
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
58
+ ): SeamHttpUserIdentitiesEnrollmentAutomations {
59
+ const constructorOptions = { ...options, apiKey }
60
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
61
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
62
+ }
63
+ return new SeamHttpUserIdentitiesEnrollmentAutomations(constructorOptions)
64
+ }
65
+
66
+ static fromClientSessionToken(
67
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
68
+ options: Omit<
69
+ SeamHttpOptionsWithClientSessionToken,
70
+ 'clientSessionToken'
71
+ > = {},
72
+ ): SeamHttpUserIdentitiesEnrollmentAutomations {
73
+ const constructorOptions = { ...options, clientSessionToken }
74
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
75
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
76
+ }
77
+ return new SeamHttpUserIdentitiesEnrollmentAutomations(constructorOptions)
78
+ }
79
+
80
+ static async fromPublishableKey(
81
+ publishableKey: string,
82
+ userIdentifierKey: string,
83
+ options: SeamHttpFromPublishableKeyOptions = {},
84
+ ): Promise<SeamHttpUserIdentitiesEnrollmentAutomations> {
85
+ warnOnInsecureuserIdentifierKey(userIdentifierKey)
86
+ const clientOptions = parseOptions({ ...options, publishableKey })
87
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
88
+ throw new SeamHttpInvalidOptionsError(
89
+ 'The client option cannot be used with SeamHttp.fromPublishableKey',
90
+ )
91
+ }
92
+ const client = createClient(clientOptions)
93
+ const clientSessions = SeamHttpClientSessions.fromClient(client)
94
+ const { token } = await clientSessions.getOrCreate({
95
+ user_identifier_key: userIdentifierKey,
96
+ })
97
+ return SeamHttpUserIdentitiesEnrollmentAutomations.fromClientSessionToken(
98
+ token,
99
+ options,
100
+ )
101
+ }
102
+
103
+ static fromConsoleSessionToken(
104
+ consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
105
+ workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
106
+ options: Omit<
107
+ SeamHttpOptionsWithConsoleSessionToken,
108
+ 'consoleSessionToken' | 'workspaceId'
109
+ > = {},
110
+ ): SeamHttpUserIdentitiesEnrollmentAutomations {
111
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId }
112
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
113
+ throw new SeamHttpInvalidOptionsError(
114
+ 'Missing consoleSessionToken or workspaceId',
115
+ )
116
+ }
117
+ return new SeamHttpUserIdentitiesEnrollmentAutomations(constructorOptions)
118
+ }
119
+
120
+ static fromPersonalAccessToken(
121
+ personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
122
+ workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
123
+ options: Omit<
124
+ SeamHttpOptionsWithPersonalAccessToken,
125
+ 'personalAccessToken' | 'workspaceId'
126
+ > = {},
127
+ ): SeamHttpUserIdentitiesEnrollmentAutomations {
128
+ const constructorOptions = { ...options, personalAccessToken, workspaceId }
129
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
130
+ throw new SeamHttpInvalidOptionsError(
131
+ 'Missing personalAccessToken or workspaceId',
132
+ )
133
+ }
134
+ return new SeamHttpUserIdentitiesEnrollmentAutomations(constructorOptions)
135
+ }
136
+
137
+ async get(
138
+ body?: UserIdentitiesEnrollmentAutomationsGetParams,
139
+ ): Promise<
140
+ UserIdentitiesEnrollmentAutomationsGetResponse['enrollment_automation']
141
+ > {
142
+ const { data } =
143
+ await this.client.request<UserIdentitiesEnrollmentAutomationsGetResponse>(
144
+ {
145
+ url: '/user_identities/enrollment_automations/get',
146
+ method: 'post',
147
+ data: body,
148
+ },
149
+ )
150
+
151
+ return data.enrollment_automation
152
+ }
153
+
154
+ async launch(
155
+ body?: UserIdentitiesEnrollmentAutomationsLaunchBody,
156
+ ): Promise<
157
+ UserIdentitiesEnrollmentAutomationsLaunchResponse['enrollment_automation']
158
+ > {
159
+ const { data } =
160
+ await this.client.request<UserIdentitiesEnrollmentAutomationsLaunchResponse>(
161
+ {
162
+ url: '/user_identities/enrollment_automations/launch',
163
+ method: 'post',
164
+ data: body,
165
+ },
166
+ )
167
+
168
+ return data.enrollment_automation
169
+ }
170
+
171
+ async list(
172
+ body?: UserIdentitiesEnrollmentAutomationsListParams,
173
+ ): Promise<
174
+ UserIdentitiesEnrollmentAutomationsListResponse['enrollment_automations']
175
+ > {
176
+ const { data } =
177
+ await this.client.request<UserIdentitiesEnrollmentAutomationsListResponse>(
178
+ {
179
+ url: '/user_identities/enrollment_automations/list',
180
+ method: 'post',
181
+ data: body,
182
+ },
183
+ )
184
+
185
+ return data.enrollment_automations
186
+ }
187
+ }
188
+
189
+ export type UserIdentitiesEnrollmentAutomationsGetParams =
190
+ RouteRequestBody<'/user_identities/enrollment_automations/get'>
191
+
192
+ export type UserIdentitiesEnrollmentAutomationsGetResponse = SetNonNullable<
193
+ Required<RouteResponse<'/user_identities/enrollment_automations/get'>>
194
+ >
195
+
196
+ export type UserIdentitiesEnrollmentAutomationsGetOptions = never
197
+
198
+ export type UserIdentitiesEnrollmentAutomationsLaunchBody =
199
+ RouteRequestBody<'/user_identities/enrollment_automations/launch'>
200
+
201
+ export type UserIdentitiesEnrollmentAutomationsLaunchResponse = SetNonNullable<
202
+ Required<RouteResponse<'/user_identities/enrollment_automations/launch'>>
203
+ >
204
+
205
+ export type UserIdentitiesEnrollmentAutomationsLaunchOptions = never
206
+
207
+ export type UserIdentitiesEnrollmentAutomationsListParams =
208
+ RouteRequestBody<'/user_identities/enrollment_automations/list'>
209
+
210
+ export type UserIdentitiesEnrollmentAutomationsListResponse = SetNonNullable<
211
+ Required<RouteResponse<'/user_identities/enrollment_automations/list'>>
212
+ >
213
+
214
+ export type UserIdentitiesEnrollmentAutomationsListOptions = never