Class: Wunderlist::Task

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/wunderlist/task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#destroy, #save, #to_hash, #update

Constructor Details

#initialize(options = {}) ⇒ Task

Returns a new instance of Task.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/wunderlist/task.rb', line 12

def initialize(options = {})
  @api = options['api']
  @id = options['id']
  @list_id = options['list_id']
  @title = options['title']
  @revision = options['revision']
  @assignee_id = options['assignee_id']
  @completed = options['completed']
  @recurrence_type = options['recurrence_type']
  @recurrence_count = options['recurrence_count']
  @due_date = options['due_date']
  @starred = options['starred']
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



10
11
12
# File 'lib/wunderlist/task.rb', line 10

def api
  @api
end

#assignee_idObject

Returns the value of attribute assignee_id.



10
11
12
# File 'lib/wunderlist/task.rb', line 10

def assignee_id
  @assignee_id
end

#completedObject

Returns the value of attribute completed.



10
11
12
# File 'lib/wunderlist/task.rb', line 10

def completed
  @completed
end

#created_atObject

Returns the value of attribute created_at.



10
11
12
# File 'lib/wunderlist/task.rb', line 10

def created_at
  @created_at
end

#due_dateObject

Returns the value of attribute due_date.



10
11
12
# File 'lib/wunderlist/task.rb', line 10

def due_date
  @due_date
end

#idObject

Returns the value of attribute id.



10
11
12
# File 'lib/wunderlist/task.rb', line 10

def id
  @id
end

#list_idObject

Returns the value of attribute list_id.



10
11
12
# File 'lib/wunderlist/task.rb', line 10

def list_id
  @list_id
end

#recurrence_countObject

Returns the value of attribute recurrence_count.



10
11
12
# File 'lib/wunderlist/task.rb', line 10

def recurrence_count
  @recurrence_count
end

#recurrence_typeObject

Returns the value of attribute recurrence_type.



10
11
12
# File 'lib/wunderlist/task.rb', line 10

def recurrence_type
  @recurrence_type
end

#revisionObject

Returns the value of attribute revision.



10
11
12
# File 'lib/wunderlist/task.rb', line 10

def revision
  @revision
end

#starredObject

Returns the value of attribute starred.



10
11
12
# File 'lib/wunderlist/task.rb', line 10

def starred
  @starred
end

#titleObject

Returns the value of attribute title.



10
11
12
# File 'lib/wunderlist/task.rb', line 10

def title
  @title
end

Instance Method Details

#new_task_comment(attrs = {}) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/wunderlist/task.rb', line 40

def new_task_comment(attrs = {})
  attrs.stringify_keys
  t_c = Wunderlist::TaskComment.new(attrs)
  t_c.api = self.api
  t_c.task_id = self.id

  t_c

end

#noteObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/wunderlist/task.rb', line 50

def note
  res = self.api.request :get, 'api/v1/notes', {:task_id => self.id}
  if !res[0].nil?
    note = Wunderlist::Note.new(res[0])
  else
    note = Wunderlist::Note.new('task_id' => self.id)
  end

  note.api = self.api
  note.task_id = self.id

  note

end

#task_commentsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/wunderlist/task.rb', line 26

def task_comments
  res = self.api.request :get, 'api/v1/task_comments', {:task_id => self.id}
  task_comments = []

  res.each do |t_c|
    task_comment = Wunderlist::TaskComment.new(t_c)
    task_comment.api = self.api
    task_comments << task_comment
  end

  task_comments

end