Skip to content

Commit

Permalink
Retired Emails (#131)
Browse files Browse the repository at this point in the history
* Retired Emails

* Minor version bump.

* Remove OAuth tenant code.

* Include docs fix
  • Loading branch information
jcook-stytch authored Jul 26, 2024
1 parent 27a7a50 commit 74c7242
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
87 changes: 87 additions & 0 deletions lib/stytch/b2b_organizations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,25 @@ def to_headers
end
end

class UnlinkRetiredEmailRequestOptions
# Optional authorization object.
# Pass in an active Stytch Member session token or session JWT and the request
# will be run using that member's permissions.
attr_accessor :authorization

def initialize(
authorization: nil
)
@authorization = authorization
end

def to_headers
headers = {}
headers.merge!(@authorization.to_headers) if authorization
headers
end
end

class CreateRequestOptions
# Optional authorization object.
# Pass in an active Stytch Member session token or session JWT and the request
Expand Down Expand Up @@ -1078,6 +1097,74 @@ def dangerously_get(
get_request(request, headers)
end

# Unlinks a retired email address from a Member specified by their `organization_id` and `member_id`. The email address
# to be retired can be identified in the request body by either its `email_id`, its `email_address`, or both. If using
# both identifiers they must refer to the same email.
#
# A previously active email address can be marked as retired in one of two ways:
#
# - It's replaced with a new primary email address during an explicit Member update.
# - A new email address is surfaced by an OAuth, SAML or OIDC provider. In this case the new email address becomes the
# Member's primary email address and the old primary email address is retired.
#
# A retired email address cannot be used by other Members in the same Organization. However, unlinking retired email
# addresses allows then to be subsequently re-used by other Organization Members. Retired email addresses can be viewed
# on the [Member object](https://stytch.com/docs/b2b/api/member-object).
# %}
#
# == Parameters:
# organization_id::
# 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.
# The type of this field is +String+.
# member_id::
# 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.
# The type of this field is +String+.
# email_id::
# The globally unique UUID of a Member's email.
# The type of this field is nilable +String+.
# email_address::
# The email address of the Member.
# The type of this field is nilable +String+.
#
# == Returns:
# An object with the following fields:
# request_id::
# 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.
# The type of this field is +String+.
# member_id::
# Globally unique UUID that identifies a specific Member.
# The type of this field is +String+.
# organization_id::
# 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.
# The type of this field is +String+.
# member::
# The [Member object](https://stytch.com/docs/b2b/api/member-object)
# The type of this field is +Member+ (+object+).
# organization::
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
# The type of this field is +Organization+ (+object+).
# status_code::
# 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.
# The type of this field is +Integer+.
#
# == Method Options:
# This method supports an optional +StytchB2B::Organizations::Members::UnlinkRetiredEmailRequestOptions+ object which will modify the headers sent in the HTTP request.
def unlink_retired_email(
organization_id:,
member_id:,
email_id: nil,
email_address: nil,
method_options: nil
)
headers = {}
headers = headers.merge(method_options.to_headers) unless method_options.nil?
request = {}
request[:email_id] = email_id unless email_id.nil?
request[:email_address] = email_address unless email_address.nil?

post_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/unlink_retired_email", request, headers)
end

# Creates a Member. An `organization_id` and `email_address` are required.
#
# == Parameters:
Expand Down
2 changes: 1 addition & 1 deletion lib/stytch/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Stytch
VERSION = '9.2.0'
VERSION = '9.3.0'
end

0 comments on commit 74c7242

Please sign in to comment.