Class: MyTado::CredentialGetter

Inherits:
Object
  • Object
show all
Defined in:
lib/my_tado/credential_getter.rb

Overview

Gets credentials from a source, either YAML or a string

Defined Under Namespace

Classes: HomeIDNotAnIntegerError, InvalidSourceError

Constant Summary collapse

DEFAULT_CLIENT_SECRET =
'wZaRN7rpjn3FoNyF5IFuxg9uMzYJcvOoQ8QWiIqS3hfk6gLhVlG57j5YNoZL2Rtc'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data_source) ⇒ CredentialGetter

Returns a new instance of CredentialGetter.



12
13
14
15
16
17
18
19
20
21
# File 'lib/my_tado/credential_getter.rb', line 12

def initialize(data_source)
  case data_source.class.to_s
  when "Hash"
    load_hash(data_source)
  when "String"
    load_file(data_source)
  else
    raise InvalidSourceError
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/my_tado/credential_getter.rb', line 10

def data
  @data
end

Instance Method Details

#client_secretObject



23
24
25
# File 'lib/my_tado/credential_getter.rb', line 23

def client_secret
  data["client_secret"] || DEFAULT_CLIENT_SECRET
end

#home_idObject



27
28
29
# File 'lib/my_tado/credential_getter.rb', line 27

def home_id
  data["home_id"]
end

#passwordObject



31
32
33
# File 'lib/my_tado/credential_getter.rb', line 31

def password
  data["password"]
end

#refresh_tokenObject



35
36
37
# File 'lib/my_tado/credential_getter.rb', line 35

def refresh_token
  data["refresh_token"]
end

#usernameObject



39
40
41
# File 'lib/my_tado/credential_getter.rb', line 39

def username
  data["username"]
end