function createClientObject($uri, $args = null) { $client = new self($this->http_client); $client->uri = $uri; /* this is to append resource name to url function call- $client->users('laravel') format like this github.com/users/laravel */ $client->appendResourceNameToURLIfGiven($args); //$uri = $this->prepareURI($method,$args); $client->sendRequest($client->uri); // throws exception //$this->validateLastRequestStatus(); $client->uri = $uri; //$client->response = $this->response; $client->header_links = $client->extractLinkHeaderFromResponse(); // this is to store like array of arrays for /users $client->collection = array_merge($client->collection, $client->extractBodyFromResponse()); return $client; }