Skip to content

Commit

Permalink
Doc PaginationIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
ecoologic committed Nov 14, 2023
1 parent 5f07e05 commit 339610d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/Zendesk/API/Traits/Utility/Pagination/AbstractStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,21 @@ public function params()
return $this->params;
}

/**
* Returns the latest HTTP response, unless an error occurred, which causes an exception
*
* @return \GuzzleHttp\Psr7\Response
*/
public function latestResponse()
{
return $this->latestResponse;
}

/**
* From the params or the default value
*
* @return integer
*/
protected function pageSize()
{
if (isset($this->pageSize)) {
Expand Down
15 changes: 11 additions & 4 deletions src/Zendesk/API/Traits/Utility/Pagination/PaginationIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@

class PaginationIterator implements Iterator
{
/**
* @var mixed using trait FindAll. The object handling the list, Ie: `$client->{clientList}()`
* Eg: `$client->tickets()` which uses FindAll
*/
private $clientList;
private $strategy;
private $method;
private $position = 0;
private $items = [];

/**
*
* @param mixed using trait FindAll. The resources collection, Eg: `$client->tickets()` which uses FindAll
* @param AbstractStrategy $strategy For pagination Logic (OBP, CBP, SinglePage)
* @param string $method used to make the API call
*/
public function __construct($clientList, AbstractStrategy $strategy, $method = 'findAll')
{
$this->clientList = $clientList;
Expand Down Expand Up @@ -55,6 +57,11 @@ public function current()
}
}

/**
* Returns the latest HTTP response, unless an error occurred, which causes an exception
*
* @return \GuzzleHttp\Psr7\Response
*/
public function latestResponse()
{
return $this->strategy->latestResponse();
Expand Down

0 comments on commit 339610d

Please sign in to comment.