Class: CurrencyConversion::Client
- Inherits:
-
Object
- Object
- CurrencyConversion::Client
- Defined in:
- lib/currency-conversion/client.rb
Overview
Client
Constant Summary collapse
- BASE_URL =
Returns Default API endpoint.
'https://api.currencyapi.com'
- API_VERSION =
Returns API Version.
'v3'
Instance Attribute Summary collapse
-
#adapter ⇒ Symbol
readonly
Gets the Symbol key identifying a default Adapter to use.
-
#api_key ⇒ String
readonly
API Key.
Instance Method Summary collapse
-
#connection ⇒ Faraday::Connection
Initializes a new Faraday connection.
-
#currencies ⇒ CurrenciesEndpoint
Currencies Endpoint instance.
-
#exchange_rates ⇒ ExchangeRatesEndpoint
Exchange Rates Endpoint instance.
-
#initialize(api_key:, adapter: Faraday.default_adapter) ⇒ Currency::Conversion::Client
constructor
Initialize a new client.
-
#status ⇒ StatusEndpoint
Status Endpoint instance.
Constructor Details
#initialize(api_key:, adapter: Faraday.default_adapter) ⇒ Currency::Conversion::Client
Initialize a new client
24 25 26 27 |
# File 'lib/currency-conversion/client.rb', line 24 def initialize(api_key:, adapter: Faraday.default_adapter) @api_key = api_key @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Symbol (readonly)
Returns Gets the Symbol key identifying a default Adapter to use.
16 17 18 |
# File 'lib/currency-conversion/client.rb', line 16 def adapter @adapter end |
#api_key ⇒ String (readonly)
Returns API Key.
13 14 15 |
# File 'lib/currency-conversion/client.rb', line 13 def api_key @api_key end |
Instance Method Details
#connection ⇒ Faraday::Connection
Initializes a new Faraday connection
53 54 55 56 57 58 59 |
# File 'lib/currency-conversion/client.rb', line 53 def connection @connection ||= Faraday.new(headers: default_headers) do |conn| conn.url_prefix = connection_url conn.response :json, content_type: 'application/json' conn.adapter adapter end end |
#currencies ⇒ CurrenciesEndpoint
Currencies Endpoint instance
39 40 41 |
# File 'lib/currency-conversion/client.rb', line 39 def currencies CurrenciesEndpoint.new(self) end |
#exchange_rates ⇒ ExchangeRatesEndpoint
Exchange Rates Endpoint instance
46 47 48 |
# File 'lib/currency-conversion/client.rb', line 46 def exchange_rates ExchangeRatesEndpoint.new(self) end |
#status ⇒ StatusEndpoint
Status Endpoint instance
32 33 34 |
# File 'lib/currency-conversion/client.rb', line 32 def status StatusEndpoint.new(self) end |