Class: Lockitron::User

Inherits:
Object
  • Object
show all
Defined in:
lib/lockitron/user.rb

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ User

Returns a new instance of User.



7
8
9
# File 'lib/lockitron/user.rb', line 7

def initialize token
  @token = token
end

Instance Method Details

#get(action) ⇒ Object



15
16
17
18
# File 'lib/lockitron/user.rb', line 15

def get action
  resp = Faraday.get "#{API_ENDPOINT}/#{action}", {access_token: @token}
  process resp
end

#locksObject



11
12
13
# File 'lib/lockitron/user.rb', line 11

def locks
  get('locks').map {|lock| Lockitron::Lock.from_json lock}
end

#post(action, params = {}) ⇒ Object



20
21
22
23
24
# File 'lib/lockitron/user.rb', line 20

def post action, params = {}
  params.merge!({access_token: @token})
  resp = Faraday.post "#{API_ENDPOINT}/#{action}", params
  process resp
end