diff --git a/app/services/proofing/lexis_nexis/verification_error_parser.rb b/app/services/proofing/lexis_nexis/verification_error_parser.rb index 25e40c09827..89d198bbdd1 100644 --- a/app/services/proofing/lexis_nexis/verification_error_parser.rb +++ b/app/services/proofing/lexis_nexis/verification_error_parser.rb @@ -47,7 +47,7 @@ def parse_product_error_messages return {} if products.nil? products.each_with_object({}) do |product, error_messages| - next if product['ProductStatus'] == 'pass' + next unless should_log?(product) # don't log PhoneFinder reflected PII product.delete('ParameterDetails') if product['ProductType'] == 'PhoneFinder' @@ -56,6 +56,13 @@ def parse_product_error_messages error_messages[key] = product end end + + def should_log?(product) + return true if product['ProductStatus'] != 'pass' + return true if product['ProductType'] == 'InstantVerify' + return true if product['Items']&.flat_map(&:keys)&.include?('ItemReason') + return false + end end end end diff --git a/spec/services/proofing/lexis_nexis/verification_error_parser_spec.rb b/spec/services/proofing/lexis_nexis/verification_error_parser_spec.rb index 05b2b29b413..063e40b0941 100644 --- a/spec/services/proofing/lexis_nexis/verification_error_parser_spec.rb +++ b/spec/services/proofing/lexis_nexis/verification_error_parser_spec.rb @@ -20,6 +20,29 @@ expect(errors[:Discovery]).to eq(nil) # This should be absent since it passed expect(errors[:SomeOtherProduct]).to eq(response_body['Products'][1]) expect(errors[:InstantVerify]).to eq(response_body['Products'][2]) + expect(errors[:'Execute Instant Verify']).to be_a Hash # log product error + end + + it 'should not log a passing response containing no important information' do + response_body['Products'].first['ProductType'] = 'Fake Product' + response_body['Products'].first['ProductStatus'] = 'pass' + response_body['Products'].first['Items'].map { |i| i.delete('ItemReason') } + + expect(errors[:'Execute Instant Verify']).to eq(nil) + end + + it 'should log any Instant Verify response, including a pass' do + response_body['Products'].first['ProductStatus'] = 'pass' + response_body['Products'].first['Items'].map { |i| i.delete('ItemReason') } + + expect(errors[:'Execute Instant Verify']).to be_a Hash + end + + it 'should log any response with an ItemReason, including a pass' do + response_body['Products'].first['ProductType'] = 'Fake Product' + response_body['Products'].first['ProductStatus'] = 'pass' + + expect(errors[:'Execute Instant Verify']).to be_a Hash end end end