Class: EVSS::Letters::DownloadService
- Inherits:
-
Service
- Object
- Common::Client::Base
- Service
- EVSS::Letters::DownloadService
- Includes:
- Common::Client::Concerns::Monitoring
- Defined in:
- lib/evss/letters/download_service.rb
Overview
Proxy Service for Letters Download Caseflow
Constant Summary
Constants inherited from Service
Instance Attribute Summary
Attributes inherited from Service
Instance Method Summary collapse
- #download(type) ⇒ Object private
-
#download_letter(type, options = nil) ⇒ String
Downloads a letter for a user.
- #download_with_benefit_options(type, options) ⇒ Object private
Methods included from Common::Client::Concerns::Monitoring
#increment, #increment_failure, #increment_total, #with_monitoring
Methods inherited from Service
#handle_error, #headers, #initialize, #perform, #save_error_details, service_is_up?, #with_monitoring_and_error_handling
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
#download(type) ⇒ Object (private)
50 51 52 |
# File 'lib/evss/letters/download_service.rb', line 50 def download(type) perform(:get, type) end |
#download_letter(type, options = nil) ⇒ String
Downloads a letter for a user
one of EVSS::Letters::Letter::LETTER_TYPES
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/evss/letters/download_service.rb', line 28 def download_letter(type, = nil) with_monitoring do response = if .blank? download(type) else (type, ) end case response.status.to_i when 200 response.body when 404 raise Common::Exceptions::RecordNotFound, type else Sentry.set_extras(url: config.base_path, body: response.body) raise_backend_exception('EVSS502', 'Letters') end end end |
#download_with_benefit_options(type, options) ⇒ Object (private)
54 55 56 |
# File 'lib/evss/letters/download_service.rb', line 54 def (type, ) perform(:post, "#{type}/generate", , 'Content-Type' => 'application/json') end |