Class AbstractClient
java.lang.Object
ai.philterd.philter.AbstractClient
- Direct Known Subclasses:
PhilterClient
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> Texecute(retrofit2.Call<T> call) Executes a call and returns its response body, translating non-successful responses into the appropriate exception.protected voidexecuteVoid(retrofit2.Call<?> call) Executes a call that has no meaningful response body, translating non-successful responses into the appropriate exception.protected RuntimeExceptiontoException(int code) Maps an HTTP status code to a client exception.
-
Field Details
-
UNAUTHORIZED
- See Also:
-
SERVICE_UNAVAILABLE
- See Also:
-
-
Constructor Details
-
AbstractClient
public AbstractClient()
-
-
Method Details
-
execute
Executes a call and returns its response body, translating non-successful responses into the appropriate exception.- Type Parameters:
T- The response body type.- Parameters:
call- TheCallto execute.- Returns:
- The response body.
- Throws:
IOException- Thrown if the request cannot be executed.
-
executeVoid
Executes a call that has no meaningful response body, translating non-successful responses into the appropriate exception.- Parameters:
call- TheCallto execute.- Throws:
IOException- Thrown if the request cannot be executed.
-
toException
Maps an HTTP status code to a client exception.- Parameters:
code- The HTTP status code.- Returns:
- A
RuntimeExceptiondescribing the error.
-