Skip to content

Commit

Permalink
Merge pull request #20 from horgh/horgh/email-domain-first-seen
Browse files Browse the repository at this point in the history
Add output /email/domain/first_seen
  • Loading branch information
kushniryb committed May 14, 2020
2 parents ca723c2 + 9f0b9d5 commit 9341199
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
/coverage
pkg
.project
Gemfile.lock
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,8 @@
# Minfraud Changelog

* Adds support for the new email domain output `/email/domain/first_seen`.
This may be accessed via `response.email.domain.first_seen` on the
minFraud Insights and Factors response objects.
* Rename ErrorHandler#inspect to ErrorHandler#examine in order not to break LSP.
* Adds classes for the Score, Insights, and Factors responses. This allows
us to provide API documentation for the various response attributes.
Expand Down
7 changes: 7 additions & 0 deletions lib/minfraud/model/email.rb
@@ -1,11 +1,17 @@
# frozen_string_literal: true

require 'minfraud/model/abstract'
require 'minfraud/model/email_domain'

module Minfraud
module Model
# Model containing information about the email address.
class Email < Abstract
# An object containing information about the email domain.
#
# @return [Minfraud::Model::EmailDomain]
attr_reader :domain

# A date string (e.g. 2017-04-24) to identify the date an email address
# was first seen by MaxMind. This is expressed using the ISO 8601 date
# format.
Expand Down Expand Up @@ -37,6 +43,7 @@ class Email < Abstract
def initialize(record)
super(record)

@domain = Minfraud::Model::EmailDomain.new(get('domain'))
@first_seen = get('first_seen')
@is_disposable = get('is_disposable')
@is_free = get('is_free')
Expand Down
24 changes: 24 additions & 0 deletions lib/minfraud/model/email_domain.rb
@@ -0,0 +1,24 @@
# frozen_string_literal: true

require 'minfraud/model/abstract'

module Minfraud
module Model
# Model containing information about the email domain.
class EmailDomain < Abstract
# A date string (e.g. 2017-04-24) to identify the date an email domain
# was first seen by MaxMind. This is expressed using the ISO 8601 date
# format.
#
# @return [String, nil]
attr_reader :first_seen

# @!visibility private
def initialize(record)
super(record)

@first_seen = get('first_seen')
end
end
end
end
2 changes: 1 addition & 1 deletion lib/minfraud/model/ip_address.rb
Expand Up @@ -76,7 +76,7 @@ def initialize(record, locales)
@traits.define_singleton_method(:is_satellite_provider) { get('is_satellite_provider') }
end

LANGUAGE_CODES = ['de', 'en', 'es', 'fr', 'ja', 'pt-BR', 'ru', 'zh-CN'].freeze
LANGUAGE_CODES = [:de, :en, :es, :fr, :ja, :'pt-BR', :ru, :'zh-CN'].freeze
end
end
end
3 changes: 3 additions & 0 deletions spec/fixtures/files/insights-response1.json
Expand Up @@ -156,6 +156,9 @@
"local_time": "2017-06-08T14:16:38Z"
},
"email": {
"domain": {
"first_seen": "2016-01-03"
},
"first_seen": "2017-01-02",
"is_disposable": true,
"is_free": true,
Expand Down
2 changes: 2 additions & 0 deletions spec/model/insights_spec.rb
Expand Up @@ -109,6 +109,7 @@
expect(m.device.last_seen).to eq '2016-06-08T14:16:38Z'
expect(m.device.local_time).to eq '2017-06-08T14:16:38Z'

expect(m.email.domain.first_seen).to eq '2016-01-03'
expect(m.email.first_seen).to eq '2017-01-02'
expect(m.email.is_disposable).to eq true
expect(m.email.is_free).to eq true
Expand Down Expand Up @@ -177,6 +178,7 @@
expect(m.device.confidence).to eq nil
expect(m.device.id).to eq '7835b099-d385-4e5b-969e-7df26181d73b'

expect(m.email.domain.first_seen).to eq nil
expect(m.email.first_seen).to eq nil
expect(m.email.is_disposable).to eq true

Expand Down

0 comments on commit 9341199

Please sign in to comment.