/**
  * Moves a note to another notebook
  *
  * @param Note $note
  * @param Notebook $notebook
  * @return Note
  * @throws Exception\PermissionDeniedException
  * @throws \EDAM\Error\EDAMUserException
  * @throws \Exception
  */
 public function moveNote(Note $note, Notebook $notebook)
 {
     if ($this->isAppNotebookToken($this->token)) {
         throw new PermissionDeniedException("You can't move a note as you're using an app notebook token");
     }
     $edamNote = $note->getEdamNote();
     $noteStore = $note->getNoteStore();
     $token = $note->getAuthToken();
     $edamNote->notebookGuid = $notebook->guid;
     try {
         $moved_note = $noteStore->updateNote($token, $edamNote);
         $note = $this->getNoteInstance($moved_note, $noteStore, $token);
     } catch (EDAMNotFoundException $e) {
         $moved_note = $this->uploadNote($note, $notebook);
         if ($moved_note && $moved_note->notebookGuid === $notebook->guid) {
             $this->deleteNote($note);
         }
         $note = $moved_note;
     } catch (EDAMUserException $e) {
         if ($e->parameter === 'Note.notebookGuid') {
             $moved_note = $this->uploadNote($note, $notebook);
             if ($moved_note && $moved_note->notebookGuid === $notebook->guid) {
                 $this->deleteNote($note);
             }
             $note = $moved_note;
         } else {
             throw $e;
         }
     }
     return $note;
 }