public abstract class BreinBase<T extends BreinBase> extends java.lang.Object implements ISecretStrategy
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
API_KEY_FIELD |
static com.google.gson.Gson |
GSON
Builder for JSON creation
|
static java.lang.String |
IP_ADDRESS |
static java.lang.String |
SIGNATURE_FIELD |
static java.lang.String |
SIGNATURE_TYPE_FIELD |
static java.lang.String |
UNIX_TIMESTAMP_FIELD |
| Constructor and Description |
|---|
BreinBase() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getClientIpAddress() |
abstract java.lang.String |
getEndPoint(BreinConfig config)
Gets the endpoint to be used to send the request to
|
com.google.gson.Gson |
getGson()
Gets the GSON builder instance used to build the requests body
|
java.util.Map<java.lang.String,java.lang.String> |
getHeaders() |
protected T |
getThis() |
long |
getUnixTimestamp()
Retrieves the currently set
unixTimestamp. |
BreinUser |
getUser()
Retrieves the current
BreinUser for the request. |
java.lang.String |
prepareRequestData(BreinConfig config)
Method to generate the body part of the request.
|
abstract void |
prepareRequestData(BreinConfig config,
java.util.Map<java.lang.String,java.lang.Object> requestData)
This method adds the request specific information to the
requestData. |
T |
set(java.lang.String key,
java.lang.Object value)
Sets a base value.
|
T |
setAdditional(java.lang.String key,
java.lang.Object value)
Sets a specific data point for the additional part of the request, i.e.:
|
T |
setClientIpAddress(java.lang.String ipAddress)
sets the ipaddress
|
T |
setHeader(java.lang.String key,
java.lang.String value) |
T |
setHeaders(java.util.Map<java.lang.String,java.lang.String> headers) |
T |
setUnixTimestamp(long unixTimestamp)
Sets the timestamp.
|
T |
setUser(BreinUser.UserField key,
java.lang.Object value)
Sets a specific data point for the user data of the request, i.e.:
|
T |
setUser(BreinUser user)
Sets the
BreinUser instance for the request. |
T |
setUser(java.lang.String key,
java.lang.Object value)
Sets a specific data point for the user data of the request, i.e.:
|
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcreateSignaturepublic static final java.lang.String API_KEY_FIELD
public static final java.lang.String UNIX_TIMESTAMP_FIELD
public static final java.lang.String IP_ADDRESS
public static final java.lang.String SIGNATURE_FIELD
public static final java.lang.String SIGNATURE_TYPE_FIELD
public static final com.google.gson.Gson GSON
public BreinUser getUser()
BreinUser for the request. This method never returns null, instead it
creates an empty BreinUser instance if none is available so far.BreinUser for the requestpublic T setUser(BreinUser user)
BreinUser instance for the request. It is recommended to get the user (using getUser())
and manipulate the retrieved instance directly or to use the setUser(key, value) method to set user
specific data.user - the BreinUser to setthisBreinUserpublic T setUser(java.lang.String key, java.lang.Object value)
{
user: {
'key': 'value'
}
}
Typically, that would be, e.g., email,
sessionId, and/or userId
key - the value to be set (e.g., "email" or "sessionId")value - the value to be set for the specified keythispublic T setUser(BreinUser.UserField key, java.lang.Object value)
{
user: {
'key': 'value'
}
}
Typically, that would be, e.g., email,
sessionId, and/or userId
key - the value to be set (e.g., UserField.EMAIL)value - the value to be set for the specified keythisBreinUser.UserFieldpublic T setAdditional(java.lang.String key, java.lang.Object value)
{
user: {
additional: {
'key': 'value'
}
}
}
key - the value to be set (e.g., "localDateTime", "userAgent", "referrer" or
"timezone")value - the value to be set for the specified keythispublic abstract java.lang.String getEndPoint(BreinConfig config)
config - the current configurationBreinConfigpublic long getUnixTimestamp()
unixTimestamp. If now should be used as timestamp, the method returns -1L.public T setUnixTimestamp(long unixTimestamp)
unixTimestamp - unix timestamp to be usedthispublic T setClientIpAddress(java.lang.String ipAddress)
ipAddress - contains the ipAddressthispublic java.lang.String getClientIpAddress()
public com.google.gson.Gson getGson()
public T set(java.lang.String key, java.lang.Object value)
{
'key': 'value'
}
thispublic T setHeader(java.lang.String key, java.lang.String value)
public T setHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
public java.util.Map<java.lang.String,java.lang.String> getHeaders()
public abstract void prepareRequestData(BreinConfig config, java.util.Map<java.lang.String,java.lang.Object> requestData)
requestData. It is called by prepareRequestData(BreinConfig) after the request data of the base information is added.requestData - the request data to be sent to the endpointpublic java.lang.String prepareRequestData(BreinConfig config)
config - the configuration used to create the request bodyprotected T getThis()
public java.lang.String toString()
toString in class java.lang.ObjectCopyright © Breinify - All Rights Reserved.