Пример #1
0
 /**
  * Take note and read the text recognition data.
  * Returns an array of Estey\EvernoteOCR\TextBlock objects.
  * 
  * @param Evernote\Model\Note $note
  * @return Estey\EvernoteOCR\TextBlock[]
  * @throws Estey\EvernoteOCR\Exceptions\ImageRecognitionException
  */
 private function getRecognition(Note $note)
 {
     // Get collection of resources from note.
     $resources = $note->getResources();
     $data = (array) $resources[0]->recognition;
     if (!isset($data['body'])) {
         throw new ImageRecognitionException('No text found in image file.');
     }
     return $this->parseTextBlocks($data['body']);
 }
 /**
  * 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;
 }