Class: Kisi::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/kisi/client.rb,
lib/kisi/client/version.rb

Constant Summary collapse

VERSION =
"0.1.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Client

Returns a new instance of Client.



10
11
12
# File 'lib/kisi/client.rb', line 10

def initialize(token)
  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



8
9
10
# File 'lib/kisi/client.rb', line 8

def token
  @token
end

Instance Method Details

#get_doorsObject



14
15
16
# File 'lib/kisi/client.rb', line 14

def get_doors
  self.class.get("/locks/index_with_token.json?limit=10&offset=0&token=#{token}")
end

#unlock_door(door) ⇒ Object



18
19
20
21
22
23
# File 'lib/kisi/client.rb', line 18

def unlock_door(door)
  self.class.post(
    "/locks/#{door["id"]}/access_with_token.json?token=#{token}",
    { body: { lock: door } }
  )
end