Class: VAProfile::AddressValidation::AddressSuggestionsResponse
- Inherits:
-
Object
- Object
- VAProfile::AddressValidation::AddressSuggestionsResponse
- Defined in:
- lib/va_profile/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
-
#initialize(candidate_res) ⇒ AddressSuggestionsResponse
constructor
A new instance of AddressSuggestionsResponse.
- #to_json(*_args) ⇒ Object
Constructor Details
#initialize(candidate_res) ⇒ AddressSuggestionsResponse
Returns a new instance of AddressSuggestionsResponse.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/va_profile/address_validation/address_suggestions_response.rb', line 12 def initialize(candidate_res) validation_key = candidate_res['candidate_addresses'][0]['address_meta_data']['validation_key'] @response = { addresses: candidate_res['candidate_addresses'].map do |address_suggestion_hash| { address: VAProfile::Models::ValidationAddress.build_from_address_suggestion( address_suggestion_hash ).to_h.compact, address_meta_data: address_suggestion_hash['address_meta_data'].except('validation_key') } end, validation_key: } end |
Instance Method Details
#to_json(*_args) ⇒ Object
28 29 30 |
# File 'lib/va_profile/address_validation/address_suggestions_response.rb', line 28 def to_json(*_args) @response.to_json end |