Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

An iterator for paginated ResultSet #59

Open
xpavp03 opened this issue Oct 13, 2014 · 1 comment
Open

An iterator for paginated ResultSet #59

xpavp03 opened this issue Oct 13, 2014 · 1 comment

Comments

@xpavp03
Copy link
Contributor

xpavp03 commented Oct 13, 2014

How cool it would be to write this:

$service = new \Ctct\Services\ListService($apiKey);
$resultSet = $service->getContactsFromList($accessToken, $listId, $params);
$iterator = new \Ctct\Util\ResultSetIterator($resultSet);
foreach ($iterator as $contact) {
  print "First name: " . $contact->first_name . "<br>";
}

The iterator would traverse all items, fetching remaining results via the "next" parameter in the background if needed.

This should work for all ResultSets, not only for sets of Contacts.

What do you think? Should be easy to implement. Do you want me to?

@WoogieNoogie
Copy link
Contributor

This would definitely be an interesting way to handle it. I'd love to see what you come up with if you have the time - we wouldn't be able to work on this on our end in the near future.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants