I have an API that returns the network status and I want to add retry and cancel function for the API call
@GET("{path1}/{path2}")
suspend fun status(
@HeaderMap headers: Map<String, String>
): Status?
This is the service class from where the API is called
override suspend fun status(): Status? =
service.status(
path1 = PATH_ONE,
path2 = PATH_TWO,
headers = mapOf(
USER_AGENT to userAgent,
ACCEPT to accept,
ACCEPT_LANGUAGE to locale,
X_APP_GUID to xAppGuid
)
)
The issue that I am facing is that to use the retrofit2.enqueue() and retrofit2.cancel() functions I need to change the return type of the status() function to Call, but then I face the issue that I cannot return that to the user, because Call() is an interface and cannot instantiated, and I need to return the actual status.
Does anyone have any clue how to do it?