Class: MDOT::Configuration

Inherits:
Common::Client::Configuration::REST show all
Defined in:
lib/mdot/configuration.rb

Instance Attribute Summary

Attributes inherited from Common::Client::Configuration::Base

#base_request_headers, #open_timeout, #read_timeout, #request_types, #user_agent

Instance Method Summary collapse

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

Instance Method Details

#base_pathObject



11
12
13
# File 'lib/mdot/configuration.rb', line 11

def base_path
  Settings.mdot.url
end

#connectionObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mdot/configuration.rb', line 15

def connection
  @connection = Faraday.new(base_path, headers: base_request_headers, request: request_options) do |f|
    f.use :breakers
    f.request :json
    f.use Faraday::Response::RaiseError
    f.response :betamocks if mock_enabled?
    f.response :snakecase, symbolize: false
    f.response :json
    f.adapter Faraday.default_adapter

    # TODO: remove long timeouts after changing to real API
    f.options.timeout = 30
    f.options.open_timeout = 30
  end
end

#mock_enabled?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/mdot/configuration.rb', line 31

def mock_enabled?
  Settings.mdot.mock || false
end

#service_nameObject



7
8
9
# File 'lib/mdot/configuration.rb', line 7

def service_name
  'MDOT'
end