I'm using ServiceStack for creating my first API. In my service the user can enter new orders and retrieve those he has already executed. Each order has a very complex structure made up of various fields and lists of objects (some of which consist of 10 or 100 items, other consiste of thousands of records which therefore require paging).
The question is: what and how much data to send to the client.
Hypothetically, when the client requests the list of last executed orders I should provide a list of orders with few fields.
When the client instead requests the detail of the order I could give him more information.
In the REST world I saw 2 techniques:
[view] parameter
/orders?view=list
/orders?view=detail
which can be "list | detail" which provides a more succinct or more detailed version of the requested object.
[expand] parameter
/orders?expand=customer
/orders?expand=customer,address,phones,address
that allows specifying which fields to retrieve
In this way, whether the user requests a list of objects or the detail he can specify the amount of information he want to receive.
This solution is adopted by Stripe.com that provide also a c# client.
https://github.com/stripe/stripe-dotnet/blob/master/src/Stripe.net/Entities/ExpandableField.cs
How can these solutions be implemented with ServiceStack and in particular with the fact that the same api can be used both via http and via ServiceStack.Client?
Can it be a good idea to create two types of DTOs?
OrderDTO (containing few fields)
OrderDetailDTO (containing all the fields)