Dynamically add optional parameters to API requests

Viewed 20455

I have an Android app that communicates with a REST API.

For each request, I want my app to be able to add optional parameters in addition to the mandatory parameters.

How can I implement this with Retrofit? Currently all the parameters are hard-coded in the interface:

@GET("/user/{id}/comments?position={pos}")  
void getComments(@Path("id") int id, @Query("pos") int pos, Callback<String> cb);

@GET("/user/{id}/likes?n={number}")  
void getLikes(@Path("id") int id, @Query("number") int number, Callback<String> cb);

/* etc */

Is it possible to "sub-class" the RestAdapter or something to be able to dynamically add optional parameters to my requests?

2 Answers
Related