Skip to content
This repository was archived by the owner on Jun 12, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/lexisnexis/date_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ def formatted_date
}
end

def formatted_year_only
{
Year: date.year.to_s,
}
end

def yyyymmdd
date.strftime('%Y%m%d')
end
Expand Down
2 changes: 1 addition & 1 deletion lib/lexisnexis/instant_verify/proofer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Proofer < LexisNexis::Proofer
:state,
:zipcode

optional_attributes :address2, :uuid_prefix
optional_attributes :address2, :uuid_prefix, :dob_year_only

stage :resolution

Expand Down
11 changes: 10 additions & 1 deletion lib/lexisnexis/instant_verify/verification_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def build_request_body # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
Number: attributes[:ssn].gsub(/\D/, ''),
Type: 'ssn9',
},
DateOfBirth: DateFormatter.new(attributes[:dob]).formatted_date,
DateOfBirth: date_of_birth,
Addresses: [formatted_address],
},
}.to_json
Expand All @@ -46,6 +46,15 @@ def formatted_address
Context: 'primary',
}
end

def date_of_birth
formatter = DateFormatter.new(attributes[:dob])
if attributes[:dob_year_only]
formatter.formatted_year_only
else
formatter.formatted_date
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/lexisnexis/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module LexisNexis
VERSION = '2.4.2'.freeze
VERSION = '2.5.0'.freeze
end
8 changes: 8 additions & 0 deletions spec/lib/date_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
end
end

describe '#formatted_year_only' do
let(:date_string) { '04/15/2020' }

it 'is a hash' do
expect(date_formatter.formatted_year_only).to eq(Year: '2020')
end
end

describe '#yyyymmdd' do
let(:date_string) { '01/31/2020' }

Expand Down
14 changes: 14 additions & 0 deletions spec/lib/instant_verify/proofer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,23 @@
}
end
let(:verification_request) { LexisNexis::InstantVerify::VerificationRequest.new(applicant) }
subject(:proofer) { described_class.new }

it_behaves_like 'a proofer'

describe 'proofing birth year only' do
let(:applicant) { super().merge(dob_year_only: true) }

it 'does not send day or month in the birthday field' do
stub_request(:post, verification_request.url).with do |request|
body = JSON.parse(request.body, symbolize_names: true)
expect(body.dig(:Person, :DateOfBirth)).to eq(Year: "1980")
end.to_return(body: Fixtures.instant_verify_success_response_json, status: 200)

subject.proof(applicant)
end
end

describe '#send' do
context 'when the request times out' do
it 'raises a timeout error' do
Expand Down
11 changes: 11 additions & 0 deletions spec/lib/instant_verify/verification_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@
expect(parsed_body[:Settings][:Reference]).to eq(attributes[:uuid])
end
end

context 'when dob_year_only is true' do
let(:attributes) do
super().merge(dob_year_only: true)
end

it 'does not send the birth month or day' do
date_of_birth = JSON.parse(subject.body, symbolize_names: true).dig(:Person, :DateOfBirth)
expect(date_of_birth).to_not include(:Month, :Day)
end
end
end

describe '#url' do
Expand Down