Skip to content

Commit

Permalink
Fixed address validation (#19774)
Browse files Browse the repository at this point in the history
* test

* Attempting to fix CIV2 address bugs

* removed ssl false

* lint

* Updated address config in vcr cassettes
  • Loading branch information
RachalCassity authored Dec 9, 2024
1 parent 97a9462 commit 25c62e4
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 20 deletions.
14 changes: 7 additions & 7 deletions app/controllers/concerns/vet360/writeable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ module Writeable
# @return [Response] Normal controller `render json:` response with a response.body, .status, etc.
#
def write_to_vet360_and_render_transaction!(type, params, http_verb: 'post')
output_rails_logs = Flipper.enabled?(:va_v3_contact_information_service, @current_user)
record = build_record(type, params)
validate!(record)
response = write_valid_record!(http_verb, type, record)
Rails.logger.info('CI V2') if output_rails_logs
render_new_transaction!(type, response)
end

Expand All @@ -40,11 +38,13 @@ def invalidate_cache

def build_record(type, params)
# This needs to be refactored after V2 upgrade is complete
model = if type == 'address' && Flipper.enabled?(:va_v3_contact_information_service, @current_user)
'VAProfile::Models::V3::Address'
else
"VAProfile::Models::#{type.capitalize}"
end
if type == 'address' && Flipper.enabled?(:va_v3_contact_information_service, @current_user)
model = 'VAProfile::Models::V3::Address'
# Ensures the address_pou is valid
params[:address_pou] = 'RESIDENCE' if params[:address_pou] == 'RESIDENCE/CHOICE'
else
model = "VAProfile::Models::#{type.capitalize}"
end
model.constantize
.new(params)
.set_defaults(@current_user)
Expand Down
26 changes: 18 additions & 8 deletions lib/va_profile/models/v3/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,25 @@ def in_json_v2
addressPOU: @address_pou,
addressType: @address_type.titleize,
cityName: @city,
countryCodeISO2: @country_code_iso2,
countryCodeISO3: @country_code_iso3,
countryName: @country_name,
country: {
countryName: @country_name,
countryCodeFIPS: @country_code_fips,
countryCodeISO2: @country_code_iso2,
countryCodeISO3: @country_code_iso3
},
county: {
countyCode: @county_code,
countyName: @county_name
},
province: {
provinceName: @province,
provinceCode: @province_code
},
state: {
stateName: @state_name,
stateCode: @state_code
},
intPostalCode: @international_postal_code,
provinceName: @province,
stateCode: @state_code,
zipCode5: @zip_code,
zipCode4: @zip_code_suffix,
originatingSourceSystem: SOURCE_SYSTEM,
Expand Down Expand Up @@ -69,9 +78,10 @@ def self.build_from(body)
address_type: body['address_type'].upcase,
bad_address: body['bad_address'],
city: body['city_name'],
country_name: body['country_name'],
country_code_iso2: body['country_code_iso2'],
country_code_iso3: body['country_code_iso3'],
country_name: body.dig('country', 'country_name'),
country_code_iso2: body.dig('country', 'iso_2_code'),
country_code_iso3: body.dig('country', 'country_code_iso3'),
fipsCode: body.dig('country', 'fips_code'),
county_code: body.dig('county', 'county_code'),
county_name: body.dig('county', 'county_name'),
created_at: body['create_date'],
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 25c62e4

Please sign in to comment.