Class: BenefitsEducation::Service

Inherits:
Common::Client::Base show all
Includes:
Common::Client::Concerns::Monitoring, SentryLogging
Defined in:
lib/lighthouse/benefits_education/service.rb

Constant Summary collapse

STATSD_KEY_PREFIX =
'api.benefits_education'

Instance Method Summary collapse

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

#increment, #increment_failure, #increment_total, #with_monitoring

Methods included from SentryLogging

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

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

Constructor Details

#initialize(icn) ⇒ BenefitsEducation::Service

Returns a new instance of the service.

Raises:

  • (ArgumentError)


22
23
24
25
26
27
# File 'lib/lighthouse/benefits_education/service.rb', line 22

def initialize(icn)
  @icn = icn
  raise ArgumentError, 'no ICN passed in for LH API request.' if icn.blank?

  super()
end

Instance Method Details

#get_gi_bill_statusString

Retrieve a veteran’s Post-9/11 GI Bill Status

Returns:

  • (String)

    A JSON string representing the veteran’s GI Bill status.



42
43
44
45
46
47
48
49
50
51
# File 'lib/lighthouse/benefits_education/service.rb', line 42

def get_gi_bill_status
  raw_response = begin
    config.get(@icn)
  rescue Breakers::OutageException => e
    raise e
  rescue => e
    handle_error(e, config.service_name, config.base_path)
  end
  BenefitsEducation::Response.new(raw_response.status, raw_response)
end

#handle_error(error, lighthouse_client_id, endpoint) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/lighthouse/benefits_education/service.rb', line 53

def handle_error(error, lighthouse_client_id, endpoint)
  Lighthouse::ServiceException.send_error(
    error,
    self.class.to_s.underscore,
    lighthouse_client_id,
    endpoint
  )
end

#inspectObject

Overriding inspect to avoid displaying icn (now considered to be PII) in the response



31
32
33
34
35
36
37
# File 'lib/lighthouse/benefits_education/service.rb', line 31

def inspect
  instance_variables_to_inspect = instance_variables - [:@icn]
  instance_variables_string = instance_variables_to_inspect.map do |var|
    "#{var}=#{instance_variable_get(var).inspect}"
  end.join(', ')
  "#<#{self.class}:#{object_id} #{instance_variables_string}>"
end