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

Paged requests #74

Open
Pedroalexandrelopes opened this issue Jan 2, 2018 · 2 comments
Open

Paged requests #74

Pedroalexandrelopes opened this issue Jan 2, 2018 · 2 comments

Comments

@Pedroalexandrelopes
Copy link

Hi,
I'm using Retrofit to make paged requests. I need to be able to get paging attributes contained in meta.

The retrofit interface has a call like this:

@GET("appointments?include=service") Call<List<Appointment>> getBusinessAppointments(@HeaderMap Map<String, String> headers, @Query("filter[businessId]") String businessId, @QueryMap Map<String, String> options);

When making the call, I receive the Appointments list but no way of getting the attributes of meta.
The response has this format:

{"data":[...],"included":[...],"meta":{"page":{"page":1,"total-entries":10,"total-pages":1,"number":2,"size":30}}}

Is there any way of getting the 'total-entries' and 'size' params?

@kamikat
Copy link
Owner

kamikat commented Feb 8, 2018

The getMeta() returns a JsonBuffer object (https://github.com/kamikat/moshi-jsonapi#metalinksjsonapi-properties). There you can create a JsonAdapter as is described in https://github.com/square/moshi and pass it to JsonBuffer.get to get the object.

@sterien7
Copy link

sterien7 commented Sep 9, 2022

@kamikat how can you getMeta on the Document rather than each Object? As long as in this example the result is List

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

3 participants