Skip to content
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

Added some pagination examples #141

Merged
merged 5 commits into from May 1, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

Added some pagination examples

  • Loading branch information...
bkuhl committed May 1, 2019
commit e3abdf38aceabd239a02e8e8a69645779db803b8
@@ -856,6 +856,11 @@ $lastUsers = $users->getLastPage();
// Load a specific page
$otherUsers = $users->getPage(12);
// Paged results are accessible as normal arrays, so you can simply iterate over them
foreach ($otherUsers as $user) {
echo $user->getFirstName();
}
```

## Testing
@@ -25,9 +25,14 @@
// List customers
$customers = $client->customers()
->list()
->getFirstPage()
->toArray();
->list();
echo 'There are '.$customers->getTotalPageCount().' page(s) of results'.PHP_EOL;
// show the first name of the customers on the first page of results
foreach($customers->getFirstPage() as $customer) {
echo $customer->getFirstName().PHP_EOL;
}
$filters = (new CustomerFilters())
->withFirstName('John')
@@ -39,4 +44,4 @@
->withSortField('createdAt')
->withSortOrder('asc');
$customers = $client->customers()->list($filters);
$customers = $client->customers()->list($filters);
@@ -0,0 +1,23 @@
<?php
require __DIR__ . '/../vendor/autoload.php';
require '_credentials.php';
use HelpScout\Api\ApiClientFactory;
use HelpScout\Api\Customers\CustomerFilters;
use HelpScout\Api\Customers\Customer;
use HelpScout\Api\Customers\Entry\Email;
$client = ApiClientFactory::createClient();
$client = $client->useClientCredentials($appId, $appSecret);
// GET mailbox
$mailbox = $client->mailboxes()->get(4938);
// List mailboxes
$mailboxes = $client->mailboxes()
->list();
// show the name of the mailboxes on the first page of results
foreach($mailboxes->getFirstPage() as $mailbox) {
echo $mailbox->getName().PHP_EOL;
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.