public abstract class Request<T>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Request.ConnectionRestriction |
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
ACCESS_TOKEN |
protected static java.lang.String |
AUTHORIZATION |
protected static java.lang.String |
CONTENT_TYPE |
protected boolean |
isMultipartRequest |
protected static MediaType |
MEDIA_TYPE |
protected OkHttpClient |
mHttpClient |
protected static MediaType |
MULTIPART_MEDIA_TYPE |
protected static IUserService |
mUserService |
protected static RestConfiguration |
sConfiguration |
| Modifier | Constructor and Description |
|---|---|
protected |
Request() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkConnectionRestrictions(Request<T> request) |
protected void |
checkTokenValidity()
Metoda jest wykonywana dla Requestów implementujących interfejs TokenRequest.
|
protected java.util.concurrent.Callable<T> |
createRequestTask()
Utworzenie nowego zadania dla zapytania
|
RequestFuture<T> |
execute()
Metoda uruchamiająca wykonywanie zapytania
|
RequestFuture<T> |
execute(RequestListener<T> listener)
Metoda uruchamiająca wykonywanie zapytania, po zakończeniu uruchamiana jest metoda listenera
|
protected java.lang.Class<T> |
getParameterClass()
metoda zwracająca classę obiektu oczekiwanego w odpowiedzi
|
protected <any> |
getParameterType()
Metoda zwracająca typ obiektu zwracanego, jeśli metoda nie została przeciążona to zwraca null
|
protected RequestBody |
getRequestBody()
metoda zwracająca body zapytania zawierające
parameters |
protected HttpUrl |
getUrl()
Metoda zwraca kompletny adres url do metody api.
|
protected boolean |
isTokenRequest()
Sprawdzenie czy zapytanie wymaga autoryzacji przy użyciu tokena
|
protected java.lang.String |
obtainStringValue(java.lang.Object value) |
protected T |
parseToObject(java.lang.String content) |
protected abstract void |
prepareRequest()
Metoda, w której powinna byc wykonana konfiguracja zapytania.
|
protected void |
putParameter(java.lang.Object value) |
protected void |
putParameter(java.lang.String parameter,
java.lang.Object value) |
protected void |
putUrlParameter(java.lang.Object value) |
protected void |
putUrlParameter(java.lang.String parameter,
java.lang.Object value) |
protected T |
readResponse(Response response) |
protected abstract Response |
request()
Metoda zwracająca wynik zapytania api
|
static void |
setRestConfiguration(RestConfiguration credentials) |
protected void |
setUrlSegments(java.lang.String... urlSegments)
Ustawienie adresu api
|
static void |
setUserService(IUserService userService) |
protected java.lang.String[] |
toObject(java.lang.String... names) |
protected static final java.lang.String CONTENT_TYPE
protected static final MediaType MEDIA_TYPE
protected static final MediaType MULTIPART_MEDIA_TYPE
protected static final java.lang.String ACCESS_TOKEN
protected static final java.lang.String AUTHORIZATION
protected static IUserService mUserService
protected static RestConfiguration sConfiguration
protected OkHttpClient mHttpClient
protected boolean isMultipartRequest
public static void setUserService(IUserService userService)
public static void setRestConfiguration(RestConfiguration credentials)
public RequestFuture<T> execute()
public RequestFuture<T> execute(RequestListener<T> listener)
protected java.util.concurrent.Callable<T> createRequestTask()
protected T readResponse(Response response) throws java.lang.Exception
java.lang.Exceptionprotected T parseToObject(java.lang.String content) throws java.lang.Exception
java.lang.Exceptionprotected void checkConnectionRestrictions(Request<T> request) throws ConnectionRestrictionFailedException
protected <any> getParameterType()
protected java.lang.Class<T> getParameterClass()
protected boolean isTokenRequest()
protected void checkTokenValidity()
throws RefreshTokenException
RefreshTokenExceptionprotected abstract void prepareRequest()
protected abstract Response request()
throws java.io.IOException
java.io.IOExceptionprotected HttpUrl getUrl()
putUrlParameter(String, Object)protected void setUrlSegments(java.lang.String... urlSegments)
urlSegments - elementy ścieżki url do odpowiedniej metody api np.: getUrlBuilder("get", "user");protected void putUrlParameter(java.lang.String parameter,
java.lang.Object value)
protected void putUrlParameter(java.lang.Object value)
protected void putParameter(java.lang.String parameter,
java.lang.Object value)
protected void putParameter(java.lang.Object value)
protected java.lang.String[] toObject(java.lang.String... names)
protected RequestBody getRequestBody()
throws JsonProcessingException
parametersJsonProcessingExceptionprotected java.lang.String obtainStringValue(java.lang.Object value)