Class: IHub::Appointments::Service
- Inherits:
-
Service
- Object
- Common::Client::Base
- Service
- IHub::Appointments::Service
- Includes:
- Common::Client::Concerns::Monitoring
- Defined in:
- lib/ihub/appointments/service.rb
Constant Summary
Constants inherited from Service
Instance Method Summary collapse
-
#appointments ⇒ IHub::Appointments::Response
Fetches a collection of veteran appointment data from iHub.
- #appointments_url ⇒ Object private
- #icn_present! ⇒ Object private
- #log_error(response) ⇒ Object private
-
#report_error!(response) ⇒ Object
private
When an iHub error occurs, iHub sets a ‘error_occurred’ key to true, returns a status of 200, and includes the error’s details in the response.body hash.
Methods included from Common::Client::Concerns::Monitoring
#increment, #increment_failure, #increment_total, #with_monitoring
Methods inherited from Service
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 IHub::Service
Instance Method Details
#appointments ⇒ IHub::Appointments::Response
Fetches a collection of veteran appointment data from iHub.
Per iHub docs, requires a service parameter of noFilter=true, in non-production environments.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ihub/appointments/service.rb', line 45 def appointments icn_present! with_monitoring do response = perform(:get, appointments_url, nil) report_error!(response) IHub::Appointments::Response.from(response) end rescue => e Sentry.set_extras( message: e., url: config.base_path ) Sentry.(ihub: 'appointments') raise e end |
#appointments_url ⇒ Object (private)
75 76 77 78 79 80 81 |
# File 'lib/ihub/appointments/service.rb', line 75 def appointments_url if Settings.ihub.in_production @user.icn else "#{@user.icn}?noFilter=true" end end |
#icn_present! ⇒ Object (private)
67 68 69 70 71 72 73 |
# File 'lib/ihub/appointments/service.rb', line 67 def icn_present! if @user.icn.blank? error = Common::Client::Errors::ClientError.new('User has no ICN', 500, 'User has no ICN') raise_backend_exception('IHUB_102', self.class, error) end end |
#log_error(response) ⇒ Object (private)
103 104 105 106 107 108 |
# File 'lib/ihub/appointments/service.rb', line 103 def log_error(response) Sentry.set_extras( response_body: response.body.merge('status_code' => response.status) ) Sentry.(ihub: 'appointments_error_occurred') end |
#report_error!(response) ⇒ Object (private)
When an iHub error occurs, iHub sets a ‘error_occurred’ key to true, returns a status of 200, and includes the error’s details in the response.body hash.
96 97 98 99 100 101 |
# File 'lib/ihub/appointments/service.rb', line 96 def report_error!(response) if response.body&.dig('error_occurred') log_error(response) raise_backend_exception('IHUB_101', self.class, response) end end |