Class: Everlog::Dom::Repository::Evernote

Inherits:
Everlog::Dom::Repository show all
Defined in:
lib/everlog/dom/repository/evernote.rb

Constant Summary collapse

TARGET =
'lifelog'

Instance Method Summary collapse

Constructor Details

#initialize(is_sandbox, config) ⇒ Evernote

Returns a new instance of Evernote.



5
6
7
8
# File 'lib/everlog/dom/repository/evernote.rb', line 5

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

Instance Method Details

#api_clientObject



10
11
12
# File 'lib/everlog/dom/repository/evernote.rb', line 10

def api_client
  @api_client ||= Inf::Api::Evernote.new(@is_sandbox, @config)
end

#get_guid_forcibly(notebook_name) ⇒ Object



19
20
21
22
# File 'lib/everlog/dom/repository/evernote.rb', line 19

def get_guid_forcibly notebook_name
  api_client.notebooks.each {|n| return n.guid if n.name == notebook_name }
  api_client.create_notebook(notebook_name).guid
end

#save(title, content) ⇒ Object



14
15
16
17
# File 'lib/everlog/dom/repository/evernote.rb', line 14

def save(title, content)
  api_client.note.notebookGuid = get_guid_forcibly TARGET
  api_client.post_note(title, content)
end