Class: MontaAPI::Client
- Inherits:
-
Object
- Object
- MontaAPI::Client
- Defined in:
- lib/monta_api/client.rb
Constant Summary collapse
- BASE_URL =
"https://api-v6.monta.nl/"
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(username:, password:, adapter: Faraday.default_adapter) ⇒ Client
constructor
A new instance of Client.
- #return ⇒ Object
- #return_forecast ⇒ Object
Constructor Details
#initialize(username:, password:, adapter: Faraday.default_adapter) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 |
# File 'lib/monta_api/client.rb', line 11 def initialize(username:, password:, adapter: Faraday.default_adapter) @username = username @password = password @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
9 10 11 |
# File 'lib/monta_api/client.rb', line 9 def adapter @adapter end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
9 10 11 |
# File 'lib/monta_api/client.rb', line 9 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
9 10 11 |
# File 'lib/monta_api/client.rb', line 9 def username @username end |
Instance Method Details
#connection ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/monta_api/client.rb', line 25 def connection @connection ||= Faraday.new do |conn| conn.url_prefix = BASE_URL conn.request :json conn.response :json, content_type: "application/json" conn.adapter adapter conn.request :authorization, :basic, username, password end end |
#return ⇒ Object
17 18 19 |
# File 'lib/monta_api/client.rb', line 17 def return ReturnResource.new(self) end |
#return_forecast ⇒ Object
21 22 23 |
# File 'lib/monta_api/client.rb', line 21 def return_forecast ReturnForecastResource.new(self) end |