Class: Everlog::Inf::Api::Evernote
- Inherits:
-
Everlog::Inf::Api
- Object
- Everlog::Inf::Api
- Everlog::Inf::Api::Evernote
- Defined in:
- lib/everlog/inf/api/evernote.rb
Instance Method Summary collapse
- #client ⇒ Object
- #create_notebook(title) ⇒ Object
-
#initialize(is_sandbox, config) ⇒ Evernote
constructor
A new instance of Evernote.
- #note ⇒ Object
- #notebook ⇒ Object
- #notebooks ⇒ Object
- #post_note(title, content) ⇒ Object
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
#client ⇒ Object
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 |
#note ⇒ Object
14 15 16 |
# File 'lib/everlog/inf/api/evernote.rb', line 14 def note @note ||= ::Evernote::EDAM::Type::Note.new end |
#notebook ⇒ Object
18 19 20 |
# File 'lib/everlog/inf/api/evernote.rb', line 18 def notebook @notebook ||= ::Evernote::EDAM::Type::Notebook.new end |
#notebooks ⇒ Object
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 |