stytch 6.6.0 → 7.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,44 @@
9
9
  require_relative 'request_helper'
10
10
 
11
11
  module StytchB2B
12
+ class UpdateRequestOptions
13
+ # Optional authorization object.
14
+ # Pass in an active Stytch Member session token or session JWT and the request
15
+ # will be run using that member's permissions.
16
+ attr_accessor :authorization
17
+
18
+ def initialize(
19
+ authorization: nil
20
+ )
21
+ @authorization = authorization
22
+ end
23
+
24
+ def to_headers
25
+ headers = {}
26
+ headers.merge!(@authorization.to_headers) if authorization
27
+ headers
28
+ end
29
+ end
30
+
31
+ class DeleteRequestOptions
32
+ # Optional authorization object.
33
+ # Pass in an active Stytch Member session token or session JWT and the request
34
+ # will be run using that member's permissions.
35
+ attr_accessor :authorization
36
+
37
+ def initialize(
38
+ authorization: nil
39
+ )
40
+ @authorization = authorization
41
+ end
42
+
43
+ def to_headers
44
+ headers = {}
45
+ headers.merge!(@authorization.to_headers) if authorization
46
+ headers
47
+ end
48
+ end
49
+
12
50
  class Organizations
13
51
  include Stytch::RequestHelper
14
52
  attr_reader :members
@@ -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,17 @@ 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
+ # (Coming Soon) 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+).
97
140
  #
98
141
  # == Returns:
99
142
  # An object with the following fields:
@@ -117,8 +160,10 @@ module StytchB2B
117
160
  email_invites: nil,
118
161
  auth_methods: nil,
119
162
  allowed_auth_methods: nil,
120
- mfa_policy: nil
163
+ mfa_policy: nil,
164
+ rbac_email_implicit_role_assignments: nil
121
165
  )
166
+ headers = {}
122
167
  request = {
123
168
  organization_name: organization_name
124
169
  }
@@ -132,8 +177,9 @@ module StytchB2B
132
177
  request[:auth_methods] = auth_methods unless auth_methods.nil?
133
178
  request[:allowed_auth_methods] = allowed_auth_methods unless allowed_auth_methods.nil?
134
179
  request[:mfa_policy] = mfa_policy unless mfa_policy.nil?
180
+ request[:rbac_email_implicit_role_assignments] = rbac_email_implicit_role_assignments unless rbac_email_implicit_role_assignments.nil?
135
181
 
136
- post_request('/v1/b2b/organizations', request)
182
+ post_request('/v1/b2b/organizations', request, headers)
137
183
  end
138
184
 
139
185
  # Returns an Organization specified by `organization_id`.
@@ -157,33 +203,56 @@ module StytchB2B
157
203
  def get(
158
204
  organization_id:
159
205
  )
206
+ headers = {}
160
207
  query_params = {}
161
208
  request = request_with_query_params("/v1/b2b/organizations/#{organization_id}", query_params)
162
- get_request(request)
209
+ get_request(request, headers)
163
210
  end
164
211
 
165
212
  # 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.
166
213
  #
167
214
  # *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
215
  #
216
+ # (Coming Soon) Our RBAC implementation offers out-of-the-box handling of authorization checks for this endpoint. If you pass in
217
+ # a header containing a `session_token` or a `session_jwt` for an unexpired Member Session, we will check that the
218
+ # Member Session has the necessary permissions. The specific permissions needed depend on which of the optional fields
219
+ # are passed in the request. For example, if the `organization_name` argument is provided, the Member Session must have
220
+ # permission to perform the `update.info.name` action on the `stytch.organization` Resource.
221
+ #
222
+ # If the Member Session does not contain a Role that satisfies the requested permissions, or if the Member's Organization
223
+ # does not match the `organization_id` passed in the request, a 403 error will be thrown. Otherwise, the request will
224
+ # proceed as normal.
225
+ #
226
+ # To learn more about our RBAC implementation, see our [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/overview).
227
+ #
169
228
  # == Parameters:
170
229
  # organization_id::
171
230
  # 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
231
  # The type of this field is +String+.
173
232
  # organization_name::
174
233
  # The name of the Organization. Must be between 1 and 128 characters in length.
234
+ #
235
+ # 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
236
  # The type of this field is nilable +String+.
176
237
  # organization_slug::
177
238
  # 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.
239
+ #
240
+ # 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
241
  # The type of this field is nilable +String+.
179
242
  # organization_logo_url::
180
243
  # The image URL of the Organization logo.
244
+ #
245
+ # 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
246
  # The type of this field is nilable +String+.
182
247
  # trusted_metadata::
183
248
  # An arbitrary JSON object for storing application-specific data or identity-provider-specific data.
249
+ # If a session header is passed into the request, this field may **not** be passed into the request. You cannot
250
+ # update trusted metadata when acting as a Member.
184
251
  # The type of this field is nilable +object+.
185
252
  # sso_default_connection_id::
186
253
  # The default connection used for SSO when there are multiple active connections.
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.settings.default-sso-connection` action on the `stytch.organization` Resource.
187
256
  # The type of this field is nilable +String+.
188
257
  # sso_jit_provisioning::
189
258
  # The authentication setting that controls the JIT provisioning of Members when authenticating via SSO. The accepted values are:
@@ -194,24 +263,32 @@ module StytchB2B
194
263
  #
195
264
  # `NOT_ALLOWED` – disable JIT provisioning via SSO.
196
265
  #
266
+ #
267
+ # 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
268
  # The type of this field is nilable +String+.
198
269
  # sso_jit_provisioning_allowed_connections::
199
270
  # An array of `connection_id`s that reference [SAML Connection objects](https://stytch.com/docs/b2b/api/saml-connection-object).
200
271
  # Only these connections will be allowed to JIT provision Members via SSO when `sso_jit_provisioning` is set to `RESTRICTED`.
272
+ #
273
+ # 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
274
  # The type of this field is nilable list of +String+.
202
275
  # email_allowed_domains::
203
276
  # 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
277
  #
205
278
  #
206
279
  # 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.
280
+ #
281
+ # 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
282
  # The type of this field is nilable list of +String+.
208
283
  # 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:
284
+ # The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link or OAuth. The accepted values are:
285
+ #
286
+ # `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
287
  #
211
- # `RESTRICTED` – only new Members with verified emails that comply with `email_allowed_domains` can be provisioned upon authentication via Email Magic Link.
288
+ # `NOT_ALLOWED` – disable JIT provisioning via Email Magic Link and OAuth.
212
289
  #
213
- # `NOT_ALLOWED` – disable JIT provisioning via Email Magic Link.
214
290
  #
291
+ # 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
292
  # The type of this field is nilable +String+.
216
293
  # email_invites::
217
294
  # The authentication setting that controls how a new Member can be invited to an organization by email. The accepted values are:
@@ -222,6 +299,8 @@ module StytchB2B
222
299
  #
223
300
  # `NOT_ALLOWED` – disable email invites.
224
301
  #
302
+ #
303
+ # 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
304
  # The type of this field is nilable +String+.
226
305
  # auth_methods::
227
306
  # The setting that controls which authentication methods can be used by Members of an Organization. The accepted values are:
@@ -230,21 +309,34 @@ module StytchB2B
230
309
  #
231
310
  # `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
311
  #
312
+ #
313
+ # 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
314
  # The type of this field is nilable +String+.
234
315
  # allowed_auth_methods::
235
- #
236
316
  # An array of allowed authentication methods. This list is enforced when `auth_methods` is set to `RESTRICTED`.
237
317
  # The list's accepted values are: `sso`, `magic_link`, `password`, `google_oauth`, and `microsoft_oauth`.
238
318
  #
319
+ #
320
+ # 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
321
  # The type of this field is nilable list of +String+.
240
322
  # mfa_policy::
241
323
  # The setting that controls the MFA policy for all Members in the Organization. The accepted values are:
242
324
  #
243
- # `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time they wish to log in.
325
+ # `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
326
  #
245
327
  # `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
328
  #
329
+ #
330
+ # 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.
247
331
  # The type of this field is nilable +String+.
332
+ # rbac_email_implicit_role_assignments::
333
+ # (Coming Soon) Implicit role assignments based off of email domains.
334
+ # For each domain-Role pair, all Members whose email addresses have the specified email domain will be granted the
335
+ # associated Role, regardless of their login method. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
336
+ # for more information about role assignment.
337
+ #
338
+ # 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.
339
+ # The type of this field is nilable list of +String+.
248
340
  #
249
341
  # == Returns:
250
342
  # An object with the following fields:
@@ -257,6 +349,9 @@ module StytchB2B
257
349
  # status_code::
258
350
  # 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
351
  # The type of this field is +Integer+.
352
+ #
353
+ # == Method Options:
354
+ # This method supports an optional +UpdateRequestOptions+ object which will modify the headers sent in the HTTP request.
260
355
  def update(
261
356
  organization_id:,
262
357
  organization_name: nil,
@@ -271,8 +366,12 @@ module StytchB2B
271
366
  email_invites: nil,
272
367
  auth_methods: nil,
273
368
  allowed_auth_methods: nil,
274
- mfa_policy: nil
369
+ mfa_policy: nil,
370
+ rbac_email_implicit_role_assignments: nil,
371
+ method_options: nil
275
372
  )
373
+ headers = {}
374
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
276
375
  request = {}
277
376
  request[:organization_name] = organization_name unless organization_name.nil?
278
377
  request[:organization_slug] = organization_slug unless organization_slug.nil?
@@ -287,11 +386,12 @@ module StytchB2B
287
386
  request[:auth_methods] = auth_methods unless auth_methods.nil?
288
387
  request[:allowed_auth_methods] = allowed_auth_methods unless allowed_auth_methods.nil?
289
388
  request[:mfa_policy] = mfa_policy unless mfa_policy.nil?
389
+ request[:rbac_email_implicit_role_assignments] = rbac_email_implicit_role_assignments unless rbac_email_implicit_role_assignments.nil?
290
390
 
291
- put_request("/v1/b2b/organizations/#{organization_id}", request)
391
+ put_request("/v1/b2b/organizations/#{organization_id}", request, headers)
292
392
  end
293
393
 
294
- # Deletes an Organization specified by `organization_id`. All Members of the Organization will also be deleted.
394
+ # Deletes an Organization specified by `organization_id`. All Members of the Organization will also be deleted. /%}
295
395
  #
296
396
  # == Parameters:
297
397
  # organization_id::
@@ -309,10 +409,16 @@ module StytchB2B
309
409
  # status_code::
310
410
  # 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.
311
411
  # The type of this field is +Integer+.
412
+ #
413
+ # == Method Options:
414
+ # This method supports an optional +DeleteRequestOptions+ object which will modify the headers sent in the HTTP request.
312
415
  def delete(
313
- organization_id:
416
+ organization_id:,
417
+ method_options: nil
314
418
  )
315
- delete_request("/v1/b2b/organizations/#{organization_id}")
419
+ headers = {}
420
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
421
+ delete_request("/v1/b2b/organizations/#{organization_id}", headers)
316
422
  end
317
423
 
318
424
  # 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.
@@ -347,12 +453,13 @@ module StytchB2B
347
453
  limit: nil,
348
454
  query: nil
349
455
  )
456
+ headers = {}
350
457
  request = {}
351
458
  request[:cursor] = cursor unless cursor.nil?
352
459
  request[:limit] = limit unless limit.nil?
353
460
  request[:query] = query unless query.nil?
354
461
 
355
- post_request('/v1/b2b/organizations/search', request)
462
+ post_request('/v1/b2b/organizations/search', request, headers)
356
463
  end
357
464
 
358
465
  class Members
@@ -364,6 +471,18 @@ module StytchB2B
364
471
 
365
472
  # Updates a Member specified by `organization_id` and `member_id`.
366
473
  #
474
+ # (Coming Soon) Our RBAC implementation offers out-of-the-box handling of authorization checks for this endpoint. If you pass in
475
+ # a header containing a `session_token` or a `session_jwt` for an unexpired Member Session, we will check that the
476
+ # Member Session has the necessary permissions. The specific permissions needed depend on which of the optional fields
477
+ # are passed in the request. For example, if the `organization_name` argument is provided, the Member Session must have
478
+ # permission to perform the `update.info.name` action on the `stytch.organization` Resource.
479
+ #
480
+ # If the Member Session does not contain a Role that satisfies the requested permissions, or if the Member's Organization
481
+ # does not match the `organization_id` passed in the request, a 403 error will be thrown. Otherwise, the request will
482
+ # proceed as normal.
483
+ #
484
+ # To learn more about our RBAC implementation, see our [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/overview).
485
+ #
367
486
  # == Parameters:
368
487
  # organization_id::
369
488
  # 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.
@@ -373,23 +492,56 @@ module StytchB2B
373
492
  # The type of this field is +String+.
374
493
  # name::
375
494
  # The name of the Member.
495
+ #
496
+ # 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.
497
+ # 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.
376
498
  # The type of this field is nilable +String+.
377
499
  # trusted_metadata::
378
500
  # An arbitrary JSON object for storing application-specific data or identity-provider-specific data.
501
+ # If a session header is passed into the request, this field may **not** be passed into the request. You cannot
502
+ # update trusted metadata when acting as a Member.
379
503
  # The type of this field is nilable +object+.
380
504
  # untrusted_metadata::
381
505
  # An arbitrary JSON object of application-specific data. These fields can be edited directly by the
382
506
  # frontend SDK, and should not be used to store critical information. See the [Metadata resource](https://stytch.com/docs/b2b/api/metadata)
383
507
  # for complete field behavior details.
508
+ #
509
+ # 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.
510
+ # 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.
384
511
  # The type of this field is nilable +object+.
385
512
  # is_breakglass::
386
513
  # 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.
514
+ #
515
+ # 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.is-breakglass` action on the `stytch.member` Resource.
387
516
  # The type of this field is nilable +Boolean+.
388
517
  # mfa_phone_number::
389
518
  # 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.
519
+ #
520
+ # 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.
521
+ # 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.
390
522
  # The type of this field is nilable +String+.
391
523
  # mfa_enrolled::
392
524
  # 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`.
525
+ #
526
+ # 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.
527
+ # 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.
528
+ # The type of this field is nilable +Boolean+.
529
+ # roles::
530
+ # (Coming Soon) Roles to explicitly assign to this Member.
531
+ # Will completely replace any existing explicitly assigned roles. See the
532
+ # [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment.
533
+ #
534
+ # If a Role is removed from a Member, and the Member is also implicitly assigned this Role from an SSO connection
535
+ # or an SSO group, we will by default revoke any existing sessions for the Member that contain any SSO
536
+ # authentication factors with the affected connection ID. You can preserve these sessions by passing in the
537
+ # `preserve_existing_sessions` parameter with a value of `true`.
538
+ #
539
+ # 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.
540
+ # The type of this field is nilable list of +String+.
541
+ # preserve_existing_sessions::
542
+ # (Coming Soon) Whether to preserve existing sessions when explicit Roles that are revoked are also implicitly assigned
543
+ # by SSO connection or SSO group. Defaults to `false` - that is, existing Member Sessions that contain SSO
544
+ # authentication factors with the affected SSO connection IDs will be revoked.
393
545
  # The type of this field is nilable +Boolean+.
394
546
  #
395
547
  # == Returns:
@@ -409,6 +561,9 @@ module StytchB2B
409
561
  # status_code::
410
562
  # 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.
411
563
  # The type of this field is +Integer+.
564
+ #
565
+ # == Method Options:
566
+ # This method supports an optional +UpdateRequestOptions+ object which will modify the headers sent in the HTTP request.
412
567
  def update(
413
568
  organization_id:,
414
569
  member_id:,
@@ -417,8 +572,13 @@ module StytchB2B
417
572
  untrusted_metadata: nil,
418
573
  is_breakglass: nil,
419
574
  mfa_phone_number: nil,
420
- mfa_enrolled: nil
575
+ mfa_enrolled: nil,
576
+ roles: nil,
577
+ preserve_existing_sessions: nil,
578
+ method_options: nil
421
579
  )
580
+ headers = {}
581
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
422
582
  request = {}
423
583
  request[:name] = name unless name.nil?
424
584
  request[:trusted_metadata] = trusted_metadata unless trusted_metadata.nil?
@@ -426,11 +586,13 @@ module StytchB2B
426
586
  request[:is_breakglass] = is_breakglass unless is_breakglass.nil?
427
587
  request[:mfa_phone_number] = mfa_phone_number unless mfa_phone_number.nil?
428
588
  request[:mfa_enrolled] = mfa_enrolled unless mfa_enrolled.nil?
589
+ request[:roles] = roles unless roles.nil?
590
+ request[:preserve_existing_sessions] = preserve_existing_sessions unless preserve_existing_sessions.nil?
429
591
 
430
- put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}", request)
592
+ put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}", request, headers)
431
593
  end
432
594
 
433
- # Deletes a Member specified by `organization_id` and `member_id`.
595
+ # Deletes a Member specified by `organization_id` and `member_id`. /%}
434
596
  #
435
597
  # == Parameters:
436
598
  # organization_id::
@@ -451,14 +613,20 @@ module StytchB2B
451
613
  # status_code::
452
614
  # 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.
453
615
  # The type of this field is +Integer+.
616
+ #
617
+ # == Method Options:
618
+ # This method supports an optional +DeleteRequestOptions+ object which will modify the headers sent in the HTTP request.
454
619
  def delete(
455
620
  organization_id:,
456
- member_id:
621
+ member_id:,
622
+ method_options: nil
457
623
  )
458
- delete_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}")
624
+ headers = {}
625
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
626
+ delete_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}", headers)
459
627
  end
460
628
 
461
- # Reactivates a deleted Member's status and its associated email status (if applicable) to active, specified by `organization_id` and `member_id`.
629
+ # Reactivates a deleted Member's status and its associated email status (if applicable) to active, specified by `organization_id` and `member_id`. /%}
462
630
  #
463
631
  # == Parameters:
464
632
  # organization_id::
@@ -485,13 +653,19 @@ module StytchB2B
485
653
  # status_code::
486
654
  # 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.
487
655
  # The type of this field is +Integer+.
656
+ #
657
+ # == Method Options:
658
+ # This method supports an optional +ReactivateRequestOptions+ object which will modify the headers sent in the HTTP request.
488
659
  def reactivate(
489
660
  organization_id:,
490
- member_id:
661
+ member_id:,
662
+ method_options: nil
491
663
  )
664
+ headers = {}
665
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
492
666
  request = {}
493
667
 
494
- put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/reactivate", request)
668
+ put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/reactivate", request, headers)
495
669
  end
496
670
 
497
671
  # Delete a Member's MFA phone number.
@@ -501,6 +675,7 @@ module StytchB2B
501
675
  # Existing Member Sessions that include a phone number authentication factor will not be revoked if the phone number is deleted, and MFA will not be enforced until the Member logs in again.
502
676
  # If you wish to enforce MFA immediately after a phone number is deleted, you can do so by prompting the Member to enter a new phone number
503
677
  # and calling the [OTP SMS send](https://stytch.com/docs/b2b/api/otp-sms-send) endpoint, then calling the [OTP SMS Authenticate](https://stytch.com/docs/b2b/api/authenticate-otp-sms) endpoint.
678
+ # /%}
504
679
  #
505
680
  # == Parameters:
506
681
  # organization_id::
@@ -527,17 +702,35 @@ module StytchB2B
527
702
  # status_code::
528
703
  # 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.
529
704
  # The type of this field is +Integer+.
705
+ #
706
+ # == Method Options:
707
+ # This method supports an optional +DeleteMFAPhoneNumberRequestOptions+ object which will modify the headers sent in the HTTP request.
530
708
  def delete_mfa_phone_number(
531
709
  organization_id:,
532
- member_id:
710
+ member_id:,
711
+ method_options: nil
533
712
  )
534
- delete_request("/v1/b2b/organizations/#{organization_id}/members/mfa_phone_numbers/#{member_id}")
713
+ headers = {}
714
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
715
+ delete_request("/v1/b2b/organizations/#{organization_id}/members/mfa_phone_numbers/#{member_id}", headers)
535
716
  end
536
717
 
537
718
  # 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.
538
719
  #
539
720
  # *All fuzzy search filters require a minimum of three characters.
540
721
  #
722
+ # (Coming Soon) Our RBAC implementation offers out-of-the-box handling of authorization checks for this endpoint. If you pass in
723
+ # a header containing a `session_token` or a `session_jwt` for an unexpired Member Session, we will check that the
724
+ # Member Session has permission to perform the `search` action on the `stytch.member` Resource. In addition, enforcing
725
+ # RBAC on this endpoint means that you may only search for Members within the calling Member's Organization, so the
726
+ # `organization_ids` argument may only contain the `organization_id` of the Member Session passed in the header.
727
+ #
728
+ # If the Member Session does not contain a Role that satisfies the requested permission, or if the `organization_ids`
729
+ # argument contains an `organization_id` that the Member Session does not belong to, a 403 error will be thrown.
730
+ # Otherwise, the request will proceed as normal.
731
+ #
732
+ # To learn more about our RBAC implementation, see our [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/overview).
733
+ #
541
734
  # == Parameters:
542
735
  # organization_ids::
543
736
  # An array of organization_ids. At least one value is required.
@@ -569,12 +762,18 @@ module StytchB2B
569
762
  # status_code::
570
763
  # 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.
571
764
  # The type of this field is +Integer+.
765
+ #
766
+ # == Method Options:
767
+ # This method supports an optional +SearchRequestOptions+ object which will modify the headers sent in the HTTP request.
572
768
  def search(
573
769
  organization_ids:,
574
770
  cursor: nil,
575
771
  limit: nil,
576
- query: nil
772
+ query: nil,
773
+ method_options: nil
577
774
  )
775
+ headers = {}
776
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
578
777
  request = {
579
778
  organization_ids: organization_ids
580
779
  }
@@ -582,10 +781,10 @@ module StytchB2B
582
781
  request[:limit] = limit unless limit.nil?
583
782
  request[:query] = query unless query.nil?
584
783
 
585
- post_request('/v1/b2b/organizations/members/search', request)
784
+ post_request('/v1/b2b/organizations/members/search', request, headers)
586
785
  end
587
786
 
588
- # Delete a Member's password.
787
+ # Delete a Member's password. /%}
589
788
  #
590
789
  # == Parameters:
591
790
  # organization_id::
@@ -612,14 +811,20 @@ module StytchB2B
612
811
  # status_code::
613
812
  # 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.
614
813
  # The type of this field is +Integer+.
814
+ #
815
+ # == Method Options:
816
+ # This method supports an optional +DeletePasswordRequestOptions+ object which will modify the headers sent in the HTTP request.
615
817
  def delete_password(
616
818
  organization_id:,
617
- member_password_id:
819
+ member_password_id:,
820
+ method_options: nil
618
821
  )
619
- delete_request("/v1/b2b/organizations/#{organization_id}/members/passwords/#{member_password_id}")
822
+ headers = {}
823
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
824
+ delete_request("/v1/b2b/organizations/#{organization_id}/members/passwords/#{member_password_id}", headers)
620
825
  end
621
826
 
622
- # Get a Member by `member_id`. This endpoint does not require an `organization_id`, so you can use it 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.
827
+ # 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.
623
828
  #
624
829
  # == Parameters:
625
830
  # member_id::
@@ -646,12 +851,13 @@ module StytchB2B
646
851
  def dangerously_get(
647
852
  member_id:
648
853
  )
854
+ headers = {}
649
855
  query_params = {}
650
856
  request = request_with_query_params("/v1/b2b/organizations/members/dangerously_get/#{member_id}", query_params)
651
- get_request(request)
857
+ get_request(request, headers)
652
858
  end
653
859
 
654
- # Creates a Member. An `organization_id` and `email_address` are required.
860
+ # Creates a Member. An `organization_id` and `email_address` are required. /%}
655
861
  #
656
862
  # == Parameters:
657
863
  # organization_id::
@@ -683,6 +889,10 @@ module StytchB2B
683
889
  # mfa_enrolled::
684
890
  # 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`.
685
891
  # The type of this field is nilable +Boolean+.
892
+ # roles::
893
+ # (Coming Soon) Roles to explicitly assign to this Member. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
894
+ # for more information about role assignment.
895
+ # The type of this field is nilable list of +String+.
686
896
  #
687
897
  # == Returns:
688
898
  # An object with the following fields:
@@ -701,6 +911,9 @@ module StytchB2B
701
911
  # status_code::
702
912
  # 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.
703
913
  # The type of this field is +Integer+.
914
+ #
915
+ # == Method Options:
916
+ # This method supports an optional +CreateRequestOptions+ object which will modify the headers sent in the HTTP request.
704
917
  def create(
705
918
  organization_id:,
706
919
  email_address:,
@@ -710,8 +923,12 @@ module StytchB2B
710
923
  create_member_as_pending: nil,
711
924
  is_breakglass: nil,
712
925
  mfa_phone_number: nil,
713
- mfa_enrolled: nil
926
+ mfa_enrolled: nil,
927
+ roles: nil,
928
+ method_options: nil
714
929
  )
930
+ headers = {}
931
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
715
932
  request = {
716
933
  email_address: email_address
717
934
  }
@@ -722,8 +939,9 @@ module StytchB2B
722
939
  request[:is_breakglass] = is_breakglass unless is_breakglass.nil?
723
940
  request[:mfa_phone_number] = mfa_phone_number unless mfa_phone_number.nil?
724
941
  request[:mfa_enrolled] = mfa_enrolled unless mfa_enrolled.nil?
942
+ request[:roles] = roles unless roles.nil?
725
943
 
726
- post_request("/v1/b2b/organizations/#{organization_id}/members", request)
944
+ post_request("/v1/b2b/organizations/#{organization_id}/members", request, headers)
727
945
  end
728
946
 
729
947
  # Get a Member by `member_id` or `email_address`.
@@ -761,12 +979,13 @@ module StytchB2B
761
979
  member_id: nil,
762
980
  email_address: nil
763
981
  )
982
+ headers = {}
764
983
  query_params = {
765
984
  member_id: member_id,
766
985
  email_address: email_address
767
986
  }
768
987
  request = request_with_query_params("/v1/b2b/organizations/#{organization_id}/member", query_params)
769
- get_request(request)
988
+ get_request(request, headers)
770
989
  end
771
990
  end
772
991
  end