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

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ StartVerificationOptions

Returns a new instance of StartVerificationOptions.



14
15
16
17
18
# File 'lib/vonage/verify2/start_verification_options.rb', line 14

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



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

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



32
33
34
# File 'lib/vonage/verify2/start_verification_options.rb', line 32

def client_ref=(client_ref)
  @client_ref = client_ref
end

#code=(code) ⇒ Object



44
45
46
# File 'lib/vonage/verify2/start_verification_options.rb', line 44

def code=(code)
  @code = code
end

#code_length=(code_length) ⇒ Object



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

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)


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

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



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

def locale=(locale)
  @locale = locale
end

#to_hObject



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

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