Class: VAProfile::Models::V3::Address

Inherits:
BaseAddress show all
Defined in:
lib/va_profile/models/v3/address.rb

Constant Summary

Constants inherited from BaseAddress

BaseAddress::ADDRESS_FIELD_LIMIT, BaseAddress::ADDRESS_POUS, BaseAddress::ADDRESS_TYPES, BaseAddress::CORRESPONDENCE, BaseAddress::DOMESTIC, BaseAddress::INTERNATIONAL, BaseAddress::MILITARY, BaseAddress::RESIDENCE, BaseAddress::VALID_ALPHA_REGEX, BaseAddress::VALID_NUMERIC_REGEX

Constants inherited from Base

Base::SOURCE_SYSTEM

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseAddress

#ascii_only, #zip_plus_four

Methods included from Concerns::Expirable

#effective_end_date_has_passed

Methods included from Concerns::Defaultable

#set_defaults

Class Method Details

.build_from(body) ⇒ VAProfile::Models::V3::Address

Converts a decoded JSON response from VAProfile to an instance of the Address model rubocop:disable Metrics/MethodLength

Parameters:

  • body (Hash)

    the decoded response body from VAProfile

Returns:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/va_profile/models/v3/address.rb', line 63

def self.build_from(body)
  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_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'],
    county_code: body.dig('county', 'county_code'),
    county_name: body.dig('county', 'county_name'),
    created_at: body['create_date'],
    effective_end_date: body['effective_end_date'],
    effective_start_date: body['effective_start_date'],
    geocode_date: body['geocode_date'],
    geocode_precision: body['geocode_precision'],
    id: body['address_id'],
    international_postal_code: body['int_postal_code'],
    latitude: body['latitude'],
    longitude: body['longitude'],
    province: body['province_name'],
    source_date: body['source_date'],
    state_code: body['state_code'],
    transaction_id: body['tx_audit_id'],
    updated_at: body['update_date'],
    vet360_id: body['vet360_id'] || body['va_profile_id'],
    va_profile_id: body['va_profile_id'] || body['vet360_id'],
    zip_code: body['zip_code5'],
    zip_code_suffix: body['zip_code4']
  )
end

Instance Method Details

#correspondence?Boolean

rubocop:enable Metrics/MethodLength

Returns:

  • (Boolean)


99
100
101
# File 'lib/va_profile/models/v3/address.rb', line 99

def correspondence?
  @address_pou == VAProfile::Models::V3::Address::CORRESPONDENCE
end

#in_json_v2VAProfile::Models::V3::Address

Converts a decoded JSON response from VAProfile to an instance of the Address model rubocop:disable Metrics/MethodLength in_json_v2 will replace in_json when Contact Information V1 Service has depreciated

Parameters:

  • body (Hash)

    the decoded response body from VAProfile

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/va_profile/models/v3/address.rb', line 18

def in_json_v2
  address_attributes = {
    addressId: @id,
    addressLine1: @address_line1,
    addressLine2: @address_line2,
    addressLine3: @address_line3,
    addressPOU: @address_pou,
    addressType: @address_type.titleize,
    cityName: @city,
    countryCodeISO2: @country_code_iso2,
    countryCodeISO3: @country_code_iso3,
    countryName: @country_name,
    county: {
      countyCode: @county_code,
      countyName: @county_name
    },
    intPostalCode: @international_postal_code,
    provinceName: @province,
    stateCode: @state_code,
    zipCode5: @zip_code,
    zipCode4: @zip_code_suffix,
    originatingSourceSystem: SOURCE_SYSTEM,
    sourceSystemUser: @source_system_user,
    sourceDate: @source_date,
    effectiveStartDate: @effective_start_date,
    effectiveEndDate: @effective_end_date
  }

  if @validation_key.present?
    address_attributes[:validationKey] = @validation_key
    address_attributes[:overrideIndicator] = true
  end

  address_attributes[:badAddress] = false if correspondence?

  {
    bio: address_attributes
  }.to_json
end