Class: VerifIP::EmailResponse

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

Overview

Response from an email risk check.

Constant Summary collapse

FIELDS =
%i[
  request_id email risk_score valid_syntax mx_found is_disposable
  is_free_provider is_role_based domain_age_days domain
  signal_breakdown error
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ EmailResponse

Returns a new instance of EmailResponse.



128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/verifip/models.rb', line 128

def initialize(**kwargs)
  @request_id       = kwargs.fetch(:request_id, "")
  @email            = kwargs.fetch(:email, "")
  @risk_score       = kwargs.fetch(:risk_score, 0)
  @valid_syntax     = kwargs.fetch(:valid_syntax, false)
  @mx_found         = kwargs.fetch(:mx_found, false)
  @is_disposable    = kwargs.fetch(:is_disposable, false)
  @is_free_provider = kwargs.fetch(:is_free_provider, false)
  @is_role_based    = kwargs.fetch(:is_role_based, false)
  @domain_age_days  = kwargs.fetch(:domain_age_days, 0)
  @domain           = kwargs.fetch(:domain, "")
  @signal_breakdown = kwargs.fetch(:signal_breakdown, {})
  @error            = kwargs.fetch(:error, nil)
end

Class Method Details

.from_hash(hash) ⇒ Object



143
144
145
146
# File 'lib/verifip/models.rb', line 143

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

Instance Method Details

#inspectObject



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

def inspect = to_s

#to_hObject



148
149
150
# File 'lib/verifip/models.rb', line 148

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

#to_sObject



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

def to_s = "EmailResponse(email=#{@email}, risk_score=#{@risk_score})"