我正在开发一个新的
Android项目,而Retrofit2对我来说效果很好.但是,我需要在我发送的数据之上使用两个字符串中的一个来命中一个网址.
现在它看起来像这样:
@FormUrlEncoded
@POST("token")
Call requestAccess(@Field("grant_type") String type, @Field("code") String authCode, @Field("client_id") String ApiKey);
授权类型只是两件事之一,我想把它抽象成静态网址,如下所示:
@FormUrlEncoded
@POST("token")
@Field("grant_type","type1")
Call requestAccess( @Field("code") String authCode, @Field("client_id") String ApiKey);
@FormUrlEncoded
@POST("token")
@Field("grant_type","type2")
Call refreshAccess( @Field("code") String authCode, @Field("client_id") String ApiKey);
有没有办法实现这个目标?我2天的google-fu没有为我工作,也没有浏览API文档和代码.我只是不想在我的代码中的各个地方跟踪正确的字符串.