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

#to_hash

Constructor Details

#initialize(options = {}) ⇒ Task

Returns a new instance of Task.



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

def initialize(options = {})
  @api = options['api']
  @id = options['id']
  @list_id = options['list_id']
  @title = options['title']
  @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

#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 (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#list_idObject (readonly)

Returns the value of attribute list_id.



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

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

#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

#notesObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/wunderlist/task.rb', line 44

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

  res.each do |note|
    note = Wunderlist::Note.new(note)
    note.api = self.api
    notes << note
  end

  if notes.empty?
    note = Wunderlist::Note.new('task_id' => self.id)
    note.api = self.api
    notes << note
  end

  notes

end

#saveObject



26
27
28
# File 'lib/wunderlist/task.rb', line 26

def save
  self.api.request :post, 'api/v1/tasks', self.to_hash
end

#task_commentsObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/wunderlist/task.rb', line 30

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