Class: Vonage::Verify2

Inherits:
Namespace
  • Object
show all
Defined in:
lib/vonage/verify2.rb

Defined Under Namespace

Classes: StartVerificationOptions, Workflow, WorkflowBuilder

Instance Method Summary collapse

Instance Method Details

#cancel_verification_request(request_id:) ⇒ Object

Cancel a verifiction. If a verification request is still active, calling this method aborts the workflow.

Examples:

client.verify2.cancel_verification_request(request_id: '7e8c5965-0a3f-44df-8a14-f1486209d8a2')

Parameters:

  • :request_id (required, String)

    The request_id of the verification request to be cancelled

See Also:



65
66
67
# File 'lib/vonage/verify2.rb', line 65

def cancel_verification_request(request_id:)
  request('/v2/verify/' + request_id, type: Delete)
end

#check_code(request_id:, code:) ⇒ Object

Check a supplied code against a request to see if it is valid.

Examples:

code_check = client.verify2.check_code(request_id: '7e8c5965-0a3f-44df-8a14-f1486209d8a2', code: '1234')

Parameters:

  • :request_id (required, String)

    The request_id of the verification request being checked

  • :code (required, String)

    The code supplied to the end-user by the verification request

See Also:



52
53
54
# File 'lib/vonage/verify2.rb', line 52

def check_code(request_id:, code:)
  request('/v2/verify/' + request_id, params: {code: code}, type: Post)
end

#start_verification(brand:, workflow:, **opts) ⇒ Object

Request a verification be sent to a user.

Examples:

verification_request = client.verify2.start_verification(
  brand: 'Acme',
  workflow: [{channel: 'sms', to: '447000000000'}],
  code_length: 6
)

Parameters:

  • :brand (required, String)

    The brand that is sending the verification request

  • :workflow (required, Array<Hash>)

    An array of hashes for channels in the workflow

  • opts (optional, Hash)

    the options for the verification request. @option opts [Integer] :code_length The length of the one-time code provided to the end-user @option opts [String] :code An optional alphanumeric custom code to use instead of an auto-generated code @option opts [String] :locale The language to use for the verification message (where applicable) @option opts [Integer] :channel_timeout Wait time in seconds before trying the next channel in the workflow @option opts [String] :client_ref Reference to be included in callbacks @option opts [Boolean] If used, must be set to false. Will bypass a network block for a single Verify V2 request

Returns:

  • Vonage::Response

Raises:

  • (ArgumentError)

See Also:



34
35
36
37
38
39
# File 'lib/vonage/verify2.rb', line 34

def start_verification(brand:, workflow:, **opts)
  raise ArgumentError, ':workflow must be an Array' unless workflow.is_a?(Array)
  raise ArgumentError, ':workflow must not be empty' if workflow.empty?

  request('/v2/verify/', params: opts.merge(brand: brand, workflow: workflow), type: Post)
end

#start_verification_options(**opts) ⇒ Object

Instantiate a new Vonage::Verify2::StartVerificationOptions object

Parameters:

  • opts (optional, Hash)

    the options for the verification request. @option opts [Integer] :code_length The length of the one-time code provided to the end-user @option opts [String] :code An optional alphanumeric custom code to use instead of an auto-generated code @option opts [String] :locale The language to use for the verification message (where applicable) @option opts [Integer] :channel_timeout Wait time in seconds before trying the next channel in the workflow @option opts [String] :client_ref Reference to be included in callbacks @option opts [Boolean] If used, must be set to false. Will bypass a network block for a single Verify V2 request



79
80
81
# File 'lib/vonage/verify2.rb', line 79

def start_verification_options(**opts)
  StartVerificationOptions.new(**opts)
end

#workflowObject

Instantiate a new Vonage::Verify2::Workflow object



84
85
86
# File 'lib/vonage/verify2.rb', line 84

def workflow
  Workflow.new
end

#workflow_builderObject

Return the Vonage::Verify2::WorkflowBuilder class



89
90
91
# File 'lib/vonage/verify2.rb', line 89

def workflow_builder
  WorkflowBuilder.itself
end