Skip to content

Commit

Permalink
Merge branch 'master' into API-42322-Extract-OrgWebServiceBean-from-l…
Browse files Browse the repository at this point in the history
…ocalBGS
  • Loading branch information
mchristiansonVA authored Dec 11, 2024
2 parents 3a1e4fb + a247207 commit 915a8d7
Show file tree
Hide file tree
Showing 21 changed files with 278 additions and 179 deletions.
2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ def va_profile_email
end

def vaprofile_contact_info
return nil unless VAProfile::Configuration::SETTINGS.contact_information.enabled && icn.present?

@vaprofile_contact_info ||= VAProfileRedis::V2::ContactInformation.for_user(self)
end

Expand Down
22 changes: 13 additions & 9 deletions app/models/va_profile_redis/v2/contact_information.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def self.for_user(user)
# @return [VAProfile::Models::Email] The user's one email address model
#
def email
return unless @user.loa3?
return unless verified_user?

value_for('emails')&.first
end
Expand All @@ -51,7 +51,7 @@ def email
# @return [VAProfile::Models::Address] The user's one residential address model
#
def residential_address
return unless @user.loa3?
return unless verified_user?

dig_out('addresses', 'address_pou', VAProfile::Models::V3::Address::RESIDENCE)
end
Expand All @@ -62,7 +62,7 @@ def residential_address
# @return [VAProfile::Models::Address] The user's one mailing address model
#
def mailing_address
return unless @user.loa3?
return unless verified_user?

dig_out('addresses', 'address_pou', VAProfile::Models::V3::Address::CORRESPONDENCE)
end
Expand All @@ -73,7 +73,7 @@ def mailing_address
# @return [VAProfile::Models::Telephone] The user's one home phone model
#
def home_phone
return unless @user.loa3?
return unless verified_user?

dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::HOME)
end
Expand All @@ -84,7 +84,7 @@ def home_phone
# @return [VAProfile::Models::Telephone] The user's one mobile phone model
#
def mobile_phone
return unless @user.loa3?
return unless verified_user?

dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::MOBILE)
end
Expand All @@ -95,7 +95,7 @@ def mobile_phone
# @return [VAProfile::Models::Telephone] The user's one work phone model
#
def work_phone
return unless @user.loa3?
return unless verified_user?

dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::WORK)
end
Expand All @@ -106,7 +106,7 @@ def work_phone
# @return [VAProfile::Models::Telephone] The user's one temporary phone model
#
def temporary_phone
return unless @user.loa3?
return unless verified_user?

dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::TEMPORARY)
end
Expand All @@ -117,7 +117,7 @@ def temporary_phone
# @return [VAProfile::Models::Telephone] The user's one fax number model
#
def fax_number
return unless @user.loa3?
return unless verified_user?

dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::FAX)
end
Expand All @@ -128,7 +128,7 @@ def fax_number
# @return [Integer <> String] the status of the last VAProfile::V2::ContactInformation::Service response
#
def status
return VAProfile::V2::ContactInformation::PersonResponse::RESPONSE_STATUS[:not_authorized] unless @user.loa3?
return VAProfile::V2::ContactInformation::PersonResponse::RESPONSE_STATUS[:not_authorized] unless verified_user?

response.status
end
Expand Down Expand Up @@ -179,6 +179,10 @@ def response_from_redis_or_service
def contact_info_service
@service ||= VAProfile::V2::ContactInformation::Service.new @user
end

def verified_user?
@user.icn.present?
end
end
end
end
8 changes: 8 additions & 0 deletions app/sidekiq/hca/ezr_submission_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,16 @@ def perform(encrypted_form, user_uuid)

Form1010Ezr::Service.new(user).submit_sync(parsed_form)
rescue VALIDATION_ERROR => e
StatsD.increment("#{STATSD_KEY_PREFIX}.enrollment_system_validation_error")

PersonalInformationLog.create!(
data: parsed_form,
error_class: 'Form1010Ezr EnrollmentSystemValidationFailure'
)

Form1010Ezr::Service.new(nil).log_submission_failure(parsed_form)
self.class.log_exception_to_sentry(e)
self.class.send_failure_email(parsed_form) if Flipper.enabled?(:ezr_use_va_notify_on_submission_failure)
rescue
StatsD.increment("#{STATSD_KEY_PREFIX}.async.retries")
raise
Expand Down
4 changes: 4 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ features:
actor_type: user
description: When enabled, sends poa forms to BD via the refactored logic
enable_in_development: true
claims_api_526_validations_v1_local_bgs:
actor_type: user
description: Enables the method calls in the v1 526 validations use local_bgs
enable_in_development: true
claims_api_use_person_web_service:
actor_type: user
description: Uses person web service rather than local bgs
Expand Down
5 changes: 0 additions & 5 deletions lib/form1010_ezr/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ def log_submission_failure(parsed_form)
StatsD.increment("#{Form1010Ezr::Service::STATSD_KEY_PREFIX}.failed")

if parsed_form.present?
PersonalInformationLog.create!(
data: parsed_form,
error_class: 'Form1010Ezr Failed'
)

log_message_to_sentry(
'1010EZR failure',
:error,
Expand Down
8 changes: 6 additions & 2 deletions lib/va_profile/models/v3/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ def in_json_v2
# @return [VAProfile::Models::V3::Address] the model built from the response body
# rubocop:disable Metrics/MethodLength
def self.build_from(body)
# Ensure address_pou is RESIDENCE OR CORRESPONDENCE. RESIDENCE/CHOICE is no longer valid.
address_pou = body['address_pou'].include?('RESIDENCE') ? 'RESIDENCE' : 'CORRESPONDENCE'

VAProfile::Models::V3::Address.new(
address_line1: body['address_line1'],
address_line2: body['address_line2'],
address_line3: body['address_line3'],
address_pou: body['address_pou'],
address_pou: address_pou,
address_type: body['address_type'].upcase,
bad_address: body['bad_address'],
city: body['city_name'],
Expand All @@ -95,7 +98,8 @@ def self.build_from(body)
longitude: body['longitude'],
province: body['province_name'],
source_date: body['source_date'],
state_code: body['state_code'],
state_code: body.dig('state', 'state_code'),
state_name: body.dig('state', 'state_name'),
transaction_id: body['tx_audit_id'],
updated_at: body['update_date'],
vet360_id: body['vet360_id'] || body['va_profile_id'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def initialize(candidate_res)
validation_key = candidate_res['override_validation_key']
@response = {
addresses: candidate_res['candidate_addresses'].map do |address_suggestion_hash|
Rails.logger.info("Address Suggestion Response: #{address_suggestion_hash}")
{
address: VAProfile::Models::V3::ValidationAddress.build_from_address_suggestion(
address_suggestion_hash
Expand Down
1 change: 0 additions & 1 deletion lib/va_profile/v3/address_validation/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def initialize; end
# @return [VAProfile::AddressValidation::AddressSuggestionsResponse] response wrapper around address
# suggestions data
def address_suggestions(address)
Rails.logger.info("Address Valid Service POU: #{address.address_pou}")
with_monitoring do
address.address_pou = address.address_pou == 'RESIDENCE/CHOICE' ? 'RESIDENCE' : address.address_pou
candidate_res = candidate(address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@ module PersonWebService
)
end

##
# StandardDataService
#
module StandardDataService
DEFINITION =
Bean.new(
path: 'StandardDataService',
namespaces: Namespaces.new(
target: 'http://services.mapd.benefits.vba.va.gov/',
data: nil
)
)
end

##
# StandardDataWebServiceBean
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'common/exceptions'
require 'brd/brd'
require 'bgs_service/standard_data_service'

module ClaimsApi
module DisabilityCompensationValidations # rubocop:disable Metrics/ModuleLength
Expand Down Expand Up @@ -424,7 +425,15 @@ def validate_form_526_disability_classification_code!
def bgs_classification_ids
return @bgs_classification_ids if @bgs_classification_ids.present?

contention_classification_type_codes = bgs_service.data.get_contention_classification_type_code_list
contention_classification_type_codes = if Flipper.enabled?(:claims_api_526_validations_v1_local_bgs)
contention_service = ClaimsApi::StandardDataService.new(
external_uid: Settings.bgs.external_uid,
external_key: Settings.bgs.external_key
)
contention_service.get_contention_classification_type_code_list
else
bgs_service.data.get_contention_classification_type_code_list
end
@bgs_classification_ids = contention_classification_type_codes.pluck(:clsfcn_id)
end

Expand Down
18 changes: 18 additions & 0 deletions modules/claims_api/lib/bgs_service/standard_data_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module ClaimsApi
class StandardDataService < ClaimsApi::LocalBGS
def bean_name
'StandardDataService/StandardDataService'
end

def get_contention_classification_type_code_list
body = Nokogiri::XML::DocumentFragment.parse <<~EOXML
<getContentionClassificationTypeCodeList/>
EOXML

response = make_request(endpoint: bean_name, action: 'getContentionClassificationTypeCodeList', body:)
response[:return]
end
end
end
Loading

0 comments on commit 915a8d7

Please sign in to comment.