I have an API endpoint that is defined as:
GET https://api-server.com/something/{id_or_ids}
where idscan be the identifier of one object or a comma-separated list of identifiers .
eg,
https://api-server.com/something/abcd1234
https://api-server.com/something/abcd1234,abcd4567,gdht64332
if one id is given (and the corresponding object is found), I return a json object :
{ "blah" : "blah" }
If multiple identifiers are specified , I get a response in the json array :
[{"blah1":"bleh"}, {"blah2":"meh"}, {"blah3":"blah"}]
I now think that I should implement this as two methods (can this be done in one?):
which takes one id and returns one object:
@GET("/something/{id}")
void getObject (@Path("id") String objectId, Callback<MyObject> callback)
and
which takes multiple identifiers and returns an array of objects.
@GET("/something/{ids}")
void getObject (Callback<MyObject[]> callback,@Path("ids") String ... objectIds)
varargs id?