Class: Apps::Configuration

Inherits:
Common::Client::Configuration::REST show all
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

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

Class Method Details

.base_request_headersHash

Returns The basic headers required for any Apps API call.

Returns:

  • (Hash)

    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_pathString

Returns Base path for apps URLs.

Returns:

  • (String)

    Base path for apps URLs.



34
35
36
# File 'lib/apps/configuration.rb', line 34

def base_path
  Settings.directory.url
end

#connectionObject



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: request_options) 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_nameString

Returns Service name to use in breakers and metrics.

Returns:

  • (String)

    Service name to use in breakers and metrics.



41
42
43
# File 'lib/apps/configuration.rb', line 41

def service_name
  'APPS'
end