Class: Nozbe::NotesListApiCall

Inherits:
ApiCall
  • Object
show all
Defined in:
lib/nozbe/note.rb

Overview

This class is used internaly by the Note class to make the API call that list all notes

Constant Summary

Constants inherited from ApiCall

ApiCall::API_BASE_URL

Instance Attribute Summary

Attributes inherited from ApiCall

#action, #parameters, #required_parameters

Instance Method Summary collapse

Methods inherited from ApiCall

action, #build_query_string, #build_request_path, #call, #do_request, #initialize, #url_encode

Constructor Details

This class inherits a constructor from Nozbe::ApiCall

Instance Method Details

#parse(json) ⇒ Object

Parse the JSON response, and return an Array of Note instances, or an empty array if no notes are found.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/nozbe/note.rb', line 42

def parse(json)
  notes = super(json)
  return [] if notes.nil?
  notes.collect do |raw_note|
    note = Note.new
    note.id = raw_note["id"]
    note.name = raw_note["name"]
    note.body = raw_note["body"]
    note.body_show = raw_note["body_show"]
    note.date = raw_note["date"]
    note.project = Nozbe::Project.new
    note.project.id = raw_note["project_id"]
    note.project.name = raw_note["project_name"]
    note.context = Nozbe::Context.new
    note.context.id = raw_note["context_id"]
    note.context.name = raw_note["context_name"]
    note.context.icon = raw_note["context_icon"]
    note
  end
end