Class: EVSS::PCIUAddress::Service

Inherits:
Service show all
Defined in:
lib/evss/pciu_address/service.rb

Overview

Proxy Service for PCIU Address Caseflow.

Examples:

Creating a service and fetching a country list

letters_response = EVSS::PCIUAddress::Service.new.get_countries

Constant Summary

Constants inherited from Service

Service::STATSD_KEY_PREFIX

Instance Attribute Summary

Attributes inherited from Service

#transaction_id

Instance Method Summary collapse

Methods inherited from Service

#handle_error, #headers, #initialize, #perform, #save_error_details, service_is_up?, #with_monitoring_and_error_handling

Methods included from Common::Client::Concerns::Monitoring

#increment, #increment_failure, #increment_total, #with_monitoring

Methods inherited from Common::Client::Base

#config, configuration, #connection, #delete, #get, #perform, #post, #put, #raise_backend_exception, #raise_not_authenticated, #request, #sanitize_headers!, #service_name

Methods included from SentryLogging

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

Constructor Details

This class inherits a constructor from EVSS::Service

Instance Method Details

#get_addressEVSS::PCIUAddress::AddressResponse

Returns Mailing address for a user.

Returns:



44
45
46
47
48
49
# File 'lib/evss/pciu_address/service.rb', line 44

def get_address
  with_monitoring_and_error_handling do
    raw_response = perform(:get, 'mailingAddress')
    EVSS::PCIUAddress::AddressResponse.new(raw_response.status, raw_response)
  end
end

#get_countriesEVSS::PCIUAddress::CountriesResponse

Returns A list of country names.

Returns:



24
25
26
27
28
29
# File 'lib/evss/pciu_address/service.rb', line 24

def get_countries
  with_monitoring_and_error_handling do
    raw_response = perform(:get, 'countries')
    EVSS::PCIUAddress::CountriesResponse.new(raw_response.status, raw_response)
  end
end

#get_statesEVSS::PCIUAddress::StatesResponse

Returns A list of state names.

Returns:



34
35
36
37
38
39
# File 'lib/evss/pciu_address/service.rb', line 34

def get_states
  with_monitoring_and_error_handling do
    raw_response = perform(:get, 'states')
    EVSS::PCIUAddress::StatesResponse.new(raw_response.status, raw_response)
  end
end

#request_body(address) ⇒ Object (private)



63
64
65
66
67
68
69
# File 'lib/evss/pciu_address/service.rb', line 63

def request_body(address)
  EVSS::PCIU::RequestBody.new(
    address,
    pciu_key: 'cnpMailingAddress',
    date_attr: 'address_effective_date'
  ).set
end

#update_address(address) ⇒ EVSS::PCIUAddress::AddressResponse

Returns The updated mailing address for a user.

Returns:



54
55
56
57
58
59
# File 'lib/evss/pciu_address/service.rb', line 54

def update_address(address)
  with_monitoring_and_error_handling do
    raw_response = perform(:post, 'mailingAddress', request_body(address), headers)
    EVSS::PCIUAddress::AddressResponse.new(raw_response.status, raw_response)
  end
end