public function forISBN($isbn)
    {
        if (!$this->isValidISBN($isbn)) {
            throw new InvalidArgumentException('ISBN is not valid. Got: '.$isbn);
        }

        // Example: https://www.googleapis.com/books/v1/volumes?q=isbn:9780525953739
        $response = $this->client->request('GET', 'volumes', [
            'query'       => ['q' => 'isbn:'.$isbn],
            'http_errors' => false,
        ]);

        $status = $response->getStatusCode();
        if ($status != 200) {
            throw new InvalidResponseException('Invalid response. Status: '.$status.'. Body: '.$response->getBody());
        }

        $res = json_decode($response->getBody(), true);

        $totalItems = intval($res['totalItems']);
        if ($totalItems != 1) {
            throw new InvalidResponseException('Did not get 1 result. Got: '.$totalItems);
        }

        return $this->extractBook($res);
    }
public function forISBN($isbn)
    {
        if (!$this->isValidISBN($isbn)) {
            throw new InvalidArgumentException('ISBN is not valid. Got: '.$isbn);
        }

        // Example: https://www.googleapis.com/books/v1/volumes?q=isbn:9780525953739
        $response = $this->client->request('GET', 'volumes', [
            'query'       => ['q' => 'isbn:'.$isbn],
            'http_errors' => false,
        ]);

        $status = $response->getStatusCode();
        if ($status != 200) {
            throw new InvalidResponseException('Invalid response. Status: '.$status.'. Body: '.$response->getBody());
        }

        $res = json_decode($response->getBody(), true);

        $totalItems = intval($res['totalItems']);
        if ($totalItems != 1) {
            throw new InvalidResponseException('Did not get 1 result. Got: '.$totalItems);
        }

        return $this->extractBook($res);
    }
public function forISBN ( $ isbn ) { if ( ! $ this -> isValidISBN ( $ isbn ) ) { throw new InvalidArgumentException ( 'ISBN is not valid. Got: ' . $ isbn ) ; } // Example: https://www.googleapis.com/books/v1/volumes?q=isbn:9780525953739 $ response = $ this -> client -> request ( 'GET' , 'volumes' , [ 'query' => [ 'q' => 'isbn:' . $ isbn ] , 'http_errors' => false , ] ) ; $ status = $ response -> getStatusCode ( ) ; if ( $ status != 200 ) { throw new InvalidResponseException ( 'Invalid response. Status: ' . $ status . '. Body: ' . $ response -> getBody ( ) ) ; } $ res = json_decode ( $ response -> getBody ( ) , true ) ; $ totalItems = intval ( $ res [ 'totalItems' ] ) ; if ( $ totalItems != 1 ) { throw new InvalidResponseException ( 'Did not get 1 result. Got: ' . $ totalItems ) ; } return $ this -> extractBook ( $ res ) ; }
Retrieve information about a book given its ISBN.

@param string $isbn

@throws InvalidArgumentException When the ISBN has not the expected format
@throws InvalidResponseException When the client got an unexpected response

@return Book
Retrieve information about a book given its ISBN .