Class: Dropcam::Notification
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#is_enabled ⇒ Object
Returns the value of attribute is_enabled.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from Base
Instance Method Summary collapse
- #create(email) ⇒ Object
- #delete(notifcation_id = nil) ⇒ Object
- #find(name) ⇒ Object
-
#initialize(camera, properties = {}) ⇒ Notification
constructor
A new instance of Notification.
- #set(enable) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(camera, properties = {}) ⇒ Notification
Returns a new instance of Notification.
6 7 8 9 10 11 12 13 |
# File 'lib/dropcam/notification.rb', line 6 def initialize(camera, properties={}) @camera = camera @name = properties["name"] @type = properties["type"] @value = properties["value"] @id = properties["id"] @is_enabled = properties["enabled"] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/dropcam/notification.rb', line 4 def id @id end |
#is_enabled ⇒ Object
Returns the value of attribute is_enabled.
4 5 6 |
# File 'lib/dropcam/notification.rb', line 4 def is_enabled @is_enabled end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/dropcam/notification.rb', line 4 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/dropcam/notification.rb', line 4 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/dropcam/notification.rb', line 4 def value @value end |
Instance Method Details
#create(email) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dropcam/notification.rb', line 25 def create(email) # {"status": 400, "items": [], "status_description": "bad-request", "status_detail": "This notification target already exists"} response = post(::CAMERA_ADD_EMAIL_NOTIFICATION, {"email"=>email}, @camera.) if response.success? return Notification.new(@camera, JSON.parse(response.body)["items"][0]) elsif response.error? raise UnkownError, JSON.parse(response.body)["status_detail"] elsif response. raise AuthorizationError else raise CameraNotFoundError end end |
#delete(notifcation_id = nil) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dropcam/notification.rb', line 53 def delete(notifcation_id=nil) notifcation_id = @id unless notifcation_id response = post(::CAMERA_DELETE_NOTIFICATION, {"id"=>notifcation_id}, @camera.) if response.success? return true elsif response. raise AuthorizationError else raise CameraNotFoundError end end |
#find(name) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/dropcam/notification.rb', line 15 def find(name) note = @camera.notification_devices.select{|note| if note.name == name puts "#{note.name} == #{name}" return note end } note end |
#set(enable) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/dropcam/notification.rb', line 39 def set(enable) # email or gcm or apn params = {"id"=>@camera.uuid, "is_enabled"=>enable, "device_token" => @value} puts params response = post(::CAMERA_NOTIFICATION_UPDATE, params, @camera.) if response.success? return true elsif response. raise AuthorizationError else raise CameraNotFoundError end end |