Class: Dropcam::Dropcam

Inherits:
Base
  • Object
show all
Defined in:
lib/dropcam.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#cookies, #session_token

Instance Method Summary collapse

Methods inherited from Base

#delete, #get, #post

Constructor Details

#initialize(username, password) ⇒ Dropcam

Returns a new instance of Dropcam.



9
10
11
12
13
# File 'lib/dropcam.rb', line 9

def initialize(username, password)
  @session = Session.new(username, password)
  @session.authenticate
  ## 
end

Instance Attribute Details

#sessionObject (readonly)

Returns the value of attribute session.



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

def session
  @session
end

Instance Method Details

#camera(uuid) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/dropcam.rb', line 14

def camera(uuid)
  c = Camera.new(uuid)
  c.cookies = @session.cookies
  c.session_token = @session.session_token
  c.update_info
  c
end

#camerasObject



34
35
36
37
38
39
# File 'lib/dropcam.rb', line 34

def cameras      
  response = get(::CAMERAS_GET_VISIBLE, {"group_cameras" => true}, @session.cookies)
  response_json = JSON.parse(response.body)
  owned = response_json["items"][0]["owned"]
  json_to_camera(owned, true)
end

#get_public_camera(token) ⇒ Object



22
23
24
25
26
# File 'lib/dropcam.rb', line 22

def get_public_camera(token)
  response = get(::CAMERAS_GET_BY_PUBLIC_TOKEN, {"token"=>token, "return_deleted"=>true}, @session.cookies)      
  camera = JSON.parse(response.body)["items"][0]
  Camera.new(camera["uuid"], camera)
end

#public_camerasObject



28
29
30
31
32
# File 'lib/dropcam.rb', line 28

def public_cameras      
  response = get(::CAMERAS_GET_PUBLIC, {}, @session.cookies)
  public_cameras = JSON.parse(response.body)["items"]
  json_to_camera(public_cameras)
end