Class: Vonage::Verify2

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

Defined Under Namespace

Classes: StartVerificationOptions, TemplateFragments, Templates, 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:



68
69
70
# File 'lib/vonage/verify2.rb', line 68

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:



55
56
57
# File 'lib/vonage/verify2.rb', line 55

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

#next_workflow(request_id:) ⇒ Object



72
73
74
# File 'lib/vonage/verify2.rb', line 72

def next_workflow(request_id:)
  request('/v2/verify/' + request_id + '/next-workflow', 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

    • Must be between 1 and 16 characters in length

  • :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:



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

def start_verification(brand:, workflow:, **opts)
  raise ArgumentError, ':brand must be a String' unless brand.is_a?(String)
  raise ArgumentError, "Invalid 'brand' value #{brand}. Length must be between 1 and 16 characters." unless brand.length.between?(1, 16)
  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



86
87
88
# File 'lib/vonage/verify2.rb', line 86

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

#template_fragmentsTemplateFragments

Returns existing or instantiates a new Vonage::Verify2::Templates object

Returns:



108
109
110
# File 'lib/vonage/verify2.rb', line 108

def template_fragments
  @template_fragments ||= TemplateFragments.new(@config)
end

#templatesTemplates

Returns existing or instantiates a new Vonage::Verify2::Templates object

Returns:



102
103
104
# File 'lib/vonage/verify2.rb', line 102

def templates
  @templates ||= Templates.new(@config)
end

#workflowObject

Instantiate a new Vonage::Verify2::Workflow object



91
92
93
# File 'lib/vonage/verify2.rb', line 91

def workflow
  Workflow.new
end

#workflow_builderObject

Return the Vonage::Verify2::WorkflowBuilder class



96
97
98
# File 'lib/vonage/verify2.rb', line 96

def workflow_builder
  WorkflowBuilder.itself
end