I have some problems with modeling the resources in the domain to match the REST API. The example is clearly contrived and simplified, but it illustrates 2 points where I am stuck.
I know that:
- the user has pets.
- the pet has several names - one for each member of the family
- The pet has: date of birth, date of death and type (dog, cat ...)
- I need to be able to query based on dates (in fact, a date or date range is required when asking about pets). For example: tell me what animals I have now; tell me what kind of pets grandmothers say we had 5 years ago to 3 years ago.
How do I handle dates?
a. in the query line: / pets / dogs / d123? from = 10102010 & to = 10102015 (but, as I understand it, the query string is mainly for optional parameters, as well as the date / date range. I was thinking about having the current date by default if there is nothing in the query string. Any thoughts on this? )
b. somewhere in the way. To / pets? This seems a little strange when I switch between a date and a date range. And my real path has long been long
How do I handle multiple names?
As I see this, I must indicate who uses the name I'm looking for.
/ pets / dogs / rex β I want to know about a dog called rex (by whom, am I or grandmother?). But where to put the grandmother?
I have seen some people say that you donβt have to worry about the url and use hypermedia. But the way I understood that (and this is possible, I was simply mistaken) is that you should always start from the root (here / pets) and follow the links provided in the answer. And then I get stuck even more (as the date makes a really really long list of possibilities).
Any help is appreciated. Thanks
Ana f source share