Class: VerifIP::URLResponse
- Inherits:
-
Object
- Object
- VerifIP::URLResponse
- Defined in:
- lib/verifip/models.rb
Overview
Response from a URL risk check.
Constant Summary collapse
- FIELDS =
%i[ request_id url risk_score is_phishing is_malware safe_browsing_threat in_phishtank spamhaus_dbl domain_age_days ssl_valid ssl_issuer signal_breakdown error ].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ URLResponse
constructor
A new instance of URLResponse.
- #inspect ⇒ Object
- #malware? ⇒ Boolean
- #phishing? ⇒ Boolean
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(**kwargs) ⇒ URLResponse
Returns a new instance of URLResponse.
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/verifip/models.rb', line 213 def initialize(**kwargs) @request_id = kwargs.fetch(:request_id, "") @url = kwargs.fetch(:url, "") @risk_score = kwargs.fetch(:risk_score, 0) @is_phishing = kwargs.fetch(:is_phishing, false) @is_malware = kwargs.fetch(:is_malware, false) @safe_browsing_threat = kwargs.fetch(:safe_browsing_threat, "") @in_phishtank = kwargs.fetch(:in_phishtank, false) @spamhaus_dbl = kwargs.fetch(:spamhaus_dbl, false) @domain_age_days = kwargs.fetch(:domain_age_days, 0) @ssl_valid = kwargs.fetch(:ssl_valid, false) @ssl_issuer = kwargs.fetch(:ssl_issuer, "") @signal_breakdown = kwargs.fetch(:signal_breakdown, {}) @error = kwargs.fetch(:error, nil) end |
Class Method Details
.from_hash(hash) ⇒ Object
229 230 231 232 |
# File 'lib/verifip/models.rb', line 229 def self.from_hash(hash) hash = _symbolize(hash) new(**hash.slice(*FIELDS)) end |
Instance Method Details
#inspect ⇒ Object
242 |
# File 'lib/verifip/models.rb', line 242 def inspect = to_s |
#malware? ⇒ Boolean
235 |
# File 'lib/verifip/models.rb', line 235 def malware? = @is_malware |
#phishing? ⇒ Boolean
234 |
# File 'lib/verifip/models.rb', line 234 def phishing? = @is_phishing |
#to_h ⇒ Object
237 238 239 |
# File 'lib/verifip/models.rb', line 237 def to_h FIELDS.each_with_object({}) { |f, h| h[f] = send(f) } end |
#to_s ⇒ Object
241 |
# File 'lib/verifip/models.rb', line 241 def to_s = "URLResponse(url=#{@url}, risk_score=#{@risk_score})" |