-
Notifications
You must be signed in to change notification settings - Fork 863
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 support for auto pagination #224
Conversation
3d0f1df
to
fa57195
Compare
Aww, looks like I'll see if I can update the PR to make it compatible with PHP 5.3 and 5.4. |
210d0c2
to
9b4a194
Compare
There we go! I replaced the function with |
{ | ||
private $page = null; | ||
private $params = array(); | ||
|
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.
Nitpick, but maybe just clean up the whitespace around these parameters and alphabetized them?
Left a few minor comments, but this looks great! Awesome work @olivierbellone!
Hmm, it probably isn't much better, but do you think it would be better if we moved the request parameters over to I can go either way on that one though.
PHP has every programming language feature ever invented and yield didn't make it until 5.5?! :/ Thanks for updating the implementation though! |
268aa65
to
2affcb0
Compare
@brandur Thanks for the feedback! I updated the PR with your remarks:
|
array('id' => 'foo') | ||
), | ||
'has_more' => true | ||
), new Util\RequestOptions()); |
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.
Hey @olivierbellone! Great fixes. This is looking really good to me.
Sorry to push it, but can I make one more requested it change? It might be advantageous if we could send in an additional request option in the initial collection initialization here, and just verify that it appears in the second request below. This has the advantage of checking that parameters that were given to the original collection will be sent along in subsequent requests as expected.
I remember that I messed up something along these lines in the Java bindings and any additional sanity checks that we can put in would probably be a reasonably good idea.
2affcb0
to
a6f84fc
Compare
@brandur Right, this crossed my mind as well, but I forgot to add a test for it. While testing this I also realized the I'm not too sure how to test this though -- I think it would have to be tested into the request mocker. Thoughts? EDIT: on second thought, I think the getter might be unnecessary and simply not passing an options argument would work equally well. Still not sure how to test it though. EDIT2: okay, I tested it manually and the |
a6f84fc
to
8392fac
Compare
Would it be possible to avoid the getter and just have return new Util\AutoPagingIterator($this, $this->_requestParams); |
8392fac
to
dd6a49e
Compare
Alright, we're getting there. Thanks for bearing with me! :) I added a call to |
Great changes! This is looking really solid now.
I guess I could see it either way. A custom exception is always a little nice because if it does blow up, you get a more helpful message, but on the other hand, we may be planning for a very unlikely contingency here. I'll leave it up to your good judgement :) |
dd6a49e
to
c69db9e
Compare
Alright. Even though this should never happen, I think it's better to break things cleanly with an exception rather than let PHP do whatever PHP does (probably output a notice and go on its merry way, grr). So I added a check that should hopefully be entirely unnecessary :) |
Awesome! Let's try this out. |
Added support for auto pagination
Released in 3.9.0. |
This PR adds support for auto pagination. The following code:
will iterate over all charges. No more need to fiddle with pagination parameters! Yay!
The
autoPagingIterator()
method and its associated tests are basically a port of stripe-python'sauto_paging_iter()
.r? @brandur. I'm not super happy with the
$_lastParams
attribute and accessors I had to add toStripeObject
, maybe there's a better way to retrieve those? Happy to update the PR if so.