Sha256: f83ac99088e2e811997c57610284bbe32cedfa1b6266777d06877efc01d938cf

Contents?: true

Size: 1.51 KB

Versions: 6

Compression:

Stored size: 1.51 KB

Contents

require 'net/https'
require 'faraday'
require_relative 'middleware/parameters_name_decoding_handler'
require_relative 'middleware/user_agent_handler'
module MicrosoftKiotaFaraday
    class KiotaClientFactory
        def self.get_default_middleware()
            return [
                MicrosoftKiotaFaraday::Middleware::ParametersNameDecodingHandler,
                MicrosoftKiotaFaraday::Middleware::UserAgentHandler
            ]
        end

        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
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
microsoft_kiota_faraday-0.15.0 lib/microsoft_kiota_faraday/kiota_client_factory.rb
microsoft_kiota_faraday-0.14.0 lib/microsoft_kiota_faraday/kiota_client_factory.rb
microsoft_kiota_faraday-0.13.0 lib/microsoft_kiota_faraday/kiota_client_factory.rb
microsoft_kiota_faraday-0.12.0 lib/microsoft_kiota_faraday/kiota_client_factory.rb
microsoft_kiota_faraday-0.11.0 lib/microsoft_kiota_faraday/kiota_client_factory.rb
microsoft_kiota_faraday-0.10.0 lib/microsoft_kiota_faraday/kiota_client_factory.rb