Class: Lockitron::User
- Inherits:
-
Object
- Object
- Lockitron::User
- Defined in:
- lib/lockitron/user.rb
Instance Method Summary collapse
- #get(action) ⇒ Object
-
#initialize(token) ⇒ User
constructor
A new instance of User.
- #locks ⇒ Object
- #post(action, params = {}) ⇒ Object
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 |
#locks ⇒ Object
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 |