class EnClient::CreateNoteCommand

Attributes

content[RW]
edit_mode[RW]
notebook_guid[RW]
tag_names[RW]
title[RW]

Public Instance Methods

exec_impl() click to toggle source
# File usr/lib/evernote-mode/enclient.rb, line 473
def exec_impl
  Formatter.to_ascii @title, @content, *@tag_names

  note = Evernote::EDAM::Type::Note.new
  note.title = @title
  note.notebookGuid = @notebook_guid
  note.tagNames = @tag_names
  note.editMode = @edit_mode
  note.content = @content
  set_attribute_and_format_content! note

  server_task do
    result_note = sm.note_store.createNote sm.auth_token, note
    result_note.editMode = @edit_mode
    DBUtils.set_note_and_content dm, result_note, @content

    if result_note.tagGuids
      result_note.tagGuids.each do |guid|
        unless DBUtils.exist_tag_in_cache? dm, guid
          tags = sm.note_store.listTags sm.auth_token
          DBUtils.sync_updated_tags dm, tags
          break
        end
      end
    end

    reply = CreateNoteReply.new
    reply.note = result_note
    shell.reply self, reply
  end
end