Class: MyTado::Request::AbstractRequest

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/my_tado/request/abstract_request.rb

Overview

Sends requests to tado’s main API

Direct Known Subclasses

DayReport, Home, Me, Presence, Weather, ZoneState, Zones

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token, options) ⇒ AbstractRequest

Returns a new instance of AbstractRequest.



17
18
19
20
# File 'lib/my_tado/request/abstract_request.rb', line 17

def initialize(access_token, options)
  @access_token = access_token
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/my_tado/request/abstract_request.rb', line 11

def options
  @options
end

Class Method Details

.requires_home_id_param?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/my_tado/request/abstract_request.rb', line 13

def self.requires_home_id_param?
  true
end

Instance Method Details

#bodyObject



37
38
39
# File 'lib/my_tado/request/abstract_request.rb', line 37

def body
  nil
end

#callObject



22
23
24
25
26
27
# File 'lib/my_tado/request/abstract_request.rb', line 22

def call
  self.class.public_send(method, endpoint, {
    headers: { "Authorization" => "Bearer #{@access_token}" },
    body: body,
  },)
end

#klass_nameObject



33
34
35
# File 'lib/my_tado/request/abstract_request.rb', line 33

def klass_name
  self.class.to_s.gsub(/(.)([A-Z])/, '\1_\2').downcase
end

#methodObject



29
30
31
# File 'lib/my_tado/request/abstract_request.rb', line 29

def method
  :get
end