public class ApiConnection
Class that allows interaction with the hk-tippspiel API
Modifier and Type | Class and Description |
---|---|
static class |
ApiConnection.Companion
Contains static methods of the class
|
Modifier and Type | Field and Description |
---|---|
static ApiConnection.Companion |
Companion
Contains static methods of the class
|
Constructor and Description |
---|
ApiConnection(java.lang.String serverUrl,
java.lang.String apiKey,
User user,
int expiration)
Class that allows interaction with the hk-tippspiel API
|
Modifier and Type | Method and Description |
---|---|
org.json.JSONObject |
get(java.lang.String endpoint,
java.util.Map<java.lang.String,? extends java.lang.Object> params)
Performs an authenticated GET request to the API
|
int |
getExpiration()
:
|
User |
getUser() |
boolean |
isAuthorized()
Checks if the ApiConnection is authorized or not
|
void |
logout(BaseActivity context)
Logs out by deleting the API key
|
org.json.JSONObject |
put(java.lang.String endpoint,
java.util.Map<java.lang.String,? extends java.lang.Object> params)
Performs an authenticated PUT request to the API
|
void |
store(BaseActivity context)
Stores the API Connection info in the shared preferences
|
public static ApiConnection.Companion Companion
Contains static methods of the class
public ApiConnection(java.lang.String serverUrl, java.lang.String apiKey, User user, int expiration)
Class that allows interaction with the hk-tippspiel API
serverUrl
- : The server URL to useapiKey
- : The API key to use for authenticationexpiration
- : The expiration time of the API keyserverUrl
- : The server URL to useapiKey
- : The API key to use for authenticationexpiration
- : The expiration time of the API keypublic boolean isAuthorized()
Checks if the ApiConnection is authorized or not
public void logout(BaseActivity context)
Logs out by deleting the API key
context
- : If provided, deletes the API key information from the shared preferencespublic void store(BaseActivity context)
Stores the API Connection info in the shared preferences
context
- : The context from which to load the shared preferencespublic org.json.JSONObject get(java.lang.String endpoint, java.util.Map<java.lang.String,? extends java.lang.Object> params)
Performs an authenticated GET request to the API
endpoint
- : The API endpoint to connect toparams
- : The parameters to sendpublic org.json.JSONObject put(java.lang.String endpoint, java.util.Map<java.lang.String,? extends java.lang.Object> params)
Performs an authenticated PUT request to the API
endpoint
- : The API endpoint to connect toparams
- : The parameters to sendpublic User getUser()
public int getExpiration()
:
The expiration time of the API key