Class: MontaAPI::Client

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

Constant Summary collapse

BASE_URL =
"https://api-v6.monta.nl/"

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#adapterObject (readonly)

Returns the value of attribute adapter.



9
10
11
# File 'lib/monta_api/client.rb', line 9

def adapter
  @adapter
end

#passwordObject (readonly)

Returns the value of attribute password.



9
10
11
# File 'lib/monta_api/client.rb', line 9

def password
  @password
end

#usernameObject (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

#connectionObject



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

#returnObject



17
18
19
# File 'lib/monta_api/client.rb', line 17

def return
  ReturnResource.new(self)
end

#return_forecastObject



21
22
23
# File 'lib/monta_api/client.rb', line 21

def return_forecast
  ReturnForecastResource.new(self)
end