Class: Wunderlist::Note

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#to_hash

Constructor Details

#initialize(options = {}) ⇒ Note

Returns a new instance of Note.



12
13
14
15
16
17
18
19
20
# File 'lib/wunderlist/note.rb', line 12

def initialize(options = {})
  @api = options['api']
  @id = options['id']
  @task_id = options['task_id']
  @content = options['content']
  @created_at = options['created_at']
  @updated_at = options['updated_at']
  @revision = options['revision']
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



9
10
11
# File 'lib/wunderlist/note.rb', line 9

def api
  @api
end

#contentObject

Returns the value of attribute content.



9
10
11
# File 'lib/wunderlist/note.rb', line 9

def content
  @content
end

#created_atObject (readonly)

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#revisionObject (readonly)

Returns the value of attribute revision.



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

def revision
  @revision
end

#task_idObject (readonly)

Returns the value of attribute task_id.



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

def task_id
  @task_id
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

Instance Method Details

#createObject



30
31
32
# File 'lib/wunderlist/note.rb', line 30

def create
  puts self.api.request :post, "api/v1/notes", self.to_hash
end

#updateObject



22
23
24
25
26
27
28
# File 'lib/wunderlist/note.rb', line 22

def update
  if self.id.nil?
    self.create
  else
    self.api.request :put, "api/v1/notes/#{self.id}", self.to_hash
  end
end