Class: HttpApiClient::ConnectionFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/http_api_client/connection_factory.rb

Constant Summary collapse

OSX_CERT_PATH =
'/usr/local/opt/curl-ca-bundle/share/ca-bundle.crt'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ConnectionFactory

Returns a new instance of ConnectionFactory.



10
11
12
# File 'lib/http_api_client/connection_factory.rb', line 10

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/http_api_client/connection_factory.rb', line 8

def config
  @config
end

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/http_api_client/connection_factory.rb', line 14

def create

  Faraday.new(connection_options) do |connection|
    connection.port = config.port if config.port
    connection.request   :url_encoded    # form-encode POST params
    connection.adapter   :net_http
    # connection.use     :http_cache
    # connection.response  :logger

    if config.http_basic_username
      connection.basic_auth(config.http_basic_username, config.http_basic_password)
    end
  end

end