Class: ENUtils::Core
- Inherits:
-
Object
- Object
- ENUtils::Core
- Defined in:
- lib/evernote_utils.rb
Instance Attribute Summary collapse
-
#notestore ⇒ Object
Returns the value of attribute notestore.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #find_note(guid, with_content: false, with_resources_data: false, with_resources_recognition: false, with_resources_alternate_data: false) ⇒ Object
-
#initialize(token, production = true) ⇒ Core
constructor
A new instance of Core.
- #notebook(name = nil) ⇒ Object
- #notebooks(options = {}) ⇒ Object
- #notes(options = {}) ⇒ Object
- #tag(name = nil) ⇒ Object
- #tags(options = {}) ⇒ Object
Constructor Details
#initialize(token, production = true) ⇒ Core
Returns a new instance of Core.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/evernote_utils.rb', line 16 def initialize(token, production=true) userStoreUrl = "https://#{production ? 'www' : 'sandbox'}.evernote.com/edam/user" userStoreTransport = Thrift::HTTPClientTransport.new(userStoreUrl) userStoreProtocol = Thrift::BinaryProtocol.new(userStoreTransport) userStore = Evernote::EDAM::UserStore::UserStore::Client.new(userStoreProtocol) versionOK = userStore.checkVersion("Evernote EDAMTest (Ruby)", Evernote::EDAM::UserStore::EDAM_VERSION_MAJOR, Evernote::EDAM::UserStore::EDAM_VERSION_MINOR) raise InvalidVersion unless versionOK noteStoreUrl = userStore.getNoteStoreUrl(token) noteStoreTransport = Thrift::HTTPClientTransport.new(noteStoreUrl) noteStoreProtocol = Thrift::BinaryProtocol.new(noteStoreTransport) @notestore = Evernote::EDAM::NoteStore::NoteStore::Client.new(noteStoreProtocol) @token = token end |
Instance Attribute Details
#notestore ⇒ Object
Returns the value of attribute notestore.
14 15 16 |
# File 'lib/evernote_utils.rb', line 14 def notestore @notestore end |
#token ⇒ Object
Returns the value of attribute token.
14 15 16 |
# File 'lib/evernote_utils.rb', line 14 def token @token end |
Instance Method Details
#find_note(guid, with_content: false, with_resources_data: false, with_resources_recognition: false, with_resources_alternate_data: false) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/evernote_utils.rb', line 41 def find_note(guid, with_content: false, with_resources_data: false, with_resources_recognition: false, with_resources_alternate_data: false) self.notestore.getNote(self.token, guid, with_content, with_resources_data, with_resources_recognition, with_resources_alternate_data) end |
#notebook(name = nil) ⇒ Object
51 52 53 54 |
# File 'lib/evernote_utils.rb', line 51 def notebook(name=nil) return nil unless name Notebook.find_by_name(self, name) end |
#notebooks(options = {}) ⇒ Object
56 57 58 |
# File 'lib/evernote_utils.rb', line 56 def notebooks(={}) Notebook.where(self, ) end |
#notes(options = {}) ⇒ Object
37 38 39 |
# File 'lib/evernote_utils.rb', line 37 def notes(={}) Note.where(self, .reverse_merge(order: :updated)) end |
#tag(name = nil) ⇒ Object
60 61 62 63 |
# File 'lib/evernote_utils.rb', line 60 def tag(name=nil) return nil unless name Tag.find_by_name(self, name) end |