Returning DTOs from paginated requests #399
pindab0ter
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First of all, thanks for this amazing project. I love the way to abstract away API interactions and make them incredibly friendly to use, especially with the DTOs.
Re #191, I've looked into making this work, and I would like your feedback.
The pagination plugin has functions like
items()
andcollect()
. My thought was to create DTO versionsdtos()
andcollectDtos()
. I had a working prototype up fairly quickly, but ran into the following design problem.The request class implements a function called
createDtoFromResponse
that returns any kind ofobject
, whereas the pagination extension deals with 'items' as members of an array under a key in the response. It's this one/many discrepancy that I would like input on.It makes sense to have the request decide how to transform any individual response into an array of DTOs. I would like
createDtoFromResponse
to be that place, but I don't think it can be, as it returns a singleobject
.The next best thing would be to make an interface with a method
createDtosFromResponse
that returnsobject[]
. I think that creating DTOs out of the data should be the responsibility of theRequest
class.I would like your thoughts @Sammyjo20. As we need this for a project, I would like to collaborate to make this a part of the pagination plugin in a way that suits not only our but most people's needs.
Beta Was this translation helpful? Give feedback.
All reactions