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

Account list not paging correctly #99

Closed
emycakes opened this issue Aug 11, 2014 · 3 comments
Closed

Account list not paging correctly #99

emycakes opened this issue Aug 11, 2014 · 3 comments
Labels
V2 V2 Client

Comments

@emycakes
Copy link

Docs state that the maximum amount of results retrieved is 200 and the default is 50.
following test code retrieved 358 results and completely ignores any query parameters I try to set

    include('../lib/recurly.php');

    Recurly_Client::$subdomain = '#####';
    Recurly_Client::$apiKey = '#####';

    $accounts = Recurly_AccountList::get(array('per_page' => 25));

    foreach($accounts as $account){
        echo $account->first_name,' ',$account->last_name,"\n";
    }
@drewish
Copy link

drewish commented Aug 11, 2014

The variable you named $accounts is really a pager object that implements the Iterator interface and will make multiple requests. So it's probably going through all your accounts. I what parameters beside page size have you tried?

@emycakes
Copy link
Author

I've also used state parameter but other than that there isn't much else I can use afaik (https://docs.recurly.com/api/accounts)

Atm my solution to this to hard limit the loop count though this doesn't solve an issue I have with pagination

while( $this->accounts->valid() && $this->accounts->key() < $this->per_page ){
    $account = $this->accounts->current();
    echo $account->first_name, ' ', $account->last_name;
    $this->accounts->next();
}

@emycakes
Copy link
Author

A quick and filthy fix was to add a method to return the retrieved objects and expose the cursor in order to make manual paged requests using a cursor parameter. Too bad there isn't a simple offset parameter available to easy pagination

@bhelx bhelx added the V2 V2 Client label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V2 V2 Client
Projects
None yet
Development

No branches or pull requests

3 participants