Beispiel #1
0
 /**
  * Finds a book array from an isbn array using the Google Books API
  *
  * @param array $isbns
  *
  * @return array
  */
 public function find(array &$isbns)
 {
     $data = [];
     $isbnsNotFound = [];
     try {
         if (is_array($isbns)) {
             foreach ($isbns as $isbn) {
                 $q = Constants::GOOGLE_BOOKS_QUERY . $isbn;
                 $result = $this->booksApi->volumes->listVolumes($q, $this->params);
                 $items = $result->getItems();
                 if (count($items) > 0) {
                     $volumeInfo = $items[0]->getVolumeInfo();
                     $book = Book::buildBookWithGoogleApiInfo($volumeInfo);
                     $data[] = $book;
                 } else {
                     $isbnsNotFound[] = $isbn;
                 }
             }
             $isbns = $isbnsNotFound;
             return $data;
         }
     } catch (Exception $e) {
         //TODO: catch specific exception
         return $data;
     }
 }