Class: Thingdeck::Wrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/thingdeck/wrapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(app_id, secret) ⇒ Wrapper

Returns a new instance of Wrapper.



3
4
5
# File 'lib/thingdeck/wrapper.rb', line 3

def initialize(app_id, secret)
  @token = authenticate(app_id, secret)
end

Instance Method Details

#authorized?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/thingdeck/wrapper.rb', line 7

def authorized?
  !!@token
end

#collectionsObject



11
12
13
# File 'lib/thingdeck/wrapper.rb', line 11

def collections
  @collections ||= Collection.new(self)
end

#perform_request(need_auth = true) ⇒ Object



19
20
21
22
23
# File 'lib/thingdeck/wrapper.rb', line 19

def perform_request(need_auth = true)
  raise 'Not Authorized' if need_auth and not authorized?
  response = yield(connection)
  parse_body(response)
end

#thingsObject



15
16
17
# File 'lib/thingdeck/wrapper.rb', line 15

def things
  @things ||= Thing.new(self)
end