Class: Nexmo::Verify

Inherits:
Namespace
  • Object
show all
Defined in:
lib/nexmo/verify.rb

Defined Under Namespace

Classes: Response

Instance Method Summary collapse

Instance Method Details

#cancel(id) ⇒ Response

Cancel an existing verification request.

Examples:

response = client.verify.cancel(request_id)

Parameters:

  • id (String)

Returns:

See Also:


158
159
160
# File 'lib/nexmo/verify.rb', line 158

def cancel(id)
  control(request_id: id, cmd: 'cancel')
end

#check(params) ⇒ Response

Confirm that the PIN you received from your user matches the one sent by Nexmo in your verification request.

Examples:

response = client.verify.check(request_id: request_id, code: '1234')

if response.success?
  puts "Verification complete, event_id=#{response.event_id}"
else
  puts "Error: #{response.error_text}"
end

Parameters:

  • params (Hash)

Options Hash (params):

  • :request_id (required, String)

    The Verify request to check. This is the `request_id` you received in the response to the Verify request.

  • :code (required, String)

    The verification code entered by your user.

  • :ip_address (String)

    The IP address used by your user when they entered the verification code. Nexmo uses this information to identify fraud and spam. This ultimately benefits all Nexmo customers.

Returns:

See Also:


99
100
101
# File 'lib/nexmo/verify.rb', line 99

def check(params)
  http_request('/verify/check/json', params: params, type: Post)
end

#control(params) ⇒ Response

Control the progress of your verification requests.

Examples:

response = client.verify.control(request_id: request_id, cmd: 'cancel')

Parameters:

  • params (Hash)

Options Hash (params):

  • :request_id (required, String)

    The `request_id` you received in the response to the Verify request.

  • :cmd (required, String)

    The command to execute, depending on whether you want to cancel the verification process, or advance to the next verification event. You must wait at least 30 seconds before cancelling a Verify request.

Returns:

See Also:


143
144
145
# File 'lib/nexmo/verify.rb', line 143

def control(params)
  http_request('/verify/control/json', params: params, type: Post)
end

#request(params) ⇒ Response

Note:

You can make a maximum of one Verify request per second.

Generate and send a PIN to your user.

Examples:

response = client.verify.request(number: '447700900000', brand: 'Acme Inc')

if response.success?
  puts "Started verification request_id=#{response.request_id}"
else
  puts "Error: #{response.error_text}"
end

Parameters:

  • params (Hash)

Options Hash (params):

  • :number (required, String)

    The mobile or landline phone number to verify. Unless you are setting :country explicitly, this number must be in E.164 format.

  • :country (String)

    If you do not provide :number in international format or you are not sure if :number is correctly formatted, specify the two-character country code in :country. Verify will then format the number for you.

  • :brand (required, String)

    An 18-character alphanumeric string you can use to personalize the verification request SMS body, to help users identify your company or application name. For example: “Your `Acme Inc` PIN is …”

  • :sender_id (String)

    An 11-character alphanumeric string that represents the [identity of the sender](developer.nexmo.com/messaging/sms/guides/custom-sender-id) of the verification request. Depending on the destination of the phone number you are sending the verification SMS to, restrictions might apply.

  • :code_length (Integer)

    The length of the verification code.

  • :lg (String)

    By default, the SMS or text-to-speech (TTS) message is generated in the locale that matches the :number. For example, the text message or TTS message for a `33*` number is sent in French. Use this parameter to explicitly control the language, accent and gender used for the Verify request.

  • :pin_expiry (Integer)

    How log the generated verification code is valid for, in seconds. When you specify both :pin_expiry and :next_event_wait then :pin_expiry must be an integer multiple of :next_event_wait otherwise :pin_expiry is defaulted to equal :next_event_wait. See [changing the event timings](developer.nexmo.com/verify/guides/changing-default-timings).

  • :next_event_wait (Integer)

    Specifies the wait time in seconds between attempts to deliver the verification code.

  • :workflow_id (Integer)

    Selects the predefined sequence of SMS and TTS (Text To Speech) actions to use in order to convey the PIN to your user. For example, an id of 1 identifies the workflow SMS - TTS - TTS. For a list of all workflows and their associated ids, please visit the [developer portal](developer.nexmo.com/verify/guides/workflows-and-events).

Returns:

See Also:


67
68
69
# File 'lib/nexmo/verify.rb', line 67

def request(params)
  http_request('/verify/json', params: params, type: Post)
end

#search(params) ⇒ Response

Check the status of past or current verification requests.

Examples:

response = client.verify.search(request_id: request_id)

Parameters:

  • params (Hash)

Options Hash (params):

  • :request_id (String)

    The `request_id` you received in the Verify Request Response.

  • :request_ids (Array<string>)

    More than one `request_id`. Each `request_id` is a new parameter in the Verify Search request.

Returns:

See Also:


121
122
123
# File 'lib/nexmo/verify.rb', line 121

def search(params)
  http_request('/verify/search/json', params: params)
end

#trigger_next_event(id) ⇒ Response

Trigger the next verification event for an existing verification request.

Examples:

response = client.verify.trigger_next_event(request_id)

Parameters:

  • id (String)

Returns:

See Also:


173
174
175
# File 'lib/nexmo/verify.rb', line 173

def trigger_next_event(id)
  control(request_id: id, cmd: 'trigger_next_event')
end