Ofir Bar02/12/2020, 6:13 PM
However, I know, for sure, that whenever making a network request to our backend, some network responses will send back a
/** * A class wrapping every network response */ data class NetworkResponse<T>(@SerializedName("code") val code: Int, @SerializedName("message") val message: String, @SerializedName("data") val data: T)
. So then
cannot be inferred. For example, when we Patch a User data, I receive code 200 OK, but
object returned is null (no data returned back is expected). Here is the network request using retrofit:
I am not sure what type to set for NetworkRequest in this case. I need to give some object to the NetworkResponse, but don’t want to just put something ugly and unrelated like “String?“. What can be done?
@PATCH("user") suspend fun updateUserBasicDetails(@Body basicDetailsBasicDetailsRequest: UserBasicDetailsRequest) : NetworkResponse<WHAT_TO_DO_HERE?>
aipok02/12/2020, 7:23 PM
pt02/12/2020, 7:24 PM
. I’m a little confused by the question though, what do you mean by “T cannot be inferred”?