public static createFromJson ( array $response ) : static | ||
$response | array | |
return | static |
public static function createFromJson(array $response)
{
$meta = array_key_exists('meta', $response) ? $response['meta'] : ['code' => 200];
$data = array_key_exists('data', $response) ? $response['data'] : $response;
$pagination = array_key_exists('pagination', $response) ? $response['pagination'] : [];
return new static($meta, $data, $pagination);
}
/** * {@inheritDoc} */ public function request($method, $uri, array $parameters = []) { try { $response = $this->guzzle->request($method, $uri, $parameters); } catch (ClientException $e) { if (!$e->hasResponse()) { throw $e; } throw $this->resolveExceptionClass($e); } catch (Exception $e) { throw $e; } return Response::createFromJson(json_decode($response->getBody()->getContents(), true)); }