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

#notebook(name = nil) ⇒ Object



41
42
43
44
# File 'lib/evernote_utils.rb', line 41

def notebook(name=nil)
  return nil unless name
  Notebook.find_by_name(self, name)
end

#notebooks(options = {}) ⇒ Object



46
47
48
# File 'lib/evernote_utils.rb', line 46

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)
end

#tag(name = nil) ⇒ Object



50
51
52
53
# File 'lib/evernote_utils.rb', line 50

def tag(name=nil)
  return nil unless name
  Tag.find_by_name(self, name)
end

#tags(options = {}) ⇒ Object



55
56
57
# File 'lib/evernote_utils.rb', line 55

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