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
34 changes: 0 additions & 34 deletions app/services/proofing/aamva/result_with_exception.rb

This file was deleted.

41 changes: 41 additions & 0 deletions app/services/proofing/address_result.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module Proofing
class AddressResult
attr_reader :success, :errors, :exception, :vendor_name, :transaction_id, :reference

def initialize(
success:,
errors:,
exception:,
vendor_name:,
transaction_id: '',
reference: ''
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe easier to default reference to nil than empty string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was just trying to keep reference consistent with transaction_id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand the reasoning for making it nil vs empty string? I think all we do is log it and the result is the same in the end, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess nil to me is a more real "isn't there" vs some sort of default from empty string, but you're right, for most situations they're the same

)
@success = success
@errors = errors
@exception = exception
@vendor_name = vendor_name
@transaction_id = transaction_id
@reference = reference
end

def success?
success
end

def timed_out?
exception.is_a?(Proofing::TimeoutError)
end

def to_h
{
exception: exception,
errors: errors,
success: success?,
timed_out: timed_out?,
transaction_id: transaction_id,
reference: reference,
vendor_name: vendor_name,
}
end
end
end
30 changes: 28 additions & 2 deletions app/services/proofing/lexis_nexis/phone_finder/proofer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,36 @@ def initialize(config)

def proof(applicant)
response = VerificationRequest.new(config: config, applicant: applicant).send
return Proofing::LexisNexis::PhoneFinder::Result.new(response)
return build_result_from_response(response)
rescue => exception
NewRelic::Agent.notice_error(exception)
ResultWithException.new(exception, vendor_name: 'lexisnexis:phone_finder')
AddressResult.new(
success: false,
errors: {},
exception: exception,
vendor_name: 'lexisnexis:phone_finder',
)
end

private

def build_result_from_response(verification_response)
AddressResult.new(
success: verification_response.verification_status == 'passed',
errors: parse_verification_errors(verification_response),
exception: nil,
vendor_name: 'lexisnexis:phone_finder',
transaction_id: verification_response.conversation_id,
reference: verification_response.reference,
)
end

def parse_verification_errors(verification_response)
errors = Hash.new { |h, k| h[k] = [] }
Copy link
Contributor

Choose a reason for hiding this comment

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

i see you 😍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you learn something new every day

verification_response.verification_errors.each do |key, value|
errors[key] << value
end
errors
end
end
end
Expand Down
58 changes: 0 additions & 58 deletions app/services/proofing/lexis_nexis/phone_finder/result.rb

This file was deleted.

38 changes: 0 additions & 38 deletions app/services/proofing/lexis_nexis/result_with_exception.rb

This file was deleted.

39 changes: 14 additions & 25 deletions app/services/proofing/mock/address_mock_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,6 @@ class AddressMockClient
FAILED_TO_CONTACT_PHONE_NUMBER = '7035555999'
TRANSACTION_ID = 'address-mock-transaction-id-123'

AddressMockClientResult = Struct.new(:success, :errors, :exception, keyword_init: true) do
def success?
success
end

def transaction_id
TRANSACTION_ID
end

def to_h
{
exception: exception,
errors: errors,
success: success,
timed_out: exception.is_a?(Proofing::TimeoutError),
transaction_id: transaction_id,
vendor_name: 'AddressMock',
}
end
end

def proof(applicant)
plain_phone = applicant[:phone].gsub(/\D/, '').delete_prefix('1')
if plain_phone == UNVERIFIABLE_PHONE_NUMBER
Expand All @@ -36,35 +15,45 @@ def proof(applicant)
elsif plain_phone == PROOFER_TIMEOUT_PHONE_NUMBER
timeout_result
else
AddressMockClientResult.new(success: true, errors: {}, exception: nil)
address_result(success: true, errors: {}, exception: nil)
end
end

private

def unverifiable_phone_result
AddressMockClientResult.new(
address_result(
success: false,
errors: { phone: ['The phone number could not be verified.'] },
exception: nil,
)
end

def failed_to_contact_vendor_result
AddressMockClientResult.new(
address_result(
success: false,
errors: {},
exception: RuntimeError.new('Failed to contact proofing vendor'),
)
end

def timeout_result
AddressMockClientResult.new(
address_result(
success: false,
errors: {},
exception: Proofing::TimeoutError.new('address mock timeout'),
)
end

def address_result(success:, errors:, exception:)
AddressResult.new(
success: success,
errors: errors,
exception: exception,
transaction_id: TRANSACTION_ID,
vendor_name: 'AddressMock',
)
end
end
end
end
2 changes: 2 additions & 0 deletions spec/controllers/idv/phone_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@
exception: nil,
timed_out: false,
transaction_id: 'address-mock-transaction-id-123',
reference: '',
},
}

Expand Down Expand Up @@ -381,6 +382,7 @@
exception: nil,
timed_out: false,
transaction_id: 'address-mock-transaction-id-123',
reference: '',
},
}

Expand Down
4 changes: 2 additions & 2 deletions spec/features/idv/analytics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'IdV: doc auth optional verify_wait submitted' => { success: true, errors: {}, address_edited: false, proofing_results: { exception: nil, transaction_id: 'resolution-mock-transaction-id-123', reference: 'aaa-bbb-ccc', timed_out: false, context: { should_proof_state_id: true, stages: { resolution: { client: 'ResolutionMock', errors: {}, exception: nil, success: true, timed_out: false, transaction_id: 'resolution-mock-transaction-id-123', reference: 'aaa-bbb-ccc' }, state_id: { client: 'StateIdMock', errors: {}, success: true, timed_out: false, exception: nil, transaction_id: 'state-id-mock-transaction-id-456', state: 'MT', state_id_jurisdiction: 'ND' } } } }, ssn_is_unique: true, step: 'verify_wait_step_show' },
'IdV: phone of record visited' => {},
'IdV: phone confirmation form' => { success: true, errors: {}, phone_type: :mobile, types: [:fixed_or_mobile], carrier: 'Test Mobile Carrier', country_code: 'US', area_code: '202' },
'IdV: phone confirmation vendor' => { success: true, errors: {}, vendor: { exception: nil, vendor_name: 'AddressMock', transaction_id: 'address-mock-transaction-id-123', timed_out: false }, new_phone_added: false },
'IdV: phone confirmation vendor' => { success: true, errors: {}, vendor: { exception: nil, vendor_name: 'AddressMock', transaction_id: 'address-mock-transaction-id-123', timed_out: false, reference: '' }, new_phone_added: false },
'IdV: final resolution' => { success: true },
'IdV: personal key visited' => {},
'IdV: personal key submitted' => {},
Expand Down Expand Up @@ -101,7 +101,7 @@
'IdV: in person proofing optional verify_wait submitted' => { success: true, step: 'verify_wait_step_show', address_edited: false, ssn_is_unique: true },
'IdV: phone of record visited' => {},
'IdV: phone confirmation form' => { success: true, errors: {}, phone_type: :mobile, types: [:fixed_or_mobile], carrier: 'Test Mobile Carrier', country_code: 'US', area_code: '202' },
'IdV: phone confirmation vendor' => { success: true, errors: {}, vendor: { exception: nil, vendor_name: 'AddressMock', transaction_id: 'address-mock-transaction-id-123', timed_out: false }, new_phone_added: false },
'IdV: phone confirmation vendor' => { success: true, errors: {}, vendor: { exception: nil, vendor_name: 'AddressMock', transaction_id: 'address-mock-transaction-id-123', timed_out: false, reference: '' }, new_phone_added: false },
'IdV: Phone OTP delivery Selection Visited' => {},
'IdV: Phone OTP Delivery Selection Submitted' => { success: true, otp_delivery_preference: 'sms' },
'IdV: phone confirmation otp sent' => { success: true, otp_delivery_preference: :sms, country_code: 'US', area_code: '202' },
Expand Down
2 changes: 2 additions & 0 deletions spec/services/idv/phone_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
exception: nil,
timed_out: false,
transaction_id: 'address-mock-transaction-id-123',
reference: '',
},
}

Expand Down Expand Up @@ -92,6 +93,7 @@
exception: nil,
timed_out: false,
transaction_id: 'address-mock-transaction-id-123',
reference: '',
},
}

Expand Down
50 changes: 0 additions & 50 deletions spec/services/proofing/lexis_nexis/phone_finder/result_spec.rb

This file was deleted.

Loading