Class: CompaniesHouseClient::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



25
26
27
28
29
30
31
32
33
# File 'lib/companies_house_client.rb', line 25

def initialize
  @connection ||= Her::API.new
  @api_key = ""
  @url = CompaniesHouseClient::API_URL
  @ssl_options = {
    ca_path: CompaniesHouseClient::CAPath.platform_path
  }
  @proxy
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



22
23
24
# File 'lib/companies_house_client.rb', line 22

def api_key
  @api_key
end

#connectionObject (readonly)

Returns the value of attribute connection.



23
24
25
# File 'lib/companies_house_client.rb', line 23

def connection
  @connection
end

#proxyObject

Returns the value of attribute proxy.



22
23
24
# File 'lib/companies_house_client.rb', line 22

def proxy
  @proxy
end

#ssl_optionsObject

Returns the value of attribute ssl_options.



22
23
24
# File 'lib/companies_house_client.rb', line 22

def ssl_options
  @ssl_options
end

#urlObject

Returns the value of attribute url.



22
23
24
# File 'lib/companies_house_client.rb', line 22

def url
  @url
end

Instance Method Details

#configure_connectionObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/companies_house_client.rb', line 35

def configure_connection

  @connection.setup url: @url, ssl: @ssl_options, proxy: @proxy do |c|

    #Auth
    c.use Faraday::Request::BasicAuthentication, @api_key, ''

    # Request
    c.use Faraday::Request::UrlEncoded

    # Parse collections
    c.use CompaniesHouseClient::CollectionParser
    # c.use Her::Middleware::DefaultParseJSON

    # Adapter
    c.use Faraday::Adapter::NetHttp
  end
end