class SesameAPI

Constants

ENDPOINT
VERSION

Public Class Methods

new(sesame_id, token) click to toggle source
# File lib/sesame-api.rb, line 7
def initialize(sesame_id, token)
  @path = ENDPOINT.path + sesame_id
  @opts = {'Authorization' => token, 'Content-Type' => 'application/json'}
  @client = Net::HTTP.new ENDPOINT.host, ENDPOINT.port
  @client.use_ssl = true
  @client.verify_mode = OpenSSL::SSL::VERIFY_PEER
  @client.verify_depth = 5
end

Public Instance Methods

lock() click to toggle source
# File lib/sesame-api.rb, line 16
def lock
  req = Net::HTTP::Post.new @path, @opts
  req.body = '{"command":"lock"}'
  @client.request req
end
status() click to toggle source
# File lib/sesame-api.rb, line 28
def status
  @client.request Net::HTTP::Get.new @path, @opts
end
unlock() click to toggle source
# File lib/sesame-api.rb, line 22
def unlock
  req = Net::HTTP::Post.new @path, @opts
  req.body = '{"command":"unlock"}'
  @client.request req
end