/** * 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; }