Hi,
We have come across situations where we have two screens where most of fields are same but in two situations.
E.g a) we search for junctions and it shows list of junctions with some commercial break availability time.
We have another situation b) where we show specific information for a junction and some additional fields e.g trailAvailability (but not commercial break).
We have an endpoint /junctions/searchResults (POST) that also accepts junction ids as well as search params (e.g date, time etc.).
So for option a) we use end point
POST - /junctions/search (with search params) and another one that gives trail info e.g /trailInfo.
and club (?) the result
POST - /junctions/search (with junction id) and get rest of information from /commercialbreak
and again club the result
I have a doubt shall I use two endpoints here that will aggregate results based on requirement
e.g GET /junctions with query params for search criteria (Use 1 above)
{
“junctions”:[{
“junctionid”":
“trailAvailability”:“”
}]
}
In this case it is junctions but it has some break information
and GET /junctions/{junctionid} (from 2 above)
{
“junctionid”":
“commercialBreakAvailability”:“”
}]
Or a single endpoint that can operate with flag isTrailReq and isCommercialBreak required.
With some response as below
Response-
{
"junctions":[{
"junctionid" : "",
"trailAvailability":"",
"commercialBreakAvailability":""
}]
}
In case if a user doesn’t need trail information than it may be -1 or 0. Removing a field may break contract.
To sum up I want to know the public facing API’s is it ok to expose per screen basis. Also, a naming convention such as /junction/{junctionId}/withTrailInfo is it OK as per rest principles.
thanks