Ejemplo n.º 1
0
 protected function post($url, $payload = [])
 {
     if (!$this->client) {
         throw new \RuntimeException(vsprintf('Did you forget to pass the http-client in the constructor of %s?', get_class($this)));
     }
     $request = $this->client->post($url, null, json_encode($payload));
     $response = $this->sendRequest($request);
     return ResponseDecoder::decode($response);
 }
Ejemplo n.º 2
0
 public function loadNext()
 {
     if (!$this->nextRequest instanceof RequestInterface) {
         return;
     }
     $response = $this->nextRequest->send();
     foreach (call_user_func($this->transformer, ResponseDecoder::decode($response), $this->client) as $data) {
         $this->storage[] = $data;
     }
     $linkHeader = $response->getHeader('Link');
     if ($linkHeader) {
         $this->nextRequest = $this->client->get($response->getHeader('Link')->getLink('next')['url']);
     } else {
         $this->nextRequest = null;
     }
 }