first commit

This commit is contained in:
Tyler
2020-12-21 02:09:34 -05:00
commit 2802973d3f
113 changed files with 30356 additions and 0 deletions

View File

@ -0,0 +1,7 @@
<?php
namespace App\Services\BookInformation;
interface BookLookupService {
public function lookup($isbn);
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Services\BookInformation;
use Google_Client;
use Google_Service_Books;
class GoogleBooks implements BookLookupService {
public function lookup($isbn) {
$client = new Google_Client();
$client->setApplicationName("BookInventory");
$client->setDeveloperKey(env('GOOGLE_BOOKS_KEY'));
$service = new Google_Service_Books($client);
$results = $service->volumes->listVolumes('isbn:' . $isbn);
/**
* @var \Google_Service_Books_Volume
*/
$volume = array_first($results->getItems())->getVolumeInfo();
return [
'title' => $volume->getTitle(),
'authors' => $volume->getAuthors()
];
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace App\Services\BookInformation;
use Exception;
class LookupException extends Exception {
}