简体   繁体   English

如何使用改型为呼叫和响应设置不同的模型

[英]How can i set different model for call and response using retrofit

is it possible to set two models for retrofit POST? 是否可以设置两个用于POST改造的模型? i want to set the first model that use Call POST to send json data and another model that handle the response from the server 我想设置使用Call POST发送json数据的第一个模型和处理服务器响应的另一个模型

To get to differents objects is pretty much straight foward: 寻求不同的对象是非常直接的:

@POST("yourMagicURL")
fun login(@Body loginRequest: User): Call<UserStatusResponse>

Where User is the object that contains: fname, lname, email and UserStatusResponse is the object that contains status, message 其中User是包含以下内容的对象:fname,lname,email和UserStatusResponse是包含状态,消息的对象

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Retrofit ZE84E30B9390CDB64DB6ZDB2CAB9DZ 本身在 model class 中自定义实际响应 - How can I customise the actual response in model class itself using Retrofit Android? 我无法在使用 android 中使用 java 的改造 2 中收到呼叫响应无法解析 model - I cannot receive response in call using retrofit2 using java in android cannot parse response in model 如何使用Retrofit android设置工具栏标题? - How can i set Toolbar title using Retrofit android? 使用Retrofit2拨打电话时未收到任何回应 - Receiving no response when I do a call using retrofit2 改造不同的调用和响应 json 主体 - Retrofit different call and response json bodies 我如何处理改造的响应(这里我的响应没有显示数据,它只显示调用的代码和状态) - How can I handle the response from the retrofit (Here my response not showing the data, it only shows the code and status of the call) 如何在 OnResponse function 之外使用 Retrofit 响应,以便将其返回到推荐的架构 model? - How can I use the Retrofit response outside the OnResponse function so I can return it up the recommended architecture model? 如何在 RestApi 调用中设置多个响应类型 - How can i set multiple response type in RestApi call 我如何使用 retrofit 从我的 api 通话中获得此 Object - How can i get this Object from my api call am using retrofit 如何使用Retrofit和RxJava / RxAndroid处理响应错误? - How do I handle response errors using with Retrofit and RxJava/RxAndroid?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM