Class: Dropcam::ClipBase

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

Direct Known Subclasses

Clip

Instance Attribute Summary

Attributes inherited from Base

#cookies, #session_token

Instance Method Summary collapse

Methods inherited from Base

#delete, #get, #post

Constructor Details

#initialize(camera) ⇒ ClipBase

Returns a new instance of ClipBase.



5
6
7
# File 'lib/dropcam/clip_base.rb', line 5

def initialize(camera)
  @camera = camera
end

Instance Method Details

#allObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dropcam/clip_base.rb', line 9

def all
  response = get(::CLIP_GET_ALL,{},@camera.cookies)
  clips = []
  all_clips = JSON.parse(response.body)["items"]
  for clip in all_clips
    c = Clip.new(@camera, clip)
    if c.camera_id == @camera.id
      clips.push c
    end
  end
  clips
end

#archiveObject



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

def archive
  ClipArchive.new(@camera)
end

#create(length, start_date, title, description) ⇒ Object



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

def create(length, start_date, title, description)
  params = {"uuid"=>@camera.uuid, "length" => length, "start_date" => start_date, "title" => title, "description" => description}
  response = post(::VIDEOS_REQUEST, params, @camera.cookies)      
  clip_info = JSON.parse(response.body)["items"][0]
  return Clip.new(@camera, clip_info)
  
end