Class: Dropcam::Notification

Inherits:
NotificationBase show all
Defined in:
lib/dropcam/notification.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#cookies, #session_token

Instance Method Summary collapse

Methods inherited from NotificationBase

#devices

Methods inherited from Base

#get, #post

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

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/dropcam/notification.rb', line 6

def id
  @id
end

#is_enabledObject

Returns the value of attribute is_enabled.



6
7
8
# File 'lib/dropcam/notification.rb', line 6

def is_enabled
  @is_enabled
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/dropcam/notification.rb', line 6

def name
  @name
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/dropcam/notification.rb', line 6

def type
  @type
end

#valueObject

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.cookies)     
  return Notification.new(@camera, JSON.parse(response.body)["items"][0])

end

#deleteObject



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.cookies)      
  true
end