I have a REST webservice that have a couple of resources, like Company and User. But now I need to make a modification to the API to return a special list combining company, user and maybe other type of resource. Like a list of recommendations with various type of resources.
Which is the best approach to solve this?
I need to make a new endpoint (resource), something like: /recommendations
? I already have the /company
endpoint, and the /user
endpoint returning the corresponding objects. This is fine. But now I need some way to return an array with a combination of users and companies.
Also I'm thinking that the json will look like an array of objects, but how the client can know which type of object is parsing if every object in the array is a different resource?
EDIT
I want that my client could show a recomendations screen in the app. The problem is that this list can combine multiple types of data (users, companies). It doesn't matter if this resources have a relationship or not. The client shoud recive a json like that:
"recomendations": [
{
"id_user": 1
"name": "Jean"
...
},
{
"id_company": 2
"name": "Starbucks"
...
},
...
]