Class: OEXRWrapper::Client
- Inherits:
-
Object
- Object
- OEXRWrapper::Client
- Defined in:
- lib/oexrwrapper/client.rb
Constant Summary collapse
- BASE_URL =
"https://openexchangerates.org/api/"
Instance Attribute Summary collapse
-
#app_id ⇒ Object
readonly
Returns the value of attribute app_id.
-
#base_rate_code ⇒ Object
readonly
Returns the value of attribute base_rate_code.
Instance Method Summary collapse
- #connection ⇒ Object
- #currencies ⇒ Object
-
#initialize(app_id:, base_rate_code: "USD") ⇒ Client
constructor
A new instance of Client.
- #latest ⇒ Object
Constructor Details
#initialize(app_id:, base_rate_code: "USD") ⇒ Client
Returns a new instance of Client.
10 11 12 13 |
# File 'lib/oexrwrapper/client.rb', line 10 def initialize(app_id:, base_rate_code: "USD") @app_id = app_id @base_rate_code = base_rate_code end |
Instance Attribute Details
#app_id ⇒ Object (readonly)
Returns the value of attribute app_id.
8 9 10 |
# File 'lib/oexrwrapper/client.rb', line 8 def app_id @app_id end |
#base_rate_code ⇒ Object (readonly)
Returns the value of attribute base_rate_code.
8 9 10 |
# File 'lib/oexrwrapper/client.rb', line 8 def base_rate_code @base_rate_code end |
Instance Method Details
#connection ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/oexrwrapper/client.rb', line 23 def connection @connection = Faraday.new do |conn| conn.url_prefix = BASE_URL conn.request :json conn.response :json, content_type: "application/json" conn.params["app_id"] = @app_id conn.params["base"] = @base_rate_code.upcase end end |
#currencies ⇒ Object
19 20 21 |
# File 'lib/oexrwrapper/client.rb', line 19 def currencies CurrenciesResources.new self end |
#latest ⇒ Object
15 16 17 |
# File 'lib/oexrwrapper/client.rb', line 15 def latest LatestResource.new self end |