createFromJson() public static method

Creates a new instance of :php:class:Response from a JSON-decoded response body.
public static createFromJson ( array $response ) : static
$response array
return static
Example #1
0
 /**
  * {@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));
 }
Example #2
0
 /**
  * {@inheritDoc}
  */
 public function request($method, $uri, array $parameters = [])
 {
     $file = file_get_contents($this->mapRequestToFile($method, $uri, $parameters));
     return Response::createFromJson(json_decode($file, true));
 }