public abstract class AbstractClient extends Object
Abstract class which specifies how clients should operate.
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractClient()
Default constructor.
|
protected |
AbstractClient(Locale locale)
Overloaded constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
doGetRequest(String url)
Performs a GET request to the specified URL.
|
protected String |
doPostRequest(String url,
String query)
Performs a POST request to the specified URL.
|
Locale |
getLocale()
Retrieves the
Locale for this client instance. |
Locale |
getLocalizationLocale()
Returns the
Locale used for the localization. |
protected String |
getRootUrl()
Determines the URL for the API based on the current
Locale. |
abstract String |
getUrl()
Returns the URL endpoint which this client represents.
|
void |
setLocale(Locale locale)
Sets the
Locale for this client instance. |
void |
setLocalizationLocale(Locale loc)
Changes the
Locale used for the localization. |
protected AbstractClient()
Default constructor.
protected AbstractClient(Locale locale)
Overloaded constructor.
locale - the Locale for this clientpublic Locale getLocale()
Retrieves the Locale for this client instance.
Locale for this client instancepublic void setLocale(Locale locale)
Sets the Locale for this client instance. Note that doing this
after a call to setLocalizationLocale(Locale) overwrites the localization
language with the input of this method.
locale - the Locale for this clientpublic Locale getLocalizationLocale()
Returns the Locale used for the localization.
Locale for the localizationpublic void setLocalizationLocale(Locale loc)
Changes the Locale used for the localization. Useful if the client
needs to be in a different language than the error messages.
loc - the Locale for the localizationprotected String getRootUrl()
Determines the URL for the API based on the current Locale.
protected String doGetRequest(String url)
Performs a GET request to the specified URL.
url - the URL which will be sent a GET requestprotected String doPostRequest(String url, String query)
Performs a POST request to the specified URL.
url - the URL which will be sent a POST requestquery - the query which the API will processpublic abstract String getUrl()
Returns the URL endpoint which this client represents.
Copyright © 2017. All rights reserved.