Class: Apps::Configuration
- Inherits:
-
Common::Client::Configuration::REST
- Object
- Common::Client::Configuration::Base
- Common::Client::Configuration::REST
- Apps::Configuration
- Defined in:
- lib/apps/configuration.rb
Overview
HTTP client configuration for the Client, sets the base path, the base request headers, and a service name for breakers and metrics.
Instance Attribute Summary
Attributes inherited from Common::Client::Configuration::Base
#base_request_headers, #open_timeout, #read_timeout, #request_types, #user_agent
Class Method Summary collapse
-
.base_request_headers ⇒ Hash
The basic headers required for any Apps API call.
Instance Method Summary collapse
-
#base_path ⇒ String
Base path for apps URLs.
- #connection ⇒ Object
-
#service_name ⇒ String
Service name to use in breakers and metrics.
Methods inherited from Common::Client::Configuration::Base
#breakers_error_threshold, #breakers_exception_handler, #breakers_matcher, #breakers_service, #create_new_breakers_service, #current_module, #request_options, #service_exception
Class Method Details
.base_request_headers ⇒ Hash
Returns The basic headers required for any Apps API call.
27 28 29 |
# File 'lib/apps/configuration.rb', line 27 def self.base_request_headers super.merge('apikey' => Settings.directory.key) end |
Instance Method Details
#base_path ⇒ String
Returns Base path for apps URLs.
34 35 36 |
# File 'lib/apps/configuration.rb', line 34 def base_path Settings.directory.url end |
#connection ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/apps/configuration.rb', line 13 def connection @conn ||= Faraday.new(base_path, headers: base_request_headers, request: ) do |faraday| faraday.use :breakers faraday.use Faraday::Response::RaiseError faraday.response :snakecase, symbolize: false faraday.response :json, content_type: /\bjson/ # ensures only json content types parsed faraday.adapter Faraday.default_adapter end end |
#service_name ⇒ String
Returns Service name to use in breakers and metrics.
41 42 43 |
# File 'lib/apps/configuration.rb', line 41 def service_name 'APPS' end |