Class: Evernote::EDAM::Type::Notebook
- Inherits:
-
Object
- Object
- Evernote::EDAM::Type::Notebook
- Defined in:
- lib/everton.rb
Instance Method Summary collapse
-
#add_image(title, text, filename) ⇒ Object
Add an image note and return it.
-
#add_note(title, text) ⇒ Object
Add a text note and return it.
-
#find_notes(filter = nil, params = {}) ⇒ Object
See advanced search www.evernote.com/about/kb/article/advanced-search?lang=en.
Instance Method Details
#add_image(title, text, filename) ⇒ Object
Add an image note and return it
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/everton.rb', line 90 def add_image(title, text, filename) image = File.open(filename, "rb") { |io| io.read } hashFunc = Digest::MD5.new hashHex = hashFunc.hexdigest(image) data = Evernote::EDAM::Type::Data.new() data.size = image.size data.bodyHash = hashHex data.body = image resource = Evernote::EDAM::Type::Resource.new() resource.mime = "image/png" resource.data = data; resource.attributes = Evernote::EDAM::Type::ResourceAttributes.new() resource.attributes.fileName = filename note = Evernote::EDAM::Type::Note.new() note.title = title note.notebookGuid = self.guid note.content = '<?xml version="1.0" encoding="UTF-8"?>' + '<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">' + '<en-note>' + text + '<en-media type="image/png" hash="' + hashHex + '"/>' + '</en-note>' note.resources = [ resource ] Everton::Remote.note_store.createNote(Everton::Remote.access_token, note) end |
#add_note(title, text) ⇒ Object
Add a text note and return it
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/everton.rb', line 76 def add_note(title, text) note = Evernote::EDAM::Type::Note.new() note.title = title note.notebookGuid = self.guid note.content = '<?xml version="1.0" encoding="UTF-8"?>' + '<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note>' + text + '</en-note>' Everton::Remote.note_store.createNote(Everton::Remote.access_token, note) end |
#find_notes(filter = nil, params = {}) ⇒ Object
125 126 127 128 129 130 131 132 |
# File 'lib/everton.rb', line 125 def find_notes(filter=nil, params = {}) f = Evernote::EDAM::NoteStore::NoteFilter.new() f.notebookGuid = self.guid f.words = filter if filter offset = params[:offset] || 0 max_notes = params[:max_notes] || 20 Everton::Remote.note_store.findNotes(Remote.access_token,f,offset,max_notes).notes end |