Class: Dropcam::Dropcam
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Attributes inherited from Base
Instance Method Summary collapse
- #camera(uuid) ⇒ Object
- #cameras ⇒ Object
- #get_public_camera(token) ⇒ Object
-
#initialize(username, password) ⇒ Dropcam
constructor
A new instance of Dropcam.
- #public_cameras ⇒ Object
Methods inherited from Base
Constructor Details
Instance Attribute Details
#session ⇒ Object (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. = @session. c.session_token = @session.session_token c.properties = c.info c end |
#cameras ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dropcam.rb', line 49 def cameras response = get(::CAMERAS_GET_VISIBLE, {"group_cameras" => true}, @session.) cameras = [] if response.success? response_json = JSON.parse(response.body) owned = response_json["items"][0]["owned"] owned.each{|camera| c = Camera.new(camera["uuid"], camera) c. = @session. c.session_token = @session.session_token cameras.push(c) } end return cameras end |
#get_public_camera(token) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dropcam.rb', line 22 def get_public_camera(token) response = get(::CAMERAS_GET_BY_PUBLIC_TOKEN, {"token"=>token, "return_deleted"=>true}, @session.) if response.success? return response.body elsif response. raise AuthorizationError else raise CameraNotFoundError end end |
#public_cameras ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dropcam.rb', line 33 def public_cameras response = get(::CAMERAS_GET_PUBLIC, {}, @session.) cameras = [] if response.success? response_json = JSON.parse(response.body) owned = response_json["items"][0]["owned"] owned.each{|camera| c = Camera.new(camera["uuid"], camera) c. = @session. c.session_token = @session.session_token cameras.push(c) } end return cameras end |