Skip to content
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
5 changes: 5 additions & 0 deletions app/services/proofing/aamva/applicant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ def self.from_proofer_applicant(applicant)
last_name: applicant[:last_name],
dob: format_dob(applicant[:dob]),
state_id_data: format_state_id_data(applicant),
address1: applicant[:address1],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there an address2?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an address2 though I am just throwing the first line in for now since getting the 2nd in is a little complicated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To elaborate on this, the way the docs say to add the address to the request is to include an additional AddressDeliveryPointText field for address line 2, but only if there is an address line 2 present.

This means adding a little bit of extra logic to this class to handle that. We probably should do that but I'm keeping it simple for now to verify everything is working then we can come back around and handle the second address line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pushed 0386575 which is a little messy but does get address line 2 in there

address2: applicant[:address2],
city: applicant[:city],
state: applicant[:state],
zipcode: applicant[:zipcode]&.slice(0..4),
)
end

Expand Down
6 changes: 6 additions & 0 deletions app/services/proofing/aamva/request/templates/verify.xml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<ns2:PersonGivenName></ns2:PersonGivenName>
<ns2:PersonSurName></ns2:PersonSurName>
</ns2:PersonName>
<ns1:Address>
<ns2:AddressDeliveryPointText></ns2:AddressDeliveryPointText>
<ns2:LocationCityName></ns2:LocationCityName>
<ns2:LocationStateUsPostalServiceCode></ns2:LocationStateUsPostalServiceCode>
<ns2:LocationPostalCode></ns2:LocationPostalCode>
</ns1:Address>
</ns:verifyDriverLicenseDataRequest>
</ns:VerifyDriverLicenseData>
</soap:Body>
Expand Down
31 changes: 31 additions & 0 deletions app/services/proofing/aamva/request/verification_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,36 @@ def add_user_provided_data_to_body
user_provided_data_map.each do |xpath, data|
REXML::XPath.first(document, xpath).add_text(data)
end
add_street_address_line_2_to_rexml_document(document) if applicant.address2.present?
@body = document.to_s
end

def add_street_address_line_2_to_rexml_document(document)
old_address_node = document.delete_element('//ns1:Address')
new_address_node = old_address_node.clone
old_address_node.children.each do |child_node|
next unless child_node.node_type == :element

new_element = child_node.clone
new_element.add_text(child_node.text)
new_address_node.add_element(new_element)

if child_node.name == 'AddressDeliveryPointText'
new_address_node.add_element(address_line_2_element)
end
end
REXML::XPath.first(
document,
'//ns:verifyDriverLicenseDataRequest',
).add_element(new_address_node)
end

def address_line_2_element
element = REXML::Element.new('ns2:AddressDeliveryPointText')
element.add_text(applicant.address2)
element
end

def build_request_body
renderer = ERB.new(request_body_template)
@body = renderer.result(binding)
Expand Down Expand Up @@ -106,6 +133,10 @@ def user_provided_data_map
'//ns2:PersonGivenName' => applicant.first_name,
'//ns2:PersonSurName' => applicant.last_name,
'//ns1:PersonBirthDate' => applicant.dob,
'//ns2:AddressDeliveryPointText' => applicant.address1,
'//ns2:LocationCityName' => applicant.city,
'//ns2:LocationStateUsPostalServiceCode' => applicant.state,
'//ns2:LocationPostalCode' => applicant.zipcode,
}
end

Expand Down
5 changes: 5 additions & 0 deletions app/services/proofing/aamva/response/verification_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ class VerificationResponse
'PersonBirthDateMatchIndicator' => :dob,
'PersonLastNameExactMatchIndicator' => :last_name,
'PersonFirstNameExactMatchIndicator' => :first_name,
'AddressLine1MatchIndicator' => :address1,
'AddressLine2MatchIndicator' => :address2,
'AddressCityMatchIndicator' => :city,
'AddressStateCodeMatchIndicator' => :state,
'AddressZIP5MatchIndicator' => :zipcode,
}.freeze

REQUIRED_VERIFICATION_ATTRIBUTES = %i[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<ns2:PersonGivenName>Testy</ns2:PersonGivenName>
<ns2:PersonSurName>McTesterson</ns2:PersonSurName>
</ns2:PersonName>
<ns1:Address>
<ns2:AddressDeliveryPointText>123 Sunnyside way</ns2:AddressDeliveryPointText>
<ns2:LocationCityName>Sterling</ns2:LocationCityName>
<ns2:LocationStateUsPostalServiceCode>VA</ns2:LocationStateUsPostalServiceCode>
<ns2:LocationPostalCode>20176</ns2:LocationPostalCode>
</ns1:Address>
</ns:verifyDriverLicenseDataRequest>
</ns:VerifyDriverLicenseData>
</soap:Body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@
<PersonFirstNameFuzzyPrimaryMatchIndicator>true</PersonFirstNameFuzzyPrimaryMatchIndicator>
<PersonFirstNameFuzzyAlternateMatchIndicator>true</PersonFirstNameFuzzyAlternateMatchIndicator>
<DocumentCategoryMatchIndicator>true</DocumentCategoryMatchIndicator>
<AddressLine1MatchIndicator>true</AddressLine1MatchIndicator>
<AddressCityMatchIndicator>true</AddressCityMatchIndicator>
<AddressStateCodeMatchIndicator>true</AddressStateCodeMatchIndicator>
<AddressZIP5MatchIndicator>true</AddressZIP5MatchIndicator>
</dldv:VerifyDriverLicenseDataResponse>
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
<PersonBirthDateMatchIndicator xmlns="http://aamva.org/niem/extensions/1.0">true</PersonBirthDateMatchIndicator>
<PersonLastNameExactMatchIndicator xmlns="http://aamva.org/niem/extensions/1.0">true</PersonLastNameExactMatchIndicator>
<PersonFirstNameExactMatchIndicator xmlns="http://aamva.org/niem/extensions/1.0">true</PersonFirstNameExactMatchIndicator>
<AddressLine1MatchIndicator xmlns="http://aamva.org/niem/extensions/1.0">true</AddressLine1MatchIndicator>
<AddressCityMatchIndicator xmlns="http://aamva.org/niem/extensions/1.0">true</AddressCityMatchIndicator>
<AddressStateCodeMatchIndicator xmlns="http://aamva.org/niem/extensions/1.0">true</AddressStateCodeMatchIndicator>
<AddressZIP5MatchIndicator xmlns="http://aamva.org/niem/extensions/1.0">true</AddressZIP5MatchIndicator>
</VerifyDriverLicenseDataResult>
</VerifyDriverLicenseDataResponse>
</s:Body>
</s:Envelope>

4 changes: 2 additions & 2 deletions spec/services/proofing/aamva/proofing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
subject.aamva_proof(state_id_data, result)

expect(result.failed?).to eq(true)
expect(result.errors).to eq(dob: ['UNVERIFIED'])
expect(result.errors).to include(dob: ['UNVERIFIED'])
end
end

Expand All @@ -82,7 +82,7 @@
subject.aamva_proof(state_id_data, result)

expect(result.failed?).to eq(true)
expect(result.errors).to eq(dob: ['MISSING'])
expect(result.errors).to include(dob: ['MISSING'])
end
end
end
Expand Down
33 changes: 33 additions & 0 deletions spec/services/proofing/aamva/request/verification_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
first_name: 'Testy',
last_name: 'McTesterson',
dob: '10/29/1942',
address1: '123 Sunnyside way',
city: 'Sterling',
state: 'VA',
zipcode: '20176-1234',
)
applicant.state_id_data.merge!(
state_id_number: '123456789',
Expand Down Expand Up @@ -39,6 +43,35 @@
expect(subject.body).to_not include('<foo></bar>')
expect(subject.body).to include('&lt;foo&gt;&lt;/bar&gt;')
end

it 'includes an address line 2 if one is present' do
applicant.address2 = 'Apt 1'

document = REXML::Document.new(subject.body)
address_node = REXML::XPath.first(document, '//ns:verifyDriverLicenseDataRequest/ns1:Address')

address_node_element_names = address_node.elements.map(&:name)
address_node_element_values = address_node.elements.map(&:text)

expect(address_node_element_names).to eq(
[
'AddressDeliveryPointText',
'AddressDeliveryPointText',
'LocationCityName',
'LocationStateUsPostalServiceCode',
'LocationPostalCode',
],
)
expect(address_node_element_values).to eq(
[
applicant.address1,
applicant.address2,
applicant.city,
applicant.state,
applicant.zipcode,
],
)
end
end

describe '#headers' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
dob: true,
last_name: true,
first_name: true,
address1: true,
address2: nil,
city: true,
state: true,
zipcode: true,
}
end

Expand Down