stytch 6.4.0 → 9.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,44 @@ require_relative 'request_helper'
10
10
 
11
11
  module StytchB2B
12
12
  class Organizations
13
+ class UpdateRequestOptions
14
+ # Optional authorization object.
15
+ # Pass in an active Stytch Member session token or session JWT and the request
16
+ # will be run using that member's permissions.
17
+ attr_accessor :authorization
18
+
19
+ def initialize(
20
+ authorization: nil
21
+ )
22
+ @authorization = authorization
23
+ end
24
+
25
+ def to_headers
26
+ headers = {}
27
+ headers.merge!(@authorization.to_headers) if authorization
28
+ headers
29
+ end
30
+ end
31
+
32
+ class DeleteRequestOptions
33
+ # Optional authorization object.
34
+ # Pass in an active Stytch Member session token or session JWT and the request
35
+ # will be run using that member's permissions.
36
+ attr_accessor :authorization
37
+
38
+ def initialize(
39
+ authorization: nil
40
+ )
41
+ @authorization = authorization
42
+ end
43
+
44
+ def to_headers
45
+ headers = {}
46
+ headers.merge!(@authorization.to_headers) if authorization
47
+ headers
48
+ end
49
+ end
50
+
13
51
  include Stytch::RequestHelper
14
52
  attr_reader :members
15
53
 
@@ -19,7 +57,7 @@ module StytchB2B
19
57
  @members = StytchB2B::Organizations::Members.new(@connection)
20
58
  end
21
59
 
22
- # Creates an Organization. An `organization_name` and a unique `organization_slug` are required.
60
+ # Creates an. An `organization_name` and a unique `organization_slug` are required.
23
61
  #
24
62
  # By default, `email_invites` and `sso_jit_provisioning` will be set to `ALL_ALLOWED`, and `mfa_policy` will be set to `OPTIONAL` if no Organization authentication settings are explicitly defined in the request.
25
63
  #
@@ -27,10 +65,10 @@ module StytchB2B
27
65
  #
28
66
  # == Parameters:
29
67
  # organization_name::
30
- # The name of the Organization.
68
+ # The name of the Organization. Must be between 1 and 128 characters in length.
31
69
  # The type of this field is +String+.
32
70
  # organization_slug::
33
- # The unique URL slug of the Organization. A minimum of two characters is required. The slug only accepts alphanumeric characters and the following reserved characters: `-` `.` `_` `~`.
71
+ # The unique URL slug of the Organization. The slug only accepts alphanumeric characters and the following reserved characters: `-` `.` `_` `~`. Must be between 2 and 128 characters in length.
34
72
  # The type of this field is nilable +String+.
35
73
  # organization_logo_url::
36
74
  # The image URL of the Organization logo.
@@ -55,11 +93,11 @@ module StytchB2B
55
93
  # Common domains such as `gmail.com` are not allowed. See the [common email domains resource](https://stytch.com/docs/b2b/api/common-email-domains) for the full list.
56
94
  # The type of this field is nilable list of +String+.
57
95
  # email_jit_provisioning::
58
- # The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link. The accepted values are:
96
+ # The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link or OAuth. The accepted values are:
59
97
  #
60
- # `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be provisioned upon authentication via Email Magic Link.
98
+ # `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be provisioned upon authentication via Email Magic Link or OAuth.
61
99
  #
62
- # `NOT_ALLOWED` – disable JIT provisioning via Email Magic Link.
100
+ # `NOT_ALLOWED` – disable JIT provisioning via Email Magic Link and OAuth.
63
101
  #
64
102
  # The type of this field is nilable +String+.
65
103
  # email_invites::
@@ -81,7 +119,6 @@ module StytchB2B
81
119
  #
82
120
  # The type of this field is nilable +String+.
83
121
  # allowed_auth_methods::
84
- #
85
122
  # An array of allowed authentication methods. This list is enforced when `auth_methods` is set to `RESTRICTED`.
86
123
  # The list's accepted values are: `sso`, `magic_link`, `password`, `google_oauth`, and `microsoft_oauth`.
87
124
  #
@@ -89,11 +126,41 @@ module StytchB2B
89
126
  # mfa_policy::
90
127
  # The setting that controls the MFA policy for all Members in the Organization. The accepted values are:
91
128
  #
92
- # `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time they wish to log in.
129
+ # `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time they wish to log in. However, any active Session that existed prior to this setting change will remain valid.
93
130
  #
94
131
  # `OPTIONAL` – The default value. The Organization does not require MFA by default for all Members. Members will be required to complete MFA only if their `mfa_enrolled` status is set to true.
95
132
  #
96
133
  # The type of this field is nilable +String+.
134
+ # rbac_email_implicit_role_assignments::
135
+ # Implicit role assignments based off of email domains.
136
+ # For each domain-Role pair, all Members whose email addresses have the specified email domain will be granted the
137
+ # associated Role, regardless of their login method. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
138
+ # for more information about role assignment.
139
+ # The type of this field is nilable list of +EmailImplicitRoleAssignment+ (+object+).
140
+ # mfa_methods::
141
+ # The setting that controls which MFA methods can be used by Members of an Organization. The accepted values are:
142
+ #
143
+ # `ALL_ALLOWED` – the default setting which allows all authentication methods to be used.
144
+ #
145
+ # `RESTRICTED` – only methods that comply with `allowed_mfa_methods` can be used for authentication. This setting does not apply to Members with `is_breakglass` set to `true`.
146
+ #
147
+ # The type of this field is nilable +String+.
148
+ # allowed_mfa_methods::
149
+ # An array of allowed MFA authentication methods. This list is enforced when `mfa_methods` is set to `RESTRICTED`.
150
+ # The list's accepted values are: `sms_otp` and `totp`.
151
+ #
152
+ # The type of this field is nilable list of +String+.
153
+ # oauth_tenant_jit_provisioning::
154
+ # The authentication setting that controls how a new Member can JIT provision into an organization by tenant. The accepted values are:
155
+ #
156
+ # `RESTRICTED` – only new Members with tenants in `allowed_oauth_tenants` can JIT provision via tenant.
157
+ #
158
+ # `NOT_ALLOWED` – disable JIT provisioning by OAuth Tenant.
159
+ #
160
+ # The type of this field is nilable +String+.
161
+ # allowed_oauth_tenants::
162
+ # A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack" and "hubspot".
163
+ # The type of this field is nilable +object+.
97
164
  #
98
165
  # == Returns:
99
166
  # An object with the following fields:
@@ -117,8 +184,14 @@ module StytchB2B
117
184
  email_invites: nil,
118
185
  auth_methods: nil,
119
186
  allowed_auth_methods: nil,
120
- mfa_policy: nil
187
+ mfa_policy: nil,
188
+ rbac_email_implicit_role_assignments: nil,
189
+ mfa_methods: nil,
190
+ allowed_mfa_methods: nil,
191
+ oauth_tenant_jit_provisioning: nil,
192
+ allowed_oauth_tenants: nil
121
193
  )
194
+ headers = {}
122
195
  request = {
123
196
  organization_name: organization_name
124
197
  }
@@ -132,11 +205,16 @@ module StytchB2B
132
205
  request[:auth_methods] = auth_methods unless auth_methods.nil?
133
206
  request[:allowed_auth_methods] = allowed_auth_methods unless allowed_auth_methods.nil?
134
207
  request[:mfa_policy] = mfa_policy unless mfa_policy.nil?
208
+ request[:rbac_email_implicit_role_assignments] = rbac_email_implicit_role_assignments unless rbac_email_implicit_role_assignments.nil?
209
+ request[:mfa_methods] = mfa_methods unless mfa_methods.nil?
210
+ request[:allowed_mfa_methods] = allowed_mfa_methods unless allowed_mfa_methods.nil?
211
+ request[:oauth_tenant_jit_provisioning] = oauth_tenant_jit_provisioning unless oauth_tenant_jit_provisioning.nil?
212
+ request[:allowed_oauth_tenants] = allowed_oauth_tenants unless allowed_oauth_tenants.nil?
135
213
 
136
- post_request('/v1/b2b/organizations', request)
214
+ post_request('/v1/b2b/organizations', request, headers)
137
215
  end
138
216
 
139
- # Returns an Organization specified by `organization_id`.
217
+ # Returns an specified by `organization_id`.
140
218
  #
141
219
  # == Parameters:
142
220
  # organization_id::
@@ -157,12 +235,13 @@ module StytchB2B
157
235
  def get(
158
236
  organization_id:
159
237
  )
238
+ headers = {}
160
239
  query_params = {}
161
240
  request = request_with_query_params("/v1/b2b/organizations/#{organization_id}", query_params)
162
- get_request(request)
241
+ get_request(request, headers)
163
242
  end
164
243
 
165
- # Updates an Organization specified by `organization_id`. An Organization must always have at least one auth setting set to either `RESTRICTED` or `ALL_ALLOWED` in order to provision new Members. test
244
+ # Updates an specified by `organization_id`. An Organization must always have at least one auth setting set to either `RESTRICTED` or `ALL_ALLOWED` in order to provision new Members.
166
245
  #
167
246
  # *See the [Organization authentication settings](https://stytch.com/docs/b2b/api/org-auth-settings) resource to learn more about fields like `email_jit_provisioning`, `email_invites`, `sso_jit_provisioning`, etc., and their behaviors.
168
247
  #
@@ -171,19 +250,29 @@ module StytchB2B
171
250
  # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
172
251
  # The type of this field is +String+.
173
252
  # organization_name::
174
- # The name of the Organization.
253
+ # The name of the Organization. Must be between 1 and 128 characters in length.
254
+ #
255
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.info.name` action on the `stytch.organization` Resource.
175
256
  # The type of this field is nilable +String+.
176
257
  # organization_slug::
177
- # The unique URL slug of the Organization. A minimum of two characters is required. The slug only accepts alphanumeric characters and the following reserved characters: `-` `.` `_` `~`.
258
+ # The unique URL slug of the Organization. The slug only accepts alphanumeric characters and the following reserved characters: `-` `.` `_` `~`. Must be between 2 and 128 characters in length.
259
+ #
260
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.info.slug` action on the `stytch.organization` Resource.
178
261
  # The type of this field is nilable +String+.
179
262
  # organization_logo_url::
180
263
  # The image URL of the Organization logo.
264
+ #
265
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.info.logo-url` action on the `stytch.organization` Resource.
181
266
  # The type of this field is nilable +String+.
182
267
  # trusted_metadata::
183
268
  # An arbitrary JSON object for storing application-specific data or identity-provider-specific data.
269
+ # If a session header is passed into the request, this field may **not** be passed into the request. You cannot
270
+ # update trusted metadata when acting as a Member.
184
271
  # The type of this field is nilable +object+.
185
272
  # sso_default_connection_id::
186
273
  # The default connection used for SSO when there are multiple active connections.
274
+ #
275
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.default-sso-connection` action on the `stytch.organization` Resource.
187
276
  # The type of this field is nilable +String+.
188
277
  # sso_jit_provisioning::
189
278
  # The authentication setting that controls the JIT provisioning of Members when authenticating via SSO. The accepted values are:
@@ -194,24 +283,32 @@ module StytchB2B
194
283
  #
195
284
  # `NOT_ALLOWED` – disable JIT provisioning via SSO.
196
285
  #
286
+ #
287
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.sso-jit-provisioning` action on the `stytch.organization` Resource.
197
288
  # The type of this field is nilable +String+.
198
289
  # sso_jit_provisioning_allowed_connections::
199
290
  # An array of `connection_id`s that reference [SAML Connection objects](https://stytch.com/docs/b2b/api/saml-connection-object).
200
291
  # Only these connections will be allowed to JIT provision Members via SSO when `sso_jit_provisioning` is set to `RESTRICTED`.
292
+ #
293
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.sso-jit-provisioning` action on the `stytch.organization` Resource.
201
294
  # The type of this field is nilable list of +String+.
202
295
  # email_allowed_domains::
203
296
  # An array of email domains that allow invites or JIT provisioning for new Members. This list is enforced when either `email_invites` or `email_jit_provisioning` is set to `RESTRICTED`.
204
297
  #
205
298
  #
206
299
  # Common domains such as `gmail.com` are not allowed. See the [common email domains resource](https://stytch.com/docs/b2b/api/common-email-domains) for the full list.
300
+ #
301
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.allowed-domains` action on the `stytch.organization` Resource.
207
302
  # The type of this field is nilable list of +String+.
208
303
  # email_jit_provisioning::
209
- # The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link. The accepted values are:
304
+ # The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link or OAuth. The accepted values are:
305
+ #
306
+ # `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be provisioned upon authentication via Email Magic Link or OAuth.
210
307
  #
211
- # `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be provisioned upon authentication via Email Magic Link.
308
+ # `NOT_ALLOWED` – disable JIT provisioning via Email Magic Link and OAuth.
212
309
  #
213
- # `NOT_ALLOWED` – disable JIT provisioning via Email Magic Link.
214
310
  #
311
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.email-jit-provisioning` action on the `stytch.organization` Resource.
215
312
  # The type of this field is nilable +String+.
216
313
  # email_invites::
217
314
  # The authentication setting that controls how a new Member can be invited to an organization by email. The accepted values are:
@@ -222,6 +319,8 @@ module StytchB2B
222
319
  #
223
320
  # `NOT_ALLOWED` – disable email invites.
224
321
  #
322
+ #
323
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.email-invites` action on the `stytch.organization` Resource.
225
324
  # The type of this field is nilable +String+.
226
325
  # auth_methods::
227
326
  # The setting that controls which authentication methods can be used by Members of an Organization. The accepted values are:
@@ -230,21 +329,66 @@ module StytchB2B
230
329
  #
231
330
  # `RESTRICTED` – only methods that comply with `allowed_auth_methods` can be used for authentication. This setting does not apply to Members with `is_breakglass` set to `true`.
232
331
  #
332
+ #
333
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.allowed-auth-methods` action on the `stytch.organization` Resource.
233
334
  # The type of this field is nilable +String+.
234
335
  # allowed_auth_methods::
235
- #
236
336
  # An array of allowed authentication methods. This list is enforced when `auth_methods` is set to `RESTRICTED`.
237
337
  # The list's accepted values are: `sso`, `magic_link`, `password`, `google_oauth`, and `microsoft_oauth`.
238
338
  #
339
+ #
340
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.allowed-auth-methods` action on the `stytch.organization` Resource.
239
341
  # The type of this field is nilable list of +String+.
240
342
  # mfa_policy::
241
343
  # The setting that controls the MFA policy for all Members in the Organization. The accepted values are:
242
344
  #
243
- # `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time they wish to log in.
345
+ # `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time they wish to log in. However, any active Session that existed prior to this setting change will remain valid.
244
346
  #
245
347
  # `OPTIONAL` – The default value. The Organization does not require MFA by default for all Members. Members will be required to complete MFA only if their `mfa_enrolled` status is set to true.
246
348
  #
349
+ #
350
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.mfa-policy` action on the `stytch.organization` Resource.
351
+ # The type of this field is nilable +String+.
352
+ # rbac_email_implicit_role_assignments::
353
+ # Implicit role assignments based off of email domains.
354
+ # For each domain-Role pair, all Members whose email addresses have the specified email domain will be granted the
355
+ # associated Role, regardless of their login method. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
356
+ # for more information about role assignment.
357
+ #
358
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.implicit-roles` action on the `stytch.organization` Resource.
359
+ # The type of this field is nilable list of +EmailImplicitRoleAssignment+.
360
+ # mfa_methods::
361
+ # The setting that controls which MFA methods can be used by Members of an Organization. The accepted values are:
362
+ #
363
+ # `ALL_ALLOWED` – the default setting which allows all authentication methods to be used.
364
+ #
365
+ # `RESTRICTED` – only methods that comply with `allowed_mfa_methods` can be used for authentication. This setting does not apply to Members with `is_breakglass` set to `true`.
366
+ #
367
+ #
368
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.allowed-mfa-methods` action on the `stytch.organization` Resource.
247
369
  # The type of this field is nilable +String+.
370
+ # allowed_mfa_methods::
371
+ # An array of allowed MFA authentication methods. This list is enforced when `mfa_methods` is set to `RESTRICTED`.
372
+ # The list's accepted values are: `sms_otp` and `totp`.
373
+ #
374
+ #
375
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.allowed-mfa-methods` action on the `stytch.organization` Resource.
376
+ # The type of this field is nilable list of +String+.
377
+ # oauth_tenant_jit_provisioning::
378
+ # The authentication setting that controls how a new Member can JIT provision into an organization by tenant. The accepted values are:
379
+ #
380
+ # `RESTRICTED` – only new Members with tenants in `allowed_oauth_tenants` can JIT provision via tenant.
381
+ #
382
+ # `NOT_ALLOWED` – disable JIT provisioning by OAuth Tenant.
383
+ #
384
+ #
385
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.oauth-tenant-jit-provisioning` action on the `stytch.organization` Resource.
386
+ # The type of this field is nilable +String+.
387
+ # allowed_oauth_tenants::
388
+ # A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack" and "hubspot".
389
+ #
390
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.allowed-oauth-tenants` action on the `stytch.organization` Resource.
391
+ # The type of this field is nilable +object+.
248
392
  #
249
393
  # == Returns:
250
394
  # An object with the following fields:
@@ -257,6 +401,9 @@ module StytchB2B
257
401
  # status_code::
258
402
  # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
259
403
  # The type of this field is +Integer+.
404
+ #
405
+ # == Method Options:
406
+ # This method supports an optional +StytchB2B::Organizations::UpdateRequestOptions+ object which will modify the headers sent in the HTTP request.
260
407
  def update(
261
408
  organization_id:,
262
409
  organization_name: nil,
@@ -271,8 +418,16 @@ module StytchB2B
271
418
  email_invites: nil,
272
419
  auth_methods: nil,
273
420
  allowed_auth_methods: nil,
274
- mfa_policy: nil
421
+ mfa_policy: nil,
422
+ rbac_email_implicit_role_assignments: nil,
423
+ mfa_methods: nil,
424
+ allowed_mfa_methods: nil,
425
+ oauth_tenant_jit_provisioning: nil,
426
+ allowed_oauth_tenants: nil,
427
+ method_options: nil
275
428
  )
429
+ headers = {}
430
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
276
431
  request = {}
277
432
  request[:organization_name] = organization_name unless organization_name.nil?
278
433
  request[:organization_slug] = organization_slug unless organization_slug.nil?
@@ -280,21 +435,23 @@ module StytchB2B
280
435
  request[:trusted_metadata] = trusted_metadata unless trusted_metadata.nil?
281
436
  request[:sso_default_connection_id] = sso_default_connection_id unless sso_default_connection_id.nil?
282
437
  request[:sso_jit_provisioning] = sso_jit_provisioning unless sso_jit_provisioning.nil?
283
- unless sso_jit_provisioning_allowed_connections.nil?
284
- request[:sso_jit_provisioning_allowed_connections] =
285
- sso_jit_provisioning_allowed_connections
286
- end
438
+ request[:sso_jit_provisioning_allowed_connections] = sso_jit_provisioning_allowed_connections unless sso_jit_provisioning_allowed_connections.nil?
287
439
  request[:email_allowed_domains] = email_allowed_domains unless email_allowed_domains.nil?
288
440
  request[:email_jit_provisioning] = email_jit_provisioning unless email_jit_provisioning.nil?
289
441
  request[:email_invites] = email_invites unless email_invites.nil?
290
442
  request[:auth_methods] = auth_methods unless auth_methods.nil?
291
443
  request[:allowed_auth_methods] = allowed_auth_methods unless allowed_auth_methods.nil?
292
444
  request[:mfa_policy] = mfa_policy unless mfa_policy.nil?
445
+ request[:rbac_email_implicit_role_assignments] = rbac_email_implicit_role_assignments unless rbac_email_implicit_role_assignments.nil?
446
+ request[:mfa_methods] = mfa_methods unless mfa_methods.nil?
447
+ request[:allowed_mfa_methods] = allowed_mfa_methods unless allowed_mfa_methods.nil?
448
+ request[:oauth_tenant_jit_provisioning] = oauth_tenant_jit_provisioning unless oauth_tenant_jit_provisioning.nil?
449
+ request[:allowed_oauth_tenants] = allowed_oauth_tenants unless allowed_oauth_tenants.nil?
293
450
 
294
- put_request("/v1/b2b/organizations/#{organization_id}", request)
451
+ put_request("/v1/b2b/organizations/#{organization_id}", request, headers)
295
452
  end
296
453
 
297
- # Deletes an Organization specified by `organization_id`. All Members of the Organization will also be deleted.
454
+ # Deletes an specified by `organization_id`. All Members of the Organization will also be deleted.
298
455
  #
299
456
  # == Parameters:
300
457
  # organization_id::
@@ -312,10 +469,16 @@ module StytchB2B
312
469
  # status_code::
313
470
  # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
314
471
  # The type of this field is +Integer+.
472
+ #
473
+ # == Method Options:
474
+ # This method supports an optional +StytchB2B::Organizations::DeleteRequestOptions+ object which will modify the headers sent in the HTTP request.
315
475
  def delete(
316
- organization_id:
476
+ organization_id:,
477
+ method_options: nil
317
478
  )
318
- delete_request("/v1/b2b/organizations/#{organization_id}")
479
+ headers = {}
480
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
481
+ delete_request("/v1/b2b/organizations/#{organization_id}", headers)
319
482
  end
320
483
 
321
484
  # Search for Organizations. If you send a request with no body params, no filtering will be applied and the endpoint will return all Organizations. All fuzzy search filters require a minimum of three characters.
@@ -350,22 +513,206 @@ module StytchB2B
350
513
  limit: nil,
351
514
  query: nil
352
515
  )
516
+ headers = {}
353
517
  request = {}
354
518
  request[:cursor] = cursor unless cursor.nil?
355
519
  request[:limit] = limit unless limit.nil?
356
520
  request[:query] = query unless query.nil?
357
521
 
358
- post_request('/v1/b2b/organizations/search', request)
522
+ post_request('/v1/b2b/organizations/search', request, headers)
523
+ end
524
+
525
+ def metrics(
526
+ organization_id:
527
+ )
528
+ headers = {}
529
+ query_params = {}
530
+ request = request_with_query_params("/v1/b2b/organizations/#{organization_id}/metrics", query_params)
531
+ get_request(request, headers)
359
532
  end
360
533
 
361
534
  class Members
535
+ class UpdateRequestOptions
536
+ # Optional authorization object.
537
+ # Pass in an active Stytch Member session token or session JWT and the request
538
+ # will be run using that member's permissions.
539
+ attr_accessor :authorization
540
+
541
+ def initialize(
542
+ authorization: nil
543
+ )
544
+ @authorization = authorization
545
+ end
546
+
547
+ def to_headers
548
+ headers = {}
549
+ headers.merge!(@authorization.to_headers) if authorization
550
+ headers
551
+ end
552
+ end
553
+
554
+ class DeleteRequestOptions
555
+ # Optional authorization object.
556
+ # Pass in an active Stytch Member session token or session JWT and the request
557
+ # will be run using that member's permissions.
558
+ attr_accessor :authorization
559
+
560
+ def initialize(
561
+ authorization: nil
562
+ )
563
+ @authorization = authorization
564
+ end
565
+
566
+ def to_headers
567
+ headers = {}
568
+ headers.merge!(@authorization.to_headers) if authorization
569
+ headers
570
+ end
571
+ end
572
+
573
+ class ReactivateRequestOptions
574
+ # Optional authorization object.
575
+ # Pass in an active Stytch Member session token or session JWT and the request
576
+ # will be run using that member's permissions.
577
+ attr_accessor :authorization
578
+
579
+ def initialize(
580
+ authorization: nil
581
+ )
582
+ @authorization = authorization
583
+ end
584
+
585
+ def to_headers
586
+ headers = {}
587
+ headers.merge!(@authorization.to_headers) if authorization
588
+ headers
589
+ end
590
+ end
591
+
592
+ class DeleteMFAPhoneNumberRequestOptions
593
+ # Optional authorization object.
594
+ # Pass in an active Stytch Member session token or session JWT and the request
595
+ # will be run using that member's permissions.
596
+ attr_accessor :authorization
597
+
598
+ def initialize(
599
+ authorization: nil
600
+ )
601
+ @authorization = authorization
602
+ end
603
+
604
+ def to_headers
605
+ headers = {}
606
+ headers.merge!(@authorization.to_headers) if authorization
607
+ headers
608
+ end
609
+ end
610
+
611
+ class DeleteTOTPRequestOptions
612
+ # Optional authorization object.
613
+ # Pass in an active Stytch Member session token or session JWT and the request
614
+ # will be run using that member's permissions.
615
+ attr_accessor :authorization
616
+
617
+ def initialize(
618
+ authorization: nil
619
+ )
620
+ @authorization = authorization
621
+ end
622
+
623
+ def to_headers
624
+ headers = {}
625
+ headers.merge!(@authorization.to_headers) if authorization
626
+ headers
627
+ end
628
+ end
629
+
630
+ class SearchRequestOptions
631
+ # Optional authorization object.
632
+ # Pass in an active Stytch Member session token or session JWT and the request
633
+ # will be run using that member's permissions.
634
+ attr_accessor :authorization
635
+
636
+ def initialize(
637
+ authorization: nil
638
+ )
639
+ @authorization = authorization
640
+ end
641
+
642
+ def to_headers
643
+ headers = {}
644
+ headers.merge!(@authorization.to_headers) if authorization
645
+ headers
646
+ end
647
+ end
648
+
649
+ class DeletePasswordRequestOptions
650
+ # Optional authorization object.
651
+ # Pass in an active Stytch Member session token or session JWT and the request
652
+ # will be run using that member's permissions.
653
+ attr_accessor :authorization
654
+
655
+ def initialize(
656
+ authorization: nil
657
+ )
658
+ @authorization = authorization
659
+ end
660
+
661
+ def to_headers
662
+ headers = {}
663
+ headers.merge!(@authorization.to_headers) if authorization
664
+ headers
665
+ end
666
+ end
667
+
668
+ class UnlinkRetiredEmailRequestOptions
669
+ # Optional authorization object.
670
+ # Pass in an active Stytch Member session token or session JWT and the request
671
+ # will be run using that member's permissions.
672
+ attr_accessor :authorization
673
+
674
+ def initialize(
675
+ authorization: nil
676
+ )
677
+ @authorization = authorization
678
+ end
679
+
680
+ def to_headers
681
+ headers = {}
682
+ headers.merge!(@authorization.to_headers) if authorization
683
+ headers
684
+ end
685
+ end
686
+
687
+ class CreateRequestOptions
688
+ # Optional authorization object.
689
+ # Pass in an active Stytch Member session token or session JWT and the request
690
+ # will be run using that member's permissions.
691
+ attr_accessor :authorization
692
+
693
+ def initialize(
694
+ authorization: nil
695
+ )
696
+ @authorization = authorization
697
+ end
698
+
699
+ def to_headers
700
+ headers = {}
701
+ headers.merge!(@authorization.to_headers) if authorization
702
+ headers
703
+ end
704
+ end
705
+
362
706
  include Stytch::RequestHelper
707
+ attr_reader :oauth_providers
363
708
 
364
709
  def initialize(connection)
365
710
  @connection = connection
711
+
712
+ @oauth_providers = StytchB2B::Organizations::Members::OAuthProviders.new(@connection)
366
713
  end
367
714
 
368
- # Updates a Member specified by `organization_id` and `member_id`.
715
+ # Updates a specified by `organization_id` and `member_id`.
369
716
  #
370
717
  # == Parameters:
371
718
  # organization_id::
@@ -376,24 +723,65 @@ module StytchB2B
376
723
  # The type of this field is +String+.
377
724
  # name::
378
725
  # The name of the Member.
726
+ #
727
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.info.name` action on the `stytch.member` Resource. Alternatively, if the Member Session matches the Member associated with the `member_id` passed in the request, the authorization check will also allow a Member Session that has permission to perform the `update.info.name` action on the `stytch.self` Resource.
379
728
  # The type of this field is nilable +String+.
380
729
  # trusted_metadata::
381
730
  # An arbitrary JSON object for storing application-specific data or identity-provider-specific data.
731
+ # If a session header is passed into the request, this field may **not** be passed into the request. You cannot
732
+ # update trusted metadata when acting as a Member.
382
733
  # The type of this field is nilable +object+.
383
734
  # untrusted_metadata::
384
735
  # An arbitrary JSON object of application-specific data. These fields can be edited directly by the
385
736
  # frontend SDK, and should not be used to store critical information. See the [Metadata resource](https://stytch.com/docs/b2b/api/metadata)
386
737
  # for complete field behavior details.
738
+ #
739
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.info.untrusted-metadata` action on the `stytch.member` Resource. Alternatively, if the Member Session matches the Member associated with the `member_id` passed in the request, the authorization check will also allow a Member Session that has permission to perform the `update.info.untrusted-metadata` action on the `stytch.self` Resource.
387
740
  # The type of this field is nilable +object+.
388
741
  # is_breakglass::
389
742
  # Identifies the Member as a break glass user - someone who has permissions to authenticate into an Organization by bypassing the Organization's settings. A break glass account is typically used for emergency purposes to gain access outside of normal authentication procedures. Refer to the [Organization object](organization-object) and its `auth_methods` and `allowed_auth_methods` fields for more details.
743
+ #
744
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.is-breakglass` action on the `stytch.member` Resource.
390
745
  # The type of this field is nilable +Boolean+.
391
746
  # mfa_phone_number::
392
747
  # Sets the Member's phone number. Throws an error if the Member already has a phone number. To change the Member's phone number, use the [Delete member phone number endpoint](https://stytch.com/docs/b2b/api/delete-member-mfa-phone-number) to delete the Member's existing phone number first.
748
+ #
749
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.info.mfa-phone` action on the `stytch.member` Resource. Alternatively, if the Member Session matches the Member associated with the `member_id` passed in the request, the authorization check will also allow a Member Session that has permission to perform the `update.info.mfa-phone` action on the `stytch.self` Resource.
393
750
  # The type of this field is nilable +String+.
394
751
  # mfa_enrolled::
395
752
  # Sets whether the Member is enrolled in MFA. If true, the Member must complete an MFA step whenever they wish to log in to their Organization. If false, the Member only needs to complete an MFA step if the Organization's MFA policy is set to `REQUIRED_FOR_ALL`.
753
+ #
754
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.mfa-enrolled` action on the `stytch.member` Resource. Alternatively, if the Member Session matches the Member associated with the `member_id` passed in the request, the authorization check will also allow a Member Session that has permission to perform the `update.settings.mfa-enrolled` action on the `stytch.self` Resource.
396
755
  # The type of this field is nilable +Boolean+.
756
+ # roles::
757
+ # Roles to explicitly assign to this Member.
758
+ # Will completely replace any existing explicitly assigned roles. See the
759
+ # [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment.
760
+ #
761
+ # If a Role is removed from a Member, and the Member is also implicitly assigned this Role from an SSO connection
762
+ # or an SSO group, we will by default revoke any existing sessions for the Member that contain any SSO
763
+ # authentication factors with the affected connection ID. You can preserve these sessions by passing in the
764
+ # `preserve_existing_sessions` parameter with a value of `true`.
765
+ #
766
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.roles` action on the `stytch.member` Resource.
767
+ # The type of this field is nilable list of +String+.
768
+ # preserve_existing_sessions::
769
+ # Whether to preserve existing sessions when explicit Roles that are revoked are also implicitly assigned
770
+ # by SSO connection or SSO group. Defaults to `false` - that is, existing Member Sessions that contain SSO
771
+ # authentication factors with the affected SSO connection IDs will be revoked.
772
+ # The type of this field is nilable +Boolean+.
773
+ # default_mfa_method::
774
+ # Sets whether the Member is enrolled in MFA. If true, the Member must complete an MFA step whenever they wish to log in to their Organization. If false, the Member only needs to complete an MFA step if the Organization's MFA policy is set to `REQUIRED_FOR_ALL`.
775
+ #
776
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.default-mfa-method` action on the `stytch.member` Resource. Alternatively, if the Member Session matches the Member associated with the `member_id` passed in the request, the authorization check will also allow a Member Session that has permission to perform the `update.settings.default-mfa-method` action on the `stytch.self` Resource.
777
+ # The type of this field is nilable +String+.
778
+ # email_address::
779
+ # Updates the Member's `email_address`, if provided.
780
+ # If a Member's email address is changed, other Members in the same Organization cannot use the old email address, although the Member may update back to their old email address.
781
+ # A Member's email address can only be useable again by other Members if the Member is deleted.
782
+ #
783
+ # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.info.email` action on the `stytch.member` Resource. Members cannot update their own email address.
784
+ # The type of this field is nilable +String+.
397
785
  #
398
786
  # == Returns:
399
787
  # An object with the following fields:
@@ -412,6 +800,9 @@ module StytchB2B
412
800
  # status_code::
413
801
  # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
414
802
  # The type of this field is +Integer+.
803
+ #
804
+ # == Method Options:
805
+ # This method supports an optional +StytchB2B::Organizations::Members::UpdateRequestOptions+ object which will modify the headers sent in the HTTP request.
415
806
  def update(
416
807
  organization_id:,
417
808
  member_id:,
@@ -420,8 +811,15 @@ module StytchB2B
420
811
  untrusted_metadata: nil,
421
812
  is_breakglass: nil,
422
813
  mfa_phone_number: nil,
423
- mfa_enrolled: nil
814
+ mfa_enrolled: nil,
815
+ roles: nil,
816
+ preserve_existing_sessions: nil,
817
+ default_mfa_method: nil,
818
+ email_address: nil,
819
+ method_options: nil
424
820
  )
821
+ headers = {}
822
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
425
823
  request = {}
426
824
  request[:name] = name unless name.nil?
427
825
  request[:trusted_metadata] = trusted_metadata unless trusted_metadata.nil?
@@ -429,11 +827,15 @@ module StytchB2B
429
827
  request[:is_breakglass] = is_breakglass unless is_breakglass.nil?
430
828
  request[:mfa_phone_number] = mfa_phone_number unless mfa_phone_number.nil?
431
829
  request[:mfa_enrolled] = mfa_enrolled unless mfa_enrolled.nil?
830
+ request[:roles] = roles unless roles.nil?
831
+ request[:preserve_existing_sessions] = preserve_existing_sessions unless preserve_existing_sessions.nil?
832
+ request[:default_mfa_method] = default_mfa_method unless default_mfa_method.nil?
833
+ request[:email_address] = email_address unless email_address.nil?
432
834
 
433
- put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}", request)
835
+ put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}", request, headers)
434
836
  end
435
837
 
436
- # Deletes a Member specified by `organization_id` and `member_id`.
838
+ # Deletes a specified by `organization_id` and `member_id`.
437
839
  #
438
840
  # == Parameters:
439
841
  # organization_id::
@@ -454,14 +856,20 @@ module StytchB2B
454
856
  # status_code::
455
857
  # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
456
858
  # The type of this field is +Integer+.
859
+ #
860
+ # == Method Options:
861
+ # This method supports an optional +StytchB2B::Organizations::Members::DeleteRequestOptions+ object which will modify the headers sent in the HTTP request.
457
862
  def delete(
458
863
  organization_id:,
459
- member_id:
864
+ member_id:,
865
+ method_options: nil
460
866
  )
461
- delete_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}")
867
+ headers = {}
868
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
869
+ delete_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}", headers)
462
870
  end
463
871
 
464
- # Reactivates a deleted Member's status and its associated email status (if applicable) to active, specified by `organization_id` and `member_id`.
872
+ # Reactivates a deleted's status and its associated email status (if applicable) to active, specified by `organization_id` and `member_id`. This endpoint will only work for Members with at least one verified email where their `email_address_verified` is `true`.
465
873
  #
466
874
  # == Parameters:
467
875
  # organization_id::
@@ -488,16 +896,22 @@ module StytchB2B
488
896
  # status_code::
489
897
  # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
490
898
  # The type of this field is +Integer+.
899
+ #
900
+ # == Method Options:
901
+ # This method supports an optional +StytchB2B::Organizations::Members::ReactivateRequestOptions+ object which will modify the headers sent in the HTTP request.
491
902
  def reactivate(
492
903
  organization_id:,
493
- member_id:
904
+ member_id:,
905
+ method_options: nil
494
906
  )
907
+ headers = {}
908
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
495
909
  request = {}
496
910
 
497
- put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/reactivate", request)
911
+ put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/reactivate", request, headers)
498
912
  end
499
913
 
500
- # Delete a Member's MFA phone number.
914
+ # Delete a's MFA phone number.
501
915
  #
502
916
  # To change a Member's phone number, you must first call this endpoint to delete the existing phone number.
503
917
  #
@@ -530,11 +944,61 @@ module StytchB2B
530
944
  # status_code::
531
945
  # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
532
946
  # The type of this field is +Integer+.
947
+ #
948
+ # == Method Options:
949
+ # This method supports an optional +StytchB2B::Organizations::Members::DeleteMFAPhoneNumberRequestOptions+ object which will modify the headers sent in the HTTP request.
533
950
  def delete_mfa_phone_number(
534
951
  organization_id:,
535
- member_id:
952
+ member_id:,
953
+ method_options: nil
954
+ )
955
+ headers = {}
956
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
957
+ delete_request("/v1/b2b/organizations/#{organization_id}/members/mfa_phone_numbers/#{member_id}", headers)
958
+ end
959
+
960
+ # Delete a Member's MFA TOTP registration.
961
+ #
962
+ # To mint a new registration for a Member, you must first call this endpoint to delete the existing registration.
963
+ #
964
+ # Existing Member Sessions that include the TOTP authentication factor will not be revoked if the registration is deleted, and MFA will not be enforced until the Member logs in again.
965
+ #
966
+ # == Parameters:
967
+ # organization_id::
968
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
969
+ # The type of this field is +String+.
970
+ # member_id::
971
+ # Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
972
+ # The type of this field is +String+.
973
+ #
974
+ # == Returns:
975
+ # An object with the following fields:
976
+ # request_id::
977
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
978
+ # The type of this field is +String+.
979
+ # member_id::
980
+ # Globally unique UUID that identifies a specific Member.
981
+ # The type of this field is +String+.
982
+ # member::
983
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object)
984
+ # The type of this field is +Member+ (+object+).
985
+ # organization::
986
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
987
+ # The type of this field is +Organization+ (+object+).
988
+ # status_code::
989
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
990
+ # The type of this field is +Integer+.
991
+ #
992
+ # == Method Options:
993
+ # This method supports an optional +StytchB2B::Organizations::Members::DeleteTOTPRequestOptions+ object which will modify the headers sent in the HTTP request.
994
+ def delete_totp(
995
+ organization_id:,
996
+ member_id:,
997
+ method_options: nil
536
998
  )
537
- delete_request("/v1/b2b/organizations/#{organization_id}/members/mfa_phone_numbers/#{member_id}")
999
+ headers = {}
1000
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
1001
+ delete_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/totp", headers)
538
1002
  end
539
1003
 
540
1004
  # Search for Members within specified Organizations. An array with at least one `organization_id` is required. Submitting an empty `query` returns all non-deleted Members within the specified Organizations.
@@ -572,12 +1036,18 @@ module StytchB2B
572
1036
  # status_code::
573
1037
  # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
574
1038
  # The type of this field is +Integer+.
1039
+ #
1040
+ # == Method Options:
1041
+ # This method supports an optional +StytchB2B::Organizations::Members::SearchRequestOptions+ object which will modify the headers sent in the HTTP request.
575
1042
  def search(
576
1043
  organization_ids:,
577
1044
  cursor: nil,
578
1045
  limit: nil,
579
- query: nil
1046
+ query: nil,
1047
+ method_options: nil
580
1048
  )
1049
+ headers = {}
1050
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
581
1051
  request = {
582
1052
  organization_ids: organization_ids
583
1053
  }
@@ -585,10 +1055,10 @@ module StytchB2B
585
1055
  request[:limit] = limit unless limit.nil?
586
1056
  request[:query] = query unless query.nil?
587
1057
 
588
- post_request('/v1/b2b/organizations/members/search', request)
1058
+ post_request('/v1/b2b/organizations/members/search', request, headers)
589
1059
  end
590
1060
 
591
- # Delete a Member's password.
1061
+ # Delete a's password.
592
1062
  #
593
1063
  # == Parameters:
594
1064
  # organization_id::
@@ -615,14 +1085,140 @@ module StytchB2B
615
1085
  # status_code::
616
1086
  # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
617
1087
  # The type of this field is +Integer+.
1088
+ #
1089
+ # == Method Options:
1090
+ # This method supports an optional +StytchB2B::Organizations::Members::DeletePasswordRequestOptions+ object which will modify the headers sent in the HTTP request.
618
1091
  def delete_password(
619
1092
  organization_id:,
620
- member_password_id:
1093
+ member_password_id:,
1094
+ method_options: nil
1095
+ )
1096
+ headers = {}
1097
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
1098
+ delete_request("/v1/b2b/organizations/#{organization_id}/members/passwords/#{member_password_id}", headers)
1099
+ end
1100
+
1101
+ # Get a Member by `member_id`. This endpoint does not require an `organization_id`, enabling you to get members across organizations. This is a dangerous operation. Incorrect use may open you up to indirect object reference (IDOR) attacks. We recommend using the [Get Member](https://stytch.com/docs/b2b/api/get-member) API instead.
1102
+ #
1103
+ # == Parameters:
1104
+ # member_id::
1105
+ # Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
1106
+ # The type of this field is +String+.
1107
+ # include_deleted::
1108
+ # Whether to include deleted Members in the response. Defaults to false.
1109
+ # The type of this field is nilable +Boolean+.
1110
+ #
1111
+ # == Returns:
1112
+ # An object with the following fields:
1113
+ # request_id::
1114
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
1115
+ # The type of this field is +String+.
1116
+ # member_id::
1117
+ # Globally unique UUID that identifies a specific Member.
1118
+ # The type of this field is +String+.
1119
+ # member::
1120
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object)
1121
+ # The type of this field is +Member+ (+object+).
1122
+ # organization::
1123
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
1124
+ # The type of this field is +Organization+ (+object+).
1125
+ # status_code::
1126
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
1127
+ # The type of this field is +Integer+.
1128
+ def dangerously_get(
1129
+ member_id:,
1130
+ include_deleted: nil
1131
+ )
1132
+ headers = {}
1133
+ query_params = {
1134
+ include_deleted: include_deleted
1135
+ }
1136
+ request = request_with_query_params("/v1/b2b/organizations/members/dangerously_get/#{member_id}", query_params)
1137
+ get_request(request, headers)
1138
+ end
1139
+
1140
+ def oidc_providers(
1141
+ organization_id:,
1142
+ member_id:,
1143
+ include_refresh_token: nil
1144
+ )
1145
+ headers = {}
1146
+ query_params = {
1147
+ include_refresh_token: include_refresh_token
1148
+ }
1149
+ request = request_with_query_params("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/oidc_providers", query_params)
1150
+ get_request(request, headers)
1151
+ end
1152
+
1153
+ # Unlinks a retired email address from a specified by their `organization_id` and `member_id`. The email address
1154
+ # to be retired can be identified in the request body by either its `email_id`, its `email_address`, or both. If using
1155
+ # both identifiers they must refer to the same email.
1156
+ #
1157
+ # A previously active email address can be marked as retired in one of two ways:
1158
+ #
1159
+ # - It's replaced with a new primary email address during an explicit Member update.
1160
+ # - A new email address is surfaced by an OAuth, SAML or OIDC provider. In this case the new email address becomes the
1161
+ # Member's primary email address and the old primary email address is retired.
1162
+ #
1163
+ # A retired email address cannot be used by other Members in the same Organization. However, unlinking retired email
1164
+ # addresses allows them to be subsequently re-used by other Organization Members. Retired email addresses can be viewed
1165
+ # on the [Member object](https://stytch.com/docs/b2b/api/member-object).
1166
+ # %}
1167
+ #
1168
+ # == Parameters:
1169
+ # organization_id::
1170
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
1171
+ # The type of this field is +String+.
1172
+ # member_id::
1173
+ # Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
1174
+ # The type of this field is +String+.
1175
+ # email_id::
1176
+ # The globally unique UUID of a Member's email.
1177
+ # The type of this field is nilable +String+.
1178
+ # email_address::
1179
+ # The email address of the Member.
1180
+ # The type of this field is nilable +String+.
1181
+ #
1182
+ # == Returns:
1183
+ # An object with the following fields:
1184
+ # request_id::
1185
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
1186
+ # The type of this field is +String+.
1187
+ # member_id::
1188
+ # Globally unique UUID that identifies a specific Member.
1189
+ # The type of this field is +String+.
1190
+ # organization_id::
1191
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
1192
+ # The type of this field is +String+.
1193
+ # member::
1194
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object)
1195
+ # The type of this field is +Member+ (+object+).
1196
+ # organization::
1197
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
1198
+ # The type of this field is +Organization+ (+object+).
1199
+ # status_code::
1200
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
1201
+ # The type of this field is +Integer+.
1202
+ #
1203
+ # == Method Options:
1204
+ # This method supports an optional +StytchB2B::Organizations::Members::UnlinkRetiredEmailRequestOptions+ object which will modify the headers sent in the HTTP request.
1205
+ def unlink_retired_email(
1206
+ organization_id:,
1207
+ member_id:,
1208
+ email_id: nil,
1209
+ email_address: nil,
1210
+ method_options: nil
621
1211
  )
622
- delete_request("/v1/b2b/organizations/#{organization_id}/members/passwords/#{member_password_id}")
1212
+ headers = {}
1213
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
1214
+ request = {}
1215
+ request[:email_id] = email_id unless email_id.nil?
1216
+ request[:email_address] = email_address unless email_address.nil?
1217
+
1218
+ post_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/unlink_retired_email", request, headers)
623
1219
  end
624
1220
 
625
- # Creates a Member. An `organization_id` and `email_address` are required.
1221
+ # Creates a. An `organization_id` and `email_address` are required.
626
1222
  #
627
1223
  # == Parameters:
628
1224
  # organization_id::
@@ -654,6 +1250,10 @@ module StytchB2B
654
1250
  # mfa_enrolled::
655
1251
  # Sets whether the Member is enrolled in MFA. If true, the Member must complete an MFA step whenever they wish to log in to their Organization. If false, the Member only needs to complete an MFA step if the Organization's MFA policy is set to `REQUIRED_FOR_ALL`.
656
1252
  # The type of this field is nilable +Boolean+.
1253
+ # roles::
1254
+ # Roles to explicitly assign to this Member. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
1255
+ # for more information about role assignment.
1256
+ # The type of this field is nilable list of +String+.
657
1257
  #
658
1258
  # == Returns:
659
1259
  # An object with the following fields:
@@ -672,6 +1272,9 @@ module StytchB2B
672
1272
  # status_code::
673
1273
  # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
674
1274
  # The type of this field is +Integer+.
1275
+ #
1276
+ # == Method Options:
1277
+ # This method supports an optional +StytchB2B::Organizations::Members::CreateRequestOptions+ object which will modify the headers sent in the HTTP request.
675
1278
  def create(
676
1279
  organization_id:,
677
1280
  email_address:,
@@ -681,8 +1284,12 @@ module StytchB2B
681
1284
  create_member_as_pending: nil,
682
1285
  is_breakglass: nil,
683
1286
  mfa_phone_number: nil,
684
- mfa_enrolled: nil
1287
+ mfa_enrolled: nil,
1288
+ roles: nil,
1289
+ method_options: nil
685
1290
  )
1291
+ headers = {}
1292
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
686
1293
  request = {
687
1294
  email_address: email_address
688
1295
  }
@@ -693,8 +1300,9 @@ module StytchB2B
693
1300
  request[:is_breakglass] = is_breakglass unless is_breakglass.nil?
694
1301
  request[:mfa_phone_number] = mfa_phone_number unless mfa_phone_number.nil?
695
1302
  request[:mfa_enrolled] = mfa_enrolled unless mfa_enrolled.nil?
1303
+ request[:roles] = roles unless roles.nil?
696
1304
 
697
- post_request("/v1/b2b/organizations/#{organization_id}/members", request)
1305
+ post_request("/v1/b2b/organizations/#{organization_id}/members", request, headers)
698
1306
  end
699
1307
 
700
1308
  # Get a Member by `member_id` or `email_address`.
@@ -732,12 +1340,141 @@ module StytchB2B
732
1340
  member_id: nil,
733
1341
  email_address: nil
734
1342
  )
1343
+ headers = {}
735
1344
  query_params = {
736
1345
  member_id: member_id,
737
1346
  email_address: email_address
738
1347
  }
739
1348
  request = request_with_query_params("/v1/b2b/organizations/#{organization_id}/member", query_params)
740
- get_request(request)
1349
+ get_request(request, headers)
1350
+ end
1351
+
1352
+ class OAuthProviders
1353
+ include Stytch::RequestHelper
1354
+
1355
+ def initialize(connection)
1356
+ @connection = connection
1357
+ end
1358
+
1359
+ # Retrieve the saved Google access token and ID token for a member. After a successful OAuth login, Stytch will save the
1360
+ # issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh the
1361
+ # access token automatically.
1362
+ #
1363
+ # Google One Tap does not return access tokens. If the member has only authenticated through Google One Tap and not through a regular Google OAuth flow, this endpoint will not return any tokens.
1364
+ #
1365
+ # __Note:__ Google does not issue a refresh token on every login, and refresh tokens may expire if unused.
1366
+ # To force a refresh token to be issued, pass the `?provider_prompt=consent` query param into the
1367
+ # [Start Google OAuth flow](https://stytch.com/docs/b2b/api/oauth-google-start) endpoint.
1368
+ #
1369
+ # == Parameters:
1370
+ # organization_id::
1371
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
1372
+ # The type of this field is +String+.
1373
+ # member_id::
1374
+ # Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
1375
+ # The type of this field is +String+.
1376
+ # include_refresh_token::
1377
+ # Whether to return the refresh token Stytch has stored for the OAuth Provider. Defaults to false. **Important:** If your application exchanges the refresh token, Stytch may not be able to automatically refresh access tokens in the future.
1378
+ # The type of this field is nilable +Boolean+.
1379
+ #
1380
+ # == Returns:
1381
+ # An object with the following fields:
1382
+ # request_id::
1383
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
1384
+ # The type of this field is +String+.
1385
+ # provider_type::
1386
+ # Denotes the OAuth identity provider that the user has authenticated with, e.g. Google, Microsoft, GitHub etc.
1387
+ # The type of this field is +String+.
1388
+ # provider_subject::
1389
+ # The unique identifier for the User within a given OAuth provider. Also commonly called the `sub` or "Subject field" in OAuth protocols.
1390
+ # The type of this field is +String+.
1391
+ # id_token::
1392
+ # The `id_token` returned by the OAuth provider. ID Tokens are JWTs that contain structured information about a user. The exact content of each ID Token varies from provider to provider. ID Tokens are returned from OAuth providers that conform to the [OpenID Connect](https://openid.net/foundation/) specification, which is based on OAuth.
1393
+ # The type of this field is +String+.
1394
+ # scopes::
1395
+ # The OAuth scopes included for a given provider. See each provider's section above to see which scopes are included by default and how to add custom scopes.
1396
+ # The type of this field is list of +String+.
1397
+ # status_code::
1398
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
1399
+ # The type of this field is +Integer+.
1400
+ # access_token::
1401
+ # The `access_token` that you may use to access the User's data in the provider's API.
1402
+ # The type of this field is nilable +String+.
1403
+ # access_token_expires_in::
1404
+ # The number of seconds until the access token expires.
1405
+ # The type of this field is nilable +Integer+.
1406
+ # refresh_token::
1407
+ # The `refresh_token` that you may use to obtain a new `access_token` for the User within the provider's API.
1408
+ # The type of this field is nilable +String+.
1409
+ def google(
1410
+ organization_id:,
1411
+ member_id:,
1412
+ include_refresh_token: nil
1413
+ )
1414
+ headers = {}
1415
+ query_params = {
1416
+ include_refresh_token: include_refresh_token
1417
+ }
1418
+ request = request_with_query_params("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/oauth_providers/google", query_params)
1419
+ get_request(request, headers)
1420
+ end
1421
+
1422
+ # Retrieve the saved Microsoft access token and ID token for a member. After a successful OAuth login, Stytch will save the
1423
+ # issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh the
1424
+ # access token automatically.
1425
+ #
1426
+ # == Parameters:
1427
+ # organization_id::
1428
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
1429
+ # The type of this field is +String+.
1430
+ # member_id::
1431
+ # Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
1432
+ # The type of this field is +String+.
1433
+ # include_refresh_token::
1434
+ # Whether to return the refresh token Stytch has stored for the OAuth Provider. Defaults to false. **Important:** If your application exchanges the refresh token, Stytch may not be able to automatically refresh access tokens in the future.
1435
+ # The type of this field is nilable +Boolean+.
1436
+ #
1437
+ # == Returns:
1438
+ # An object with the following fields:
1439
+ # request_id::
1440
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
1441
+ # The type of this field is +String+.
1442
+ # provider_type::
1443
+ # Denotes the OAuth identity provider that the user has authenticated with, e.g. Google, Microsoft, GitHub etc.
1444
+ # The type of this field is +String+.
1445
+ # provider_subject::
1446
+ # The unique identifier for the User within a given OAuth provider. Also commonly called the `sub` or "Subject field" in OAuth protocols.
1447
+ # The type of this field is +String+.
1448
+ # access_token::
1449
+ # The `access_token` that you may use to access the User's data in the provider's API.
1450
+ # The type of this field is +String+.
1451
+ # access_token_expires_in::
1452
+ # The number of seconds until the access token expires.
1453
+ # The type of this field is +Integer+.
1454
+ # id_token::
1455
+ # The `id_token` returned by the OAuth provider. ID Tokens are JWTs that contain structured information about a user. The exact content of each ID Token varies from provider to provider. ID Tokens are returned from OAuth providers that conform to the [OpenID Connect](https://openid.net/foundation/) specification, which is based on OAuth.
1456
+ # The type of this field is +String+.
1457
+ # scopes::
1458
+ # The OAuth scopes included for a given provider. See each provider's section above to see which scopes are included by default and how to add custom scopes.
1459
+ # The type of this field is list of +String+.
1460
+ # status_code::
1461
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
1462
+ # The type of this field is +Integer+.
1463
+ # refresh_token::
1464
+ # The `refresh_token` that you may use to obtain a new `access_token` for the User within the provider's API.
1465
+ # The type of this field is nilable +String+.
1466
+ def microsoft(
1467
+ organization_id:,
1468
+ member_id:,
1469
+ include_refresh_token: nil
1470
+ )
1471
+ headers = {}
1472
+ query_params = {
1473
+ include_refresh_token: include_refresh_token
1474
+ }
1475
+ request = request_with_query_params("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/oauth_providers/microsoft", query_params)
1476
+ get_request(request, headers)
1477
+ end
741
1478
  end
742
1479
  end
743
1480
  end