Class: VerifIP::PhoneResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/verifip/models.rb

Overview

Response from a phone number risk check.

Constant Summary collapse

FIELDS =
%i[
  request_id phone risk_score valid country_code carrier
  line_type is_voip signal_breakdown error
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ PhoneResponse

Returns a new instance of PhoneResponse.



170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/verifip/models.rb', line 170

def initialize(**kwargs)
  @request_id       = kwargs.fetch(:request_id, "")
  @phone            = kwargs.fetch(:phone, "")
  @risk_score       = kwargs.fetch(:risk_score, 0)
  @valid            = kwargs.fetch(:valid, false)
  @country_code     = kwargs.fetch(:country_code, "")
  @carrier          = kwargs.fetch(:carrier, "")
  @line_type        = kwargs.fetch(:line_type, "")
  @is_voip          = kwargs.fetch(:is_voip, false)
  @signal_breakdown = kwargs.fetch(:signal_breakdown, {})
  @error            = kwargs.fetch(:error, nil)
end

Class Method Details

.from_hash(hash) ⇒ Object



183
184
185
186
# File 'lib/verifip/models.rb', line 183

def self.from_hash(hash)
  hash = _symbolize(hash)
  new(**hash.slice(*FIELDS))
end

Instance Method Details

#inspectObject



195
# File 'lib/verifip/models.rb', line 195

def inspect = to_s

#to_hObject



190
191
192
# File 'lib/verifip/models.rb', line 190

def to_h
  FIELDS.each_with_object({}) { |f, h| h[f] = send(f) }
end

#to_sObject



194
# File 'lib/verifip/models.rb', line 194

def to_s = "PhoneResponse(phone=#{@phone}, risk_score=#{@risk_score})"

#voip?Boolean

Returns:

  • (Boolean)


188
# File 'lib/verifip/models.rb', line 188

def voip? = @is_voip