Class: MicrosoftKiotaFaraday::KiotaClientFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/microsoft_kiota_faraday/kiota_client_factory.rb

Class Method Summary collapse

Class Method Details

.get_default_http_client(middleware = nil, default_middleware_options = Array.new) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/microsoft_kiota_faraday/kiota_client_factory.rb', line 14

def self.get_default_http_client(middleware=nil, default_middleware_options=Array.new)
    if middleware.nil? #empty is fine in case the user doesn't want to use any middleware
        middleware = self.get_default_middleware()
    end
    connection_options = Hash.new
    connection_options[:request] = Hash.new
    connection_options[:request][:context] = Hash.new
    unless default_middleware_options.nil? || default_middleware_options.empty? then
        default_middleware_options.each do |value|
            connection_options[:request][:context][value.get_key] = value
        end
    end
    conn = Faraday::Connection.new(nil, connection_options) do |builder|
        builder.adapter Faraday.default_adapter
        builder.ssl.verify = true
        builder.ssl.verify_mode = OpenSSL::SSL::VERIFY_PEER
        middleware.each do |handler|
            builder.use handler
        end
    end
    conn
end

.get_default_middlewareObject



7
8
9
10
11
12
# File 'lib/microsoft_kiota_faraday/kiota_client_factory.rb', line 7

def self.get_default_middleware()
    return [
        MicrosoftKiotaFaraday::Middleware::ParametersNameDecodingHandler,
        MicrosoftKiotaFaraday::Middleware::UserAgentHandler
    ]
end