Skip to content

Commit

Permalink
SCIM (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
ollie-stytch authored Jun 3, 2024
1 parent 112c5c9 commit 79d8f27
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
9 changes: 7 additions & 2 deletions lib/stytch/b2b_magic_links.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ def initialize(connection)

# Send either a login or signup magic link to a Member. A new, pending, or invited Member will receive a signup Email Magic Link. Members will have a `pending` status until they successfully authenticate. An active Member will receive a login Email Magic Link.
#
# The magic link is valid for 60 minutes.
#
# == 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.
Expand Down Expand Up @@ -263,7 +265,10 @@ def login_or_signup(
post_request('/v1/b2b/magic_links/email/login_or_signup', request, headers)
end

# Send an invite email to a new Member to join an Organization. The Member will be created with an `invited` status until they successfully authenticate. Sending invites to `pending` Members will update their status to `invited`. Sending invites to already `active` Members will return an error. /%}
# Send an invite email to a new Member to join an Organization. The Member will be created with an `invited` status until they successfully authenticate. Sending invites to `pending` Members will update their status to `invited`. Sending invites to already `active` Members will return an error.
#
# The magic link invite will be valid for 1 week.
# /%}
#
# == Parameters:
# organization_id::
Expand Down Expand Up @@ -366,7 +371,7 @@ def initialize(connection)
@connection = connection
end

# Send a discovery magic link to an email address.
# Send a discovery magic link to an email address. The magic link is valid for 60 minutes.
#
# == Parameters:
# email_address::
Expand Down
44 changes: 22 additions & 22 deletions lib/stytch/b2b_scim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
module StytchB2B
class SCIM
include Stytch::RequestHelper
attr_reader :connections
attr_reader :connection

def initialize(connection)
@connection = connection

@connections = StytchB2B::SCIM::Connections.new(@connection)
@connection = StytchB2B::SCIM::Connection.new(@connection)
end

class Connections
class Connection
class UpdateRequestOptions
# Optional authorization object.
# Pass in an active Stytch Member session token or session JWT and the request
Expand Down Expand Up @@ -173,7 +173,7 @@ def initialize(connection)
# The type of this field is nilable +String+.
# identity_provider::
# (no documentation yet)
# The type of this field is nilable +UpdateRequestIdp+ (string enum).
# The type of this field is nilable +UpdateRequestIdentityProvider+ (string enum).
# scim_group_implicit_role_assignments::
# (no documentation yet)
# The type of this field is nilable list of +SCIMGroupImplicitRoleAssignments+.
Expand All @@ -191,7 +191,7 @@ def initialize(connection)
# The type of this field is nilable +SCIMConnection+ (+object+).
#
# == Method Options:
# This method supports an optional +StytchB2B::SCIM::Connections::UpdateRequestOptions+ object which will modify the headers sent in the HTTP request.
# This method supports an optional +StytchB2B::SCIM::Connection::UpdateRequestOptions+ object which will modify the headers sent in the HTTP request.
def update(
organization_id:,
connection_id:,
Expand All @@ -207,7 +207,7 @@ def update(
request[:identity_provider] = identity_provider unless identity_provider.nil?
request[:scim_group_implicit_role_assignments] = scim_group_implicit_role_assignments unless scim_group_implicit_role_assignments.nil?

put_request("/v1/b2b/scim/#{organization_id}/connections/#{connection_id}", request, headers)
put_request("/v1/b2b/scim/#{organization_id}/connection/#{connection_id}", request, headers)
end

# Deletes a SCIM Connection. /%}
Expand All @@ -233,15 +233,15 @@ def update(
# The type of this field is +Integer+.
#
# == Method Options:
# This method supports an optional +StytchB2B::SCIM::Connections::DeleteRequestOptions+ object which will modify the headers sent in the HTTP request.
# This method supports an optional +StytchB2B::SCIM::Connection::DeleteRequestOptions+ object which will modify the headers sent in the HTTP request.
def delete(
organization_id:,
connection_id:,
method_options: nil
)
headers = {}
headers = headers.merge(method_options.to_headers) unless method_options.nil?
delete_request("/v1/b2b/scim/#{organization_id}/connections/#{connection_id}", headers)
delete_request("/v1/b2b/scim/#{organization_id}/connection/#{connection_id}", headers)
end

# Start a SCIM token rotation. /%}
Expand All @@ -267,7 +267,7 @@ def delete(
# The type of this field is nilable +SCIMConnectionWithNextToken+ (+object+).
#
# == Method Options:
# This method supports an optional +StytchB2B::SCIM::Connections::RotateStartRequestOptions+ object which will modify the headers sent in the HTTP request.
# This method supports an optional +StytchB2B::SCIM::Connection::RotateStartRequestOptions+ object which will modify the headers sent in the HTTP request.
def rotate_start(
organization_id:,
connection_id:,
Expand All @@ -277,7 +277,7 @@ def rotate_start(
headers = headers.merge(method_options.to_headers) unless method_options.nil?
request = {}

post_request("/v1/b2b/scim/#{organization_id}/connections/#{connection_id}/rotate/start", request, headers)
post_request("/v1/b2b/scim/#{organization_id}/connection/#{connection_id}/rotate/start", request, headers)
end

# Completes a SCIM token rotation. This will complete the current token rotation process and update the active token to be the new token supplied in the [start SCIM token rotation](https://stytch.com/docs/b2b/api/scim-rotate-token-start) response. /%}
Expand All @@ -303,7 +303,7 @@ def rotate_start(
# The type of this field is nilable +SCIMConnection+ (+object+).
#
# == Method Options:
# This method supports an optional +StytchB2B::SCIM::Connections::RotateCompleteRequestOptions+ object which will modify the headers sent in the HTTP request.
# This method supports an optional +StytchB2B::SCIM::Connection::RotateCompleteRequestOptions+ object which will modify the headers sent in the HTTP request.
def rotate_complete(
organization_id:,
connection_id:,
Expand All @@ -313,7 +313,7 @@ def rotate_complete(
headers = headers.merge(method_options.to_headers) unless method_options.nil?
request = {}

post_request("/v1/b2b/scim/#{organization_id}/connections/#{connection_id}/rotate/complete", request, headers)
post_request("/v1/b2b/scim/#{organization_id}/connection/#{connection_id}/rotate/complete", request, headers)
end

# Cancel a SCIM token rotation. This will cancel the current token rotation process, keeping the original token active. /%}
Expand All @@ -339,7 +339,7 @@ def rotate_complete(
# The type of this field is nilable +SCIMConnection+ (+object+).
#
# == Method Options:
# This method supports an optional +StytchB2B::SCIM::Connections::RotateCancelRequestOptions+ object which will modify the headers sent in the HTTP request.
# This method supports an optional +StytchB2B::SCIM::Connection::RotateCancelRequestOptions+ object which will modify the headers sent in the HTTP request.
def rotate_cancel(
organization_id:,
connection_id:,
Expand All @@ -349,7 +349,7 @@ def rotate_cancel(
headers = headers.merge(method_options.to_headers) unless method_options.nil?
request = {}

post_request("/v1/b2b/scim/#{organization_id}/connections/#{connection_id}/rotate/cancel", request, headers)
post_request("/v1/b2b/scim/#{organization_id}/connection/#{connection_id}/rotate/cancel", request, headers)
end

# Create a new SCIM Connection. /%}
Expand All @@ -363,7 +363,7 @@ def rotate_cancel(
# The type of this field is nilable +String+.
# identity_provider::
# (no documentation yet)
# The type of this field is nilable +CreateRequestIdp+ (string enum).
# The type of this field is nilable +CreateRequestIdentityProvider+ (string enum).
#
# == Returns:
# An object with the following fields:
Expand All @@ -378,7 +378,7 @@ def rotate_cancel(
# The type of this field is nilable +SCIMConnectionWithToken+ (+object+).
#
# == Method Options:
# This method supports an optional +StytchB2B::SCIM::Connections::CreateRequestOptions+ object which will modify the headers sent in the HTTP request.
# This method supports an optional +StytchB2B::SCIM::Connection::CreateRequestOptions+ object which will modify the headers sent in the HTTP request.
def create(
organization_id:,
display_name: nil,
Expand All @@ -391,7 +391,7 @@ def create(
request[:display_name] = display_name unless display_name.nil?
request[:identity_provider] = identity_provider unless identity_provider.nil?

post_request("/v1/b2b/scim/#{organization_id}/connections", request, headers)
post_request("/v1/b2b/scim/#{organization_id}/connection", request, headers)
end

# Get SCIM Connections. /%}
Expand All @@ -406,23 +406,23 @@ def create(
# 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+.
# connections::
# (no documentation yet)
# The type of this field is list of +SCIMConnection+ (+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+.
# connection::
# (no documentation yet)
# The type of this field is nilable +SCIMConnection+ (+object+).
#
# == Method Options:
# This method supports an optional +StytchB2B::SCIM::Connections::GetRequestOptions+ object which will modify the headers sent in the HTTP request.
# This method supports an optional +StytchB2B::SCIM::Connection::GetRequestOptions+ object which will modify the headers sent in the HTTP request.
def get(
organization_id:,
method_options: nil
)
headers = {}
headers = headers.merge(method_options.to_headers) unless method_options.nil?
query_params = {}
request = request_with_query_params("/v1/b2b/scim/#{organization_id}/connections", query_params)
request = request_with_query_params("/v1/b2b/scim/#{organization_id}/connection", query_params)
get_request(request, headers)
end
end
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 = '8.1.0'
VERSION = '9.0.0'
end

0 comments on commit 79d8f27

Please sign in to comment.