/** * Advance to the next page. * * @return \Tev\Bs\Utils\Paginator This, for chaining * * @throws \Exception * @throws \Tev\Bs\Exception\ErrorResponseException */ private function advance() { if ($this->currentPage() === 0 || $this->hasNextPage()) { $this->page = $this->client->request($this->endpoint->setParam('page', $this->currentPage() + 1)); } else { $this->finished = true; } return $this; }
/** * Make an API request. * * @param \Tev\Bs\Contracts\EndpointInterface $endpoint Requesting endpoint * @return \Tev\Bs\Contracts\ResponseInterface Response * * @throws \Exception * @throws \Tev\Bs\Exception\ErrorResponseException */ public function request(EndpointInterface $endpoint) { if ($this->customerId !== null) { $endpoint->setParam('customer_id', $this->customerId); } // Request $request = new Request($endpoint->getMethod(), $endpoint->getUrl(), $this->host); $request->setContent($endpoint->getContent()); // Response $response = new Response(); // Authorisation $listener = new BasicAuthListener($this->clientId, $this->clientSecret); $listener->preSend($request); // Send $client = new Curl(); $client->setTimeout(30); $client->send($request, $response); // Parse $parser = new Parser($response, $endpoint); return $parser->getResponse(); }