Class: Dropcam::Notification
- Inherits:
-
NotificationBase
- Object
- Base
- NotificationBase
- Dropcam::Notification
- Defined in:
- lib/dropcam/notification.rb
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 ⇒ Object
- #find(name) ⇒ Object
-
#initialize(camera, properties = {}) ⇒ Notification
constructor
A new instance of Notification.
- #set(enable) ⇒ Object
Methods inherited from NotificationBase
Methods inherited from Base
Constructor Details
#initialize(camera, properties = {}) ⇒ Notification
Returns a new instance of Notification.
8 9 10 11 12 13 14 15 |
# File 'lib/dropcam/notification.rb', line 8 def initialize(camera, properties={}) super(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.
6 7 8 |
# File 'lib/dropcam/notification.rb', line 6 def id @id end |
#is_enabled ⇒ Object
Returns the value of attribute is_enabled.
6 7 8 |
# File 'lib/dropcam/notification.rb', line 6 def is_enabled @is_enabled end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/dropcam/notification.rb', line 6 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/dropcam/notification.rb', line 6 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/dropcam/notification.rb', line 6 def value @value end |
Instance Method Details
#create(email) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/dropcam/notification.rb', line 26 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.) return Notification.new(@camera, JSON.parse(response.body)["items"][0]) end |
#delete ⇒ Object
40 41 42 |
# File 'lib/dropcam/notification.rb', line 40 def delete super(@id) end |
#find(name) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/dropcam/notification.rb', line 17 def find(name) note = @camera.notification_devices.select{|note| if note.name == name return note end } note end |
#set(enable) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/dropcam/notification.rb', line 33 def set(enable) # email or gcm or apn params = {"id"=>@camera.uuid, "is_enabled"=>enable, "device_token" => @value} response = post(::CAMERA_NOTIFICATION_UPDATE, params, @camera.) true end |