Class: Vonage::Verify2::StartVerificationOptions

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

Constant Summary collapse

VALID_OPTS =
[:locale, :channel_timeout, :client_ref, :code_length, :code, :fraud_check].freeze
VALID_LOCALES =
[
  'en-us', 'en-gb', 'es-es', 'es-mx', 'es-us', 'it-it', 'fr-fr',
  'de-de', 'ru-ru', 'hi-in', 'pt-br', 'pt-pt', 'id-id'
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ StartVerificationOptions

Returns a new instance of StartVerificationOptions.



19
20
21
22
23
# File 'lib/vonage/verify2/start_verification_options.rb', line 19

def initialize(**opts)
  VALID_OPTS.each do |opt|
    send("#{opt}=", opts[opt]) unless opts[opt].nil?
  end
end

Instance Method Details

#channel_timeout=(channel_timeout) ⇒ Object



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

def channel_timeout=(channel_timeout)
  unless channel_timeout.between?(MIN_CHANNEL_TIMEOUT, MAX_CHANNEL_TIMEOUT)
    raise ArgumentError, "Invalid 'channel_timeout' #{channel_timeout}. Must be between #{MIN_CHANNEL_TIMEOUT} and #{MAX_CHANNEL_TIMEOUT} (inclusive)"
  end

  @channel_timeout = channel_timeout
end

#client_ref=(client_ref) ⇒ Object



41
42
43
# File 'lib/vonage/verify2/start_verification_options.rb', line 41

def client_ref=(client_ref)
  @client_ref = client_ref
end

#code=(code) ⇒ Object



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

def code=(code)
  @code = code
end

#code_length=(code_length) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/vonage/verify2/start_verification_options.rb', line 45

def code_length=(code_length)
  unless code_length.between?(MIN_CODE_LENGTH, MAX_CODE_LENGTH)
    raise ArgumentError, "Invalid 'code_length' #{code_length}. Must be between #{MIN_CODE_LENGTH} and #{MAX_CODE_LENGTH} (inclusive)"
  end

  @code_length = code_length
end

#fraud_check=(fraud_check) ⇒ Object

Raises:

  • (ArgumentError)


57
58
59
60
61
# File 'lib/vonage/verify2/start_verification_options.rb', line 57

def fraud_check=(fraud_check)
  raise ArgumentError, "Invalid 'fraud_check' #{fraud_check}. Must be `false`" unless fraud_check == false

  @fraud_check = fraud_check
end

#locale=(locale) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/vonage/verify2/start_verification_options.rb', line 25

def locale=(locale)
  unless VALID_LOCALES.include?(locale)
    raise ArgumentError, "Invalid 'locale' #{locale}. Please choose from the following #{VALID_LOCALES}"
  end

  @locale = locale
end

#to_hObject



63
64
65
66
67
68
69
# File 'lib/vonage/verify2/start_verification_options.rb', line 63

def to_h
  hash = Hash.new
  self.instance_variables.each do |ivar|
    hash[ivar.to_s.delete("@").to_sym] = self.instance_variable_get(ivar)
  end
  hash
end