private function getSchema() : Schema { if (null === $this->jsonSchema) { $response = $this->execute($this->api->getImageSchema()); $this->jsonSchema = new Schema(Utils::jsonDecode($response, false)); } return $this->jsonSchema; }
/** * {@inheritDoc} */ public function populateFromResponse(ResponseInterface $response) : self { $entries = Utils::jsonDecode($response)['access']['serviceCatalog']; foreach ($entries as $entry) { $this->entries[] = $this->model(Entry::class, $entry); } return $this; }
/** * Populates the current resource from a response object. * * @param ResponseInterface $response * * @return AbstractResource */ public function populateFromResponse(ResponseInterface $response) : self { if (strpos($response->getHeaderLine('Content-Type'), 'application/json') === 0) { $json = Utils::jsonDecode($response); if (!empty($json)) { $this->populateFromArray(Utils::flattenJson($json, $this->resourceKey)); } } return $this; }
private function fetchResources() { if ($this->shouldNotSendAnotherRequest()) { return false; } $response = call_user_func($this->requestFn, $this->currentMarker); $json = Utils::flattenJson(Utils::jsonDecode($response), $this->resourcesKey); if ($response->getStatusCode() === 204 || empty($json)) { return false; } return $json; }
public function parseMetadata(ResponseInterface $response) : array { $json = Utils::jsonDecode($response); return isset($json['metadata']) ? $json['metadata'] : []; }
public function extractMultipleInstances(ResponseInterface $response, string $key = null) : array { $key = $key ?: $this->getResourcesKey(); $resourcesData = Utils::jsonDecode($response)[$key]; $resources = []; foreach ($resourcesData as $resourceData) { $resources[] = $this->newInstance()->populateFromArray($resourceData); } return $resources; }
public function parseMetadata(ResponseInterface $response) : array { return Utils::jsonDecode($response)['metadata']; }
/** * {@inheritDoc} */ public function populateFromResponse(ResponseInterface $response) : self { $this->populateFromArray(Utils::jsonDecode($response)['access']['token']); return $this; }
/** * @expectedException \InvalidArgumentException */ public function test_decoding_malformed_json_throws_error() { $response = new Response(200, [], \GuzzleHttp\Psr7\stream_for('{')); Utils::jsonDecode($response); }