Class: Everlog::Inf::Api::Evernote

Inherits:
Everlog::Inf::Api show all
Defined in:
lib/everlog/inf/api/evernote.rb

Instance Method Summary collapse

Constructor Details

#initialize(is_sandbox, config) ⇒ Evernote

Returns a new instance of Evernote.



5
6
7
8
# File 'lib/everlog/inf/api/evernote.rb', line 5

def initialize(is_sandbox, config)
  @is_sandbox = is_sandbox
  @config = config
end

Instance Method Details

#clientObject



10
11
12
# File 'lib/everlog/inf/api/evernote.rb', line 10

def client
  @client ||= EvernoteOAuth::Client.new(token: @config.access_secret, sandbox: @is_sandbox)
end

#create_notebook(title) ⇒ Object



30
31
32
33
34
35
# File 'lib/everlog/inf/api/evernote.rb', line 30

def create_notebook title
  notebook.name = title
  client.note_store.createNotebook notebook
rescue => e
  raise InfrastructureEvernoteError, "create_notebook error / class:#{e.class} code:#{e.errorCode}"
end

#noteObject



14
15
16
# File 'lib/everlog/inf/api/evernote.rb', line 14

def note
  @note ||= ::Evernote::EDAM::Type::Note.new
end

#notebookObject



18
19
20
# File 'lib/everlog/inf/api/evernote.rb', line 18

def notebook
  @notebook ||= ::Evernote::EDAM::Type::Notebook.new
end

#notebooksObject



37
38
39
40
41
# File 'lib/everlog/inf/api/evernote.rb', line 37

def notebooks
  client.note_store.listNotebooks
rescue => e
  raise InfrastructureEvernoteError, "notebooks error / class:#{e.class} code:#{e.errorCode}"
end

#post_note(title, content) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/everlog/inf/api/evernote.rb', line 22

def post_note(title, content)
  note.title = title
  note.content = content
  client.note_store.createNote(@config.access_secret, note)
rescue => e
  raise InfrastructureEvernoteError, "post note error / class:#{e.class} code:#{e.errorCode}"
end