Class: VAProfile::V3::AddressValidation::AddressSuggestionsResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/va_profile/v3/address_validation/address_suggestions_response.rb

Overview

Wrapper for response from VA profile address validation API. Contains address suggestions and validation key used to ignore suggested addresses and use original address.

Instance Method Summary collapse

Constructor Details

#initialize(candidate_res) ⇒ AddressSuggestionsResponse

Returns a new instance of AddressSuggestionsResponse.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/va_profile/v3/address_validation/address_suggestions_response.rb', line 13

def initialize(candidate_res)
  validation_key = candidate_res['override_validation_key']
  @response = {
    addresses: candidate_res['candidate_addresses'].map do |address_suggestion_hash|
      {
        address: VAProfile::Models::V3::ValidationAddress.build_from_address_suggestion(
          address_suggestion_hash
        ).to_h.compact,
        address_meta_data: VAProfile::Models::V3::ValidationAddress.(
          address_suggestion_hash
        ).to_h
      }
    end,
    validation_key:
  }
end

Instance Method Details

#to_json(*_args) ⇒ Object



30
31
32
# File 'lib/va_profile/v3/address_validation/address_suggestions_response.rb', line 30

def to_json(*_args)
  @response.to_json
end