Created
January 27, 2016 11:08
-
-
Save chikadance/9636aa4770f67e7729d7 to your computer and use it in GitHub Desktop.
ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'evernote_oauth' | |
require 'Evernote/EDAM/note_store_types' | |
require 'Evernote/EDAM/types_types' | |
require 'json' | |
token = JSON.load(File.read("#{ENV['HOME']}/evernote/api.json"))['dev_token'] | |
c = EvernoteOAuth::Client.new( | |
token: token, | |
service_host: 'app.yinxiang.com' | |
) | |
note_store = c.note_store | |
note_title = ::Time.now.to_s | |
note_body = ::Time.now.to_s | |
## Create n object | |
our_note = Evernote::EDAM::Type::Note.new | |
our_note.title = note_title | |
our_note.content = note_body | |
## Attempt to create n in Evernote account | |
begin | |
n = note_store.createNote(our_note) | |
rescue Evernote::EDAM::Error::EDAMUserException => edue | |
## Something was wrong with the n data | |
## See EDAMErrorCode enumeration for error code explanation | |
## http://dev.evernote.com/documentation/reference/Errors.html#Enum_EDAMErrorCode | |
puts "EDAMUserException: #{edue}" | |
rescue Evernote::EDAM::Error::EDAMNotFoundException => ednfe | |
## Parent Notebook GUID doesn't correspond to an actual notebook | |
puts "EDAMNotFoundException: Invalid parent notebook GUID" | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment