class Stytch::OTPs::Whatsapp

def initialize(connection)

def initialize(connection)
  @connection = connection
end

def login_or_create(

The type of this field is +Integer+.
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.
status_code::
The type of this field is +Boolean+.
In `login_or_create` endpoints, this field indicates whether or not a User was just created.
user_created::
The type of this field is +String+.
The unique ID for the phone number.
phone_id::
The type of this field is +String+.
The unique ID of the affected User.
user_id::
The type of this field is +String+.
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.
request_id::
An object with the following fields:
== Returns:

The type of this field is nilable +LoginOrCreateRequestLocale+ (string enum).

Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!

Currently supported languages are English (`"en"`), Spanish (`"es"`), French (`"fr"`) and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.

Used to determine which language to use when sending the user this delivery method. Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
locale::
The type of this field is nilable +Boolean+.
an account for them.
a true flag would be to require users to verify their phone by entering the OTP code before creating
If false, users will be created as active. An example usage of
If true, users will be saved with status pending in Stytch's backend until authenticated.
Flag for whether or not to save a user as pending vs active in Stytch. Defaults to false.
create_user_as_pending::
The type of this field is nilable +Attributes+ (+object+).
Provided attributes help with fraud detection.
attributes::
The type of this field is nilable +Integer+.
Set the expiration for the one-time passcode, in minutes. The minimum expiration is 1 minute and the maximum is 10 minutes. The default expiration is 2 minutes.
expiration_minutes::
The type of this field is +String+.
The phone number to use for one-time passcodes. The phone number should be in E.164 format (i.e. +1XXXXXXXXXX). You may use +10000000000 to test this endpoint, see [Testing](https://stytch.com/docs/home#resources_testing) for more detail.
phone_number::
== Parameters:

Collect the OTP which was delivered to the User. Call [Authenticate OTP](https://stytch.com/docs/api/authenticate-otp) using the OTP `code` along with the `phone_id` found in the response as the `method_id`.

### Next steps

Before configuring SMS or WhatsApp OTPs, please review how Stytch [bills the costs of international OTPs](https://stytch.com/pricing) and understand how to protect your app against [toll fraud](https://stytch.com/docs/guides/passcodes/toll-fraud/overview).
### Cost to send SMS OTP

Send a one-time passcode (OTP) to a User's WhatsApp using their phone number. If the phone number is not associated with a User already, a User will be created.
def login_or_create(
  phone_number:,
  expiration_minutes: nil,
  attributes: nil,
  create_user_as_pending: nil,
  locale: nil
)
  headers = {}
  request = {
    phone_number: phone_number
  }
  request[:expiration_minutes] = expiration_minutes unless expiration_minutes.nil?
  request[:attributes] = attributes unless attributes.nil?
  request[:create_user_as_pending] = create_user_as_pending unless create_user_as_pending.nil?
  request[:locale] = locale unless locale.nil?
  post_request('/v1/otps/whatsapp/login_or_create', request, headers)
end

def send(

The type of this field is +Integer+.
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.
status_code::
The type of this field is +String+.
The unique ID for the phone number.
phone_id::
The type of this field is +String+.
The unique ID of the affected User.
user_id::
The type of this field is +String+.
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.
request_id::
An object with the following fields:
== Returns:

The type of this field is nilable +String+.
The `session_jwt` associated with a User's existing Session.
session_jwt::
The type of this field is nilable +String+.
The `session_token` associated with a User's existing Session.
session_token::
The type of this field is nilable +String+.
The unique ID of a specific User. You may use an external_id here if one is set for the user.
user_id::
The type of this field is nilable +SendRequestLocale+ (string enum).

Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!

Currently supported languages are English (`"en"`), Spanish (`"es"`), French (`"fr"`) and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.

Used to determine which language to use when sending the user this delivery method. Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
locale::
The type of this field is nilable +Attributes+ (+object+).
Provided attributes help with fraud detection.
attributes::
The type of this field is nilable +Integer+.
Set the expiration for the one-time passcode, in minutes. The minimum expiration is 1 minute and the maximum is 10 minutes. The default expiration is 2 minutes.
expiration_minutes::
The type of this field is +String+.
The phone number to use for one-time passcodes. The phone number should be in E.164 format (i.e. +1XXXXXXXXXX). You may use +10000000000 to test this endpoint, see [Testing](https://stytch.com/docs/home#resources_testing) for more detail.
phone_number::
== Parameters:

Collect the OTP which was delivered to the user. Call [Authenticate OTP](https://stytch.com/docs/api/authenticate-otp) using the OTP `code` along with the `phone_id` found in the response as the `method_id`.

### Next steps

This endpoint also allows you to add a new phone number to an existing Stytch User. Including a `user_id`, `session_token`, or `session_jwt` in your Send one-time passcode by WhatsApp request will add the new, unverified phone number to the existing Stytch User. If the user successfully authenticates within 5 minutes, the new phone number will be marked as verified and remain permanently on the existing Stytch User. Otherwise, it will be removed from the User object, and any subsequent login requests using that phone number will create a new User.

### Add a phone number to an existing user

Before configuring SMS or WhatsApp OTPs, please review how Stytch [bills the costs of international OTPs](https://stytch.com/pricing) and understand how to protect your app against [toll fraud](https://stytch.com/docs/guides/passcodes/toll-fraud/overview).
### Cost to send SMS OTP

Note that sending another OTP code before the first has expired will invalidate the first code.

Send a One-Time Passcode (OTP) to a User's WhatsApp. If you'd like to create a user and send them a passcode with one request, use our [log in or create](https://stytch.com/docs/api/whatsapp-login-or-create) endpoint.
def send(
  phone_number:,
  expiration_minutes: nil,
  attributes: nil,
  locale: nil,
  user_id: nil,
  session_token: nil,
  session_jwt: nil
)
  headers = {}
  request = {
    phone_number: phone_number
  }
  request[:expiration_minutes] = expiration_minutes unless expiration_minutes.nil?
  request[:attributes] = attributes unless attributes.nil?
  request[:locale] = locale unless locale.nil?
  request[:user_id] = user_id unless user_id.nil?
  request[:session_token] = session_token unless session_token.nil?
  request[:session_jwt] = session_jwt unless session_jwt.nil?
  post_request('/v1/otps/whatsapp/send', request, headers)
end