Class: EVSS::Service

Inherits:
Common::Client::Base show all
Includes:
Common::Client::Concerns::Monitoring
Defined in:
lib/evss/service.rb

Constant Summary collapse

STATSD_KEY_PREFIX =
'api.evss'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#with_monitoring

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

#initialize(user = nil, auth_headers = nil) ⇒ Service

Returns a new instance of Service.



13
14
15
16
17
18
19
20
21
22
# File 'lib/evss/service.rb', line 13

def initialize(user = nil, auth_headers = nil)
  @user = user
  if auth_headers.nil?
    @headers = EVSS::AuthHeaders.new(user)
    @transaction_id = @headers.transaction_id
  else
    @headers = auth_headers
    @transaction_id = auth_headers['va_eauth_service_transaction_id']
  end
end

Instance Attribute Details

#transaction_idObject (readonly)

Returns the value of attribute transaction_id.



8
9
10
# File 'lib/evss/service.rb', line 8

def transaction_id
  @transaction_id
end

Class Method Details

.service_is_up?Boolean

Returns:

  • (Boolean)


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

def self.service_is_up?
  last_evss_claims_outage = Breakers::Outage.find_latest(service: EVSS::ClaimsService.breakers_service)
  evss_claims_up = last_evss_claims_outage.blank? || last_evss_claims_outage.end_time.present?

  last_evss_common_outage = Breakers::Outage.find_latest(service: EVSS::CommonService.breakers_service)
  evss_common_up = last_evss_common_outage.blank? || last_evss_common_outage.end_time.present?
  evss_claims_up && evss_common_up
end

Instance Method Details

#headersObject



29
30
31
# File 'lib/evss/service.rb', line 29

def headers
  { 'Content-Type' => 'application/json' }
end

#perform(method, path, body = nil, headers = {}, options = {}) ⇒ Object



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

def perform(method, path, body = nil, headers = {}, options = {})
  merged_headers = @headers.to_h.merge(headers)
  super(method, path, body, merged_headers, options)
end