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

The device_tokens API method no longer returns the current or total pages #1

Open
pr1001 opened this issue Apr 25, 2012 · 8 comments
Open

Comments

@pr1001
Copy link
Member

pr1001 commented Apr 25, 2012

The documentation is wrong: current_page and num_pages are no longer returned in the response JSON object. Check to see if the API is paged anymore.

@robotadam
Copy link

The API is paged; but current_page and num_pages are no longer available. Instead of using a naive page/offset method we switched it to start after the last device token returned in the previous page, which is lighter on our db. As long as the next url exists, keep reading there.

@pr1001
Copy link
Member Author

pr1001 commented Apr 25, 2012

Thanks, Adam. So that means I should keep requesting pages until I get an empty response?

@robotadam
Copy link

Yes, that's correct. The last page should have no next page value, so you can stop there.

@pr1001
Copy link
Member Author

pr1001 commented Apr 25, 2012

Sorry, but isn't there is no 'next page' value ever?

Put simply, I'm seeing JSON objects in the format:

{
  device_tokens: [...],
  device_tokens_count: X,
  active_device_tokens_count: Y
}

@robotadam
Copy link

That should only happen if there are no more pages. Try appending "?limit=10" to the request to force a smaller amount; you should have the same device_tokens_count, but only 10 tokens in the list and a next_page.

@pr1001
Copy link
Member Author

pr1001 commented Apr 25, 2012

Ahh, you're right. Annoying that fields like that are only present in the response object depending on what query params you use...

Anyway, thanks, that's enough for me to work with.

@robotadam
Copy link

Well, it's not that it's based on what query params you use, but on whether the data exists at all. So the option was between returning "next_page": null or not including next_page at all. The limit query just changes how many are in each page.

Hope that makes it more clear.

@pr1001
Copy link
Member Author

pr1001 commented Apr 25, 2012

Yep, but that's what I'd prefer: "next_page": null ;-)

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

No branches or pull requests

2 participants