-
-
Notifications
You must be signed in to change notification settings - Fork 598
Add a ResultPager object to support pagination of all Api's #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The get method always prepends the baseurl before the requests path. A check was added to allow for full URLS (starting with baseurl), for following pagination links.
The api client supports the per_page github parameter for api calls. Default is NULL and lets github decide the default (currently 30). $client->setPerPage()
This is the first pass at adding a paginator class for github API requests. It only works with fetchAll() at the moment, to demonstrate the usage. Currently: $paginator = new \Github\ResultPaginator( \Github\Client [client] ); $paginator->fetchAll( [api], [method], [parameters] ); Todo's include: Paginator is not complete for all possible headers Next, Last, Previous, First apiClient should be able to return a paginator (i.e. $client->getPaginator() ) CacheHttpClient does not work (does not return Link headers)
The get method always prepends the baseurl before the requests path. A check was added to allow for full URLS (starting with baseurl), for following pagination links.
The api client supports the per_page github parameter for api calls. Default is NULL and lets github decide the default (currently 30). $client->setPerPage()
This is the first pass at adding a paginator class for github API requests. It only works with fetchAll() at the moment, to demonstrate the usage. Currently: $paginator = new \Github\ResultPaginator( \Github\Client [client] ); $paginator->fetchAll( [api], [method], [parameters] ); Todo's include: Paginator is not complete for all possible headers Next, Last, Previous, First apiClient should be able to return a paginator (i.e. $client->getPaginator() ) CacheHttpClient does not work (does not return Link headers)
Added UnitTest
$organizationApi = $client->api('organization'); | ||
|
||
$paginator = new Github\ResultPager( $client ); | ||
$result = $paginator->fetchAll( $organizationApi, 'repositories', 'github ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing closing quote
you should update the coding standards to follow PSR-2 |
|
||
Check for pervious page: | ||
```php | ||
$paginator->getPrevious(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasPrevious ?
@stof @docteurklein Thanks very much for the feedback! We'll be fixing all mentioned items in the morning (sorry for the obvious issues) except the ones responded on directly, which could be improved upon by discussion maybe... |
@@ -163,7 +163,9 @@ public function put($path, array $parameters = array(), array $headers = array() | |||
*/ | |||
public function request($path, array $parameters = array(), $httpMethod = 'GET', array $headers = array()) | |||
{ | |||
$path = trim($this->options['base_url'].$path, '/'); | |||
if ( !empty($this->options['base_url']) AND 0 !== strpos( $path, $this->options['base_url'] )) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&&
@cursedcoder @pilot wake up guys, accept some pull requests or deny them.. don't let them catch dust! Doesn't KNPLabs have more collaborators? |
sure you took all comments in consideration ? then, ready to merge. |
@verschoof apply small fix's and it will be merge |
Added spaces after comma in an array
@pilot Alright! Good to merge! |
Add a ResultPager object to support pagination of all Api's
This should fix #55. (close #49, close #53)
The docs have been updated to include a Pagination Support chapter that shows basic usage.