Class: VAProfile::AddressValidation::Service

Inherits:
Service show all
Defined in:
lib/va_profile/address_validation/service.rb

Overview

Wrapper for the VA profile address validation/suggestions API

Constant Summary

Constants inherited from Service

Service::STATSD_KEY_PREFIX

Instance Method Summary collapse

Methods inherited from Service

breakers_service, #perform

Methods inherited from Common::Client::Base

configuration, #raise_backend_exception

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Constructor Details

#initializeService

Returns a new instance of Service.



14
# File 'lib/va_profile/address_validation/service.rb', line 14

def initialize; end

Instance Method Details

#address_suggestions(address) ⇒ VAProfile::AddressValidation::AddressSuggestionsResponse

Get address suggestions and override key from the VA profile API

Returns:



19
20
21
22
23
# File 'lib/va_profile/address_validation/service.rb', line 19

def address_suggestions(address)
  candidate_res = candidate(address)

  AddressSuggestionsResponse.new(candidate_res)
end

#candidate(address) ⇒ Hash

Returns raw data from VA profile address validation API including address suggestions, validation key, and address errors.

Returns:

  • (Hash)

    raw data from VA profile address validation API including address suggestions, validation key, and address errors



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/va_profile/address_validation/service.rb', line 27

def candidate(address)
  begin
    res = perform(
      :post,
      'candidate',
      address.address_validation_req.to_json
    )
  rescue => e
    handle_error(e)
  end

  res.body
end