class Ecobee::Register
Attributes
expire[R]
result[R]
Public Class Methods
new( app_key: nil, http: nil, scope: DEFAULT_SCOPE )
click to toggle source
# File lib/ecobee/register.rb, line 6 def initialize( app_key: nil, http: nil, scope: DEFAULT_SCOPE ) @result = get_pin(app_key: app_key, http: http, scope: scope) @expire = Time.now.to_i + result['expires_in'] * 60 end
Public Instance Methods
code()
click to toggle source
# File lib/ecobee/register.rb, line 15 def code @result['code'] end
interval()
click to toggle source
# File lib/ecobee/register.rb, line 19 def interval @result['interval'] end
pin()
click to toggle source
# File lib/ecobee/register.rb, line 23 def pin @result['ecobeePin'] end
scope()
click to toggle source
# File lib/ecobee/register.rb, line 27 def scope @result['scope'] end
Private Instance Methods
get_pin(app_key: nil, http: nil, scope: nil)
click to toggle source
# File lib/ecobee/register.rb, line 33 def get_pin(app_key: nil, http: nil, scope: nil) scope = scope.to_s if scope.is_a? Symbol arg = "?response_type=ecobeePin&client_id=#{app_key}&scope=#{scope}" result = http.get(arg: arg, no_auth: true, resource_prefix: 'authorize', validate_status: false) if result.key? 'error' raise Ecobee::AuthError.new( "Register Error: (#{result['error']}) #{result['error_description']}" ) else result end end