Class: StytchB2B::MagicLinks::Email
- Inherits:
-
Object
- Object
- StytchB2B::MagicLinks::Email
- Includes:
- Stytch::RequestHelper
- Defined in:
- lib/stytch/b2b_magic_links.rb
Defined Under Namespace
Classes: Discovery, InviteRequestOptions
Instance Attribute Summary collapse
-
#discovery ⇒ Object
readonly
Returns the value of attribute discovery.
Instance Method Summary collapse
-
#initialize(connection) ⇒ Email
constructor
A new instance of Email.
-
#invite(organization_id:, email_address:, invite_redirect_url: nil, invited_by_member_id: nil, name: nil, trusted_metadata: nil, untrusted_metadata: nil, invite_template_id: nil, locale: nil, roles: nil, method_options: nil) ⇒ Object
Send an invite email to a new to join an.
-
#login_or_signup(organization_id:, email_address:, login_redirect_url: nil, signup_redirect_url: nil, pkce_code_challenge: nil, login_template_id: nil, signup_template_id: nil, locale: nil) ⇒ Object
Send either a login or signup magic link to a Member.
Methods included from Stytch::RequestHelper
#delete_request, #get_request, #post_request, #put_request, #request_with_query_params
Constructor Details
Instance Attribute Details
#discovery ⇒ Object (readonly)
Returns the value of attribute discovery.
174 175 176 |
# File 'lib/stytch/b2b_magic_links.rb', line 174 def discovery @discovery end |
Instance Method Details
#invite(organization_id:, email_address:, invite_redirect_url: nil, invited_by_member_id: nil, name: nil, trusted_metadata: nil, untrusted_metadata: nil, invite_template_id: nil, locale: nil, roles: nil, method_options: nil) ⇒ Object
Send an invite email to a new to join an. 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
-
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
. - email_address
-
The email address of the Member. The type of this field is
String
. - invite_redirect_url
-
The URL that the Member clicks from the invite Email Magic Link. This URL should be an endpoint in the backend server that verifies the request by querying Stytch’s authenticate endpoint and finishes the invite flow. If this value is not passed, the default ‘invite_redirect_url` that you set in your Dashboard is used. If you have not set a default `invite_redirect_url`, an error is returned. The type of this field is nilable
String
. - invited_by_member_id
-
The ‘member_id` of the Member who sends the invite. The type of this field is nilable
String
. - name
-
The name of the Member. The type of this field is nilable
String
. - trusted_metadata
-
An arbitrary JSON object for storing application-specific data or identity-provider-specific data. The type of this field is nilable
object
. - untrusted_metadata
-
An arbitrary JSON object of application-specific data. These fields can be edited directly by the frontend SDK, and should not be used to store critical information. See the [Metadata resource](stytch.com/docs/b2b/api/metadata) for complete field behavior details. The type of this field is nilable
object
. - invite_template_id
-
Use a custom template for invite emails. By default, it will use your default email template. The template must be a template using our built-in customizations or a custom HTML email for Magic Links - Invite. The type of this field is nilable
String
. - locale
-
Used to determine which language to use when sending the user this delivery method. Parameter is a [IETF BCP 47 language tag](www.w3.org/International/articles/language-tags/), e.g. ‘“en”`.
Currently supported languages are English (‘“en”`), Spanish (`“es”`), and Brazilian Portuguese (`“pt-br”`); if no value is provided, the copy defaults to English.
Request support for additional languages [here](docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link“)!
The type of this field is nilable +InviteRequestLocale+ (string enum).
- roles
-
Roles to explicitly assign to this Member. See the [RBAC guide](stytch.com/docs/b2b/guides/rbac/role-assignment)
for more information about role assignment.
The type of this field is nilable list of
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
. - member
-
The [Member object](stytch.com/docs/b2b/api/member-object) The type of this field is
Member
(object
). - organization
-
The [Organization object](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::MagicLinks::Email::InviteRequestOptions
object which will modify the headers sent in the HTTP request.
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/stytch/b2b_magic_links.rb', line 335 def invite( organization_id:, email_address:, invite_redirect_url: nil, invited_by_member_id: nil, name: nil, trusted_metadata: nil, untrusted_metadata: nil, invite_template_id: nil, locale: nil, roles: nil, method_options: nil ) headers = {} headers = headers.merge(.to_headers) unless .nil? request = { organization_id: organization_id, email_address: email_address } request[:invite_redirect_url] = invite_redirect_url unless invite_redirect_url.nil? request[:invited_by_member_id] = invited_by_member_id unless invited_by_member_id.nil? request[:name] = name unless name.nil? request[:trusted_metadata] = unless .nil? request[:untrusted_metadata] = unless .nil? request[:invite_template_id] = invite_template_id unless invite_template_id.nil? request[:locale] = locale unless locale.nil? request[:roles] = roles unless roles.nil? post_request('/v1/b2b/magic_links/email/invite', request, headers) end |
#login_or_signup(organization_id:, email_address:, login_redirect_url: nil, signup_redirect_url: nil, pkce_code_challenge: nil, login_template_id: nil, signup_template_id: nil, locale: nil) ⇒ Object
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. The type of this field is
String
. - email_address
-
The email address of the Member. The type of this field is
String
. - login_redirect_url
-
The URL that the Member clicks from the login Email Magic Link. This URL should be an endpoint in the backend server that verifies the request by querying Stytch’s authenticate endpoint and finishes the login. If this value is not passed, the default login redirect URL that you set in your Dashboard is used. If you have not set a default login redirect URL, an error is returned. The type of this field is nilable
String
. - signup_redirect_url
-
The URL the Member clicks from the signup Email Magic Link. This URL should be an endpoint in the backend server that verifies the request by querying Stytch’s authenticate endpoint and finishes the login. If this value is not passed, the default sign-up redirect URL that you set in your Dashboard is used. If you have not set a default sign-up redirect URL, an error is returned. The type of this field is nilable
String
. - pkce_code_challenge
-
A base64url encoded SHA256 hash of a one time secret used to validate that the request starts and ends on the same device. The type of this field is nilable
String
. - login_template_id
-
Use a custom template for login emails. By default, it will use your default email template. The template must be from Stytch’s
built-in customizations or a custom HTML email for Magic Links - Login.
The type of this field is nilable +String+.
- signup_template_id
-
Use a custom template for signup emails. By default, it will use your default email template. The template must be from Stytch’s
built-in customizations or a custom HTML email for Magic Links - Signup.
The type of this field is nilable +String+.
- locale
-
Used to determine which language to use when sending the user this delivery method. Parameter is a [IETF BCP 47 language tag](www.w3.org/International/articles/language-tags/), e.g. ‘“en”`.
Currently supported languages are English (‘“en”`), Spanish (`“es”`), and Brazilian Portuguese (`“pt-br”`); if no value is provided, the copy defaults to English.
Request support for additional languages [here](docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link“)!
The type of this field is nilable +LoginOrSignupRequestLocale+ (string enum).
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
. - member_created
-
A flag indicating ‘true` if a new Member object was created and `false` if the Member object already existed. The type of this field is
Boolean
. - member
-
The [Member object](stytch.com/docs/b2b/api/member-object) The type of this field is
Member
(object
). - organization
-
The [Organization object](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
.
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/stytch/b2b_magic_links.rb', line 243 def login_or_signup( organization_id:, email_address:, login_redirect_url: nil, signup_redirect_url: nil, pkce_code_challenge: nil, login_template_id: nil, signup_template_id: nil, locale: nil ) headers = {} request = { organization_id: organization_id, email_address: email_address } request[:login_redirect_url] = login_redirect_url unless login_redirect_url.nil? request[:signup_redirect_url] = signup_redirect_url unless signup_redirect_url.nil? request[:pkce_code_challenge] = pkce_code_challenge unless pkce_code_challenge.nil? request[:login_template_id] = login_template_id unless login_template_id.nil? request[:signup_template_id] = signup_template_id unless signup_template_id.nil? request[:locale] = locale unless locale.nil? post_request('/v1/b2b/magic_links/email/login_or_signup', request, headers) end |