Class: EVSS::BaseService
Constant Summary
collapse
- SYSTEM_NAME =
'vets.gov'
- DEFAULT_TIMEOUT =
40
Class Method Summary
collapse
Instance Method Summary
collapse
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
Constructor Details
#initialize(headers, use_mock = false) ⇒ BaseService
Returns a new instance of BaseService.
14
15
16
17
|
# File 'lib/evss/base_service.rb', line 14
def initialize(, use_mock = false)
@headers =
@use_mock = use_mock
end
|
Class Method Details
.create_breakers_service(name:, url:) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/evss/base_service.rb', line 19
def self.create_breakers_service(name:, url:)
path = URI.parse(url).path
host = URI.parse(url).host
matcher = proc do |request_env|
request_env.url.host == host && request_env.url.path =~ /^#{path}/
end
Breakers::Service.new(
name:,
request_matcher: matcher
)
end
|
Instance Method Details
#base_url ⇒ Object
42
43
44
|
# File 'lib/evss/base_service.rb', line 42
def base_url
self.class::BASE_URL
end
|
#get(url) ⇒ Object
34
35
36
|
# File 'lib/evss/base_service.rb', line 34
def get(url)
conn.get url
end
|
#post(url, body = nil, headers = { 'Content-Type' => 'application/json' }) ⇒ Object
38
39
40
|
# File 'lib/evss/base_service.rb', line 38
def post(url, body = nil, = { 'Content-Type' => 'application/json' }, &)
conn.post(url, body, , &)
end
|
#timeout ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/evss/base_service.rb', line 46
def timeout
{
timeout: self.class::DEFAULT_TIMEOUT,
open_timeout: self.class::DEFAULT_TIMEOUT,
write_timeout: self.class::DEFAULT_TIMEOUT
}
end
|