Class: EVSS::GiBillStatus::Service
- Inherits:
-
Service
- Object
- Common::Client::Base
- Service
- EVSS::GiBillStatus::Service
- Defined in:
- lib/evss/gi_bill_status/service.rb
Overview
Proxy Service for GIBS Caseflow.
Constant Summary collapse
- OPERATING_ZONE =
'Eastern Time (US & Canada)'
- OPERATING_HOURS =
{ start: 6, end: 22, saturday_end: 19 }.freeze
Constants inherited from Service
Instance Attribute Summary
Attributes inherited from Service
Class Method Summary collapse
-
.retry_after_time ⇒ String
Next earliest date and time that the service will be available.
-
.seconds_until_downtime ⇒ Integer
The number of seconds until scheduled system downtime begins.
-
.within_scheduled_uptime? ⇒ Boolean
Is the current time within the system’s scheduled uptime.
Instance Method Summary collapse
-
#get_gi_bill_status(additional_headers = {}) ⇒ EVSS::GiBillStatus::GiBillStatusRestponse
Retreive the status of a GIBS claim for a user.
Methods inherited from Service
#headers, #initialize, #perform, service_is_up?
Methods included from Common::Client::Concerns::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
This class inherits a constructor from EVSS::Service
Class Method Details
.retry_after_time ⇒ String
Returns Next earliest date and time that the service will be available.
55 56 57 58 59 60 61 62 63 |
# File 'lib/evss/gi_bill_status/service.rb', line 55 def self.retry_after_time current_time = get_current_time tz = ActiveSupport::TimeZone.new(OPERATING_ZONE) service_start_time = tz.parse("#{tz.today} 0#{OPERATING_HOURS[:start]}:00:00") return service_start_time.httpdate if current_time.hour < OPERATING_HOURS[:start] service_start_time.tomorrow.httpdate end |
.seconds_until_downtime ⇒ Integer
Returns The number of seconds until scheduled system downtime begins.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/evss/gi_bill_status/service.rb', line 40 def self.seconds_until_downtime if within_scheduled_uptime? current_time = get_current_time end_hour = current_time.saturday? ? OPERATING_HOURS[:saturday_end] : OPERATING_HOURS[:end] tz = ActiveSupport::TimeZone.new(OPERATING_ZONE) service_end_time = tz.parse("#{tz.today} #{end_hour}:00:00") service_end_time - current_time else 0 end end |
.within_scheduled_uptime? ⇒ Boolean
Returns Is the current time within the system’s scheduled uptime.
28 29 30 31 32 33 34 35 |
# File 'lib/evss/gi_bill_status/service.rb', line 28 def self.within_scheduled_uptime? current_time = get_current_time if current_time.saturday? (OPERATING_HOURS[:start]...OPERATING_HOURS[:saturday_end]).cover?(current_time.hour) else (OPERATING_HOURS[:start]...OPERATING_HOURS[:end]).cover?(current_time.hour) end end |
Instance Method Details
#get_gi_bill_status(additional_headers = {}) ⇒ EVSS::GiBillStatus::GiBillStatusRestponse
Retreive the status of a GIBS claim for a user
information from the endpoint
71 72 73 74 75 76 77 |
# File 'lib/evss/gi_bill_status/service.rb', line 71 def get_gi_bill_status(additional_headers = {}) raw_response = perform(:get, '', nil, additional_headers) EVSS::GiBillStatus::GiBillStatusResponse.new(raw_response.status, raw_response) rescue Common::Client::Errors::ClientError => e response = OpenStruct.new(status: e.status, body: e.body) EVSS::GiBillStatus::GiBillStatusResponse.new(response.status, response) end |