private function retrievePicture($date)
    {
        // Make a request to the API endpoint
        $response = $this->client->request('GET', $this->options['endpoint'], [
            'query' => [
                'api_key'      => $this->options['api_key'],
                'date'         => $date,
                'concept_tags' => 'true',
            ]
        ]);

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

        if (null === $picture) {
            throw new \RuntimeException('Could not decode response as JSON');
        } elseif (isset($picture['error'])) {
            throw new \RuntimeException($picture['error']);
        }

        $paths = $this->getPicturePaths($date);
        file_put_contents($paths['json_path'], (string) $response->getBody());

        if ('image' === $picture['media_type']) {
            try {
                $image = ImageManagerStatic::make($picture['url']);
                $image->fit($this->options['thumbnail_width'], $this->options['thumbnail_height']);
                $image->save($paths['thumbnail_path']);

                $picture['thumbnail_url'] = $paths['thumbnail_url'];
            } catch (\Exception $exception) {
                unlink($paths['json_path']);
                throw $exception;
            }
        }

        return $picture;
    }
private function retrievePicture($date)
    {
        // Make a request to the API endpoint
        $response = $this->client->request('GET', $this->options['endpoint'], [
            'query' => [
                'api_key'      => $this->options['api_key'],
                'date'         => $date,
                'concept_tags' => 'true',
            ]
        ]);

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

        if (null === $picture) {
            throw new \RuntimeException('Could not decode response as JSON');
        } elseif (isset($picture['error'])) {
            throw new \RuntimeException($picture['error']);
        }

        $paths = $this->getPicturePaths($date);
        file_put_contents($paths['json_path'], (string) $response->getBody());

        if ('image' === $picture['media_type']) {
            try {
                $image = ImageManagerStatic::make($picture['url']);
                $image->fit($this->options['thumbnail_width'], $this->options['thumbnail_height']);
                $image->save($paths['thumbnail_path']);

                $picture['thumbnail_url'] = $paths['thumbnail_url'];
            } catch (\Exception $exception) {
                unlink($paths['json_path']);
                throw $exception;
            }
        }

        return $picture;
    }
private function retrievePicture ( $ date ) { // Make a request to the API endpoint $ response = $ this -> client -> request ( 'GET' , $ this -> options [ 'endpoint' ] , [ 'query' => [ 'api_key' => $ this -> options [ 'api_key' ] , 'date' => $ date , 'concept_tags' => 'true' , ] ] ) ; $ picture = json_decode ( ( string ) $ response -> getBody ( ) , true ) ; if ( null === $ picture ) { throw new \ RuntimeException ( 'Could not decode response as JSON' ) ; } elseif ( isset ( $ picture [ 'error' ] ) ) { throw new \ RuntimeException ( $ picture [ 'error' ] ) ; } $ paths = $ this -> getPicturePaths ( $ date ) ; file_put_contents ( $ paths [ 'json_path' ] , ( string ) $ response -> getBody ( ) ) ; if ( 'image' === $ picture [ 'media_type' ] ) { try { $ image = ImageManagerStatic :: make ( $ picture [ 'url' ] ) ; $ image -> fit ( $ this -> options [ 'thumbnail_width' ] , $ this -> options [ 'thumbnail_height' ] ) ; $ image -> save ( $ paths [ 'thumbnail_path' ] ) ; $ picture [ 'thumbnail_url' ] = $ paths [ 'thumbnail_url' ] ; } catch ( \ Exception $ exception ) { unlink ( $ paths [ 'json_path' ] ) ; throw $ exception ; } } return $ picture ; }
Retrieve a picture from the API

@param string $date

@return array

@throws \RuntimeException On failing to retrieve picture
Retrieve a picture from the API