Class: MPI::Configuration

Inherits:
Common::Client::Configuration::SOAP show all
Defined in:
lib/mpi/configuration.rb

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::SOAP

#allow_missing_certs?, #ssl_cert, #ssl_key

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

.open_timeoutObject



8
9
10
# File 'lib/mpi/configuration.rb', line 8

def self.open_timeout
  Settings.mvi.open_timeout
end

.read_timeoutObject



12
13
14
# File 'lib/mpi/configuration.rb', line 12

def self.read_timeout
  Settings.mvi.timeout
end

.ssl_cert_pathObject



16
17
18
# File 'lib/mpi/configuration.rb', line 16

def self.ssl_cert_path
  Settings.mvi.client_cert_path
end

.ssl_key_pathObject



20
21
22
# File 'lib/mpi/configuration.rb', line 20

def self.ssl_key_path
  Settings.mvi.client_key_path
end

Instance Method Details

#base_pathObject



24
25
26
# File 'lib/mpi/configuration.rb', line 24

def base_path
  Settings.mvi.url
end

#connectionObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/mpi/configuration.rb', line 41

def connection
  Faraday.new(base_path, headers: base_request_headers, request: request_options, ssl: ssl_options) do |conn|
    conn.use :breakers
    conn.request :soap_headers

    # Uncomment this if you want curl command equivalent or response output to log
    # conn.request(:curl, ::Logger.new(STDOUT), :warn) unless Rails.env.production?
    # conn.response(:logger, ::Logger.new(STDOUT), bodies: true) unless Rails.env.production?

    conn.response :soap_parser
    conn.use :logging, 'MVIRequest' if Settings.mvi.pii_logging # Refactor as response middleware?
    conn.response :betamocks if Settings.mvi.mock
    conn.adapter Faraday.default_adapter
  end
end

#service_nameObject



28
29
30
# File 'lib/mpi/configuration.rb', line 28

def service_name
  'MVI'
end

#ssl_optionsObject



32
33
34
35
36
37
38
39
# File 'lib/mpi/configuration.rb', line 32

def ssl_options
  if ssl_cert && ssl_key
    {
      client_cert: ssl_cert,
      client_key: ssl_key
    }
  end
end