Class: ENUtils::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/evernote_utils.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, production = true) ⇒ Core

Returns a new instance of Core.

Raises:



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

#notestoreObject

Returns the value of attribute notestore.



14
15
16
# File 'lib/evernote_utils.rb', line 14

def notestore
  @notestore
end

#tokenObject

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(options={})
  Notebook.where(self, options)
end

#notes(options = {}) ⇒ Object



37
38
39
# File 'lib/evernote_utils.rb', line 37

def notes(options={})
  Note.where(self, options.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

#tags(options = {}) ⇒ Object



65
66
67
# File 'lib/evernote_utils.rb', line 65

def tags(options={})
  Tag.where(self, options)
end