Package net.gini.android
Class SdkBuilder
- java.lang.Object
-
- net.gini.android.SdkBuilder
-
public class SdkBuilder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description SdkBuilder(android.content.Context context, java.lang.String clientId, java.lang.String clientSecret, java.lang.String emailDomain)
Constructor to initialize a new builder instance where anonymous Gini users are used.SdkBuilder(android.content.Context context, SessionManager sessionManager)
Constructor to initialize a new builder instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Gini
build()
Builds the Gini instance with the configuration settings of the builder instance.SessionManager
getSessionManager()
Return theSessionManager
set via #setSessionManager.SdkBuilder
setApiBaseUrl(java.lang.String newUrl)
Set the base URL of the Gini API.SdkBuilder
setCache(com.android.volley.Cache cache)
Set the cache implementation to use with Volley.SdkBuilder
setConnectionBackOffMultiplier(float backOffMultiplier)
Sets the backoff multiplication factor for connection retries.SdkBuilder
setConnectionTimeoutInMs(int connectionTimeoutInMs)
Sets the (initial) timeout for each request.SdkBuilder
setCredentialsStore(CredentialsStore credentialsStore)
Set the credentials store which is used by the Gini SDK to store user credentials.SdkBuilder
setGiniApiType(GiniApiType giniApiType)
Set which Gini API to use.SdkBuilder
setMaxNumberOfRetries(int maxNumberOfRetries)
Sets the maximal number of retries for each network request.SdkBuilder
setNetworkSecurityConfigResId(int networkSecurityConfigResId)
Set the resource id for the network security configuration xml to enable public key pinning.SdkBuilder
setTrustManager(javax.net.ssl.TrustManager trustManager)
Set a customTrustManager
implementation to have full control over which certificates to trust.SdkBuilder
setUserCenterApiBaseUrl(java.lang.String newUrl)
Set the base URL of the Gini User Center API.
-
-
-
Constructor Detail
-
SdkBuilder
public SdkBuilder(@NonNull android.content.Context context, @NonNull java.lang.String clientId, @NonNull java.lang.String clientSecret, @NonNull java.lang.String emailDomain)
Constructor to initialize a new builder instance where anonymous Gini users are used. This requires access to the Gini User Center API. Access to the User Center API is restricted to selected clients only.- Parameters:
context
- Your application's Context instance (Android).clientId
- Your application's client ID for the Gini API.clientSecret
- Your application's client secret for the Gini API.emailDomain
- The email domain which is used for created Gini users.
-
SdkBuilder
public SdkBuilder(@NonNull android.content.Context context, @NonNull SessionManager sessionManager)
Constructor to initialize a new builder instance. The created Gini instance will use the givenSessionManager
for session management.- Parameters:
context
- Your application's Context instance (Android).sessionManager
- The SessionManager to use.
-
-
Method Detail
-
setNetworkSecurityConfigResId
public SdkBuilder setNetworkSecurityConfigResId(@XmlRes int networkSecurityConfigResId)
Set the resource id for the network security configuration xml to enable public key pinning.- Parameters:
networkSecurityConfigResId
- xml resource id- Returns:
- The builder instance to enable chaining.
-
setApiBaseUrl
public SdkBuilder setApiBaseUrl(@NonNull java.lang.String newUrl)
Set the base URL of the Gini API. Handy for tests. Usually, you do not use this method.- Parameters:
newUrl
- The URL of the Gini API which is used by the requests of the Gini SDK.- Returns:
- The builder instance to enable chaining.
-
setUserCenterApiBaseUrl
public SdkBuilder setUserCenterApiBaseUrl(@NonNull java.lang.String newUrl)
Set the base URL of the Gini User Center API. Handy for tests. Usually, you do not use this method.- Parameters:
newUrl
- The URL of the Gini User Center API which is used by the requests of the Gini SDK.- Returns:
- The builder instance to enable chaining.
-
setGiniApiType
public SdkBuilder setGiniApiType(@NonNull GiniApiType giniApiType)
Set which Gini API to use. SeeGiniApiType
for options.- Parameters:
giniApiType
- theGiniApiType
to be used- Returns:
- The builder instance to enable chaining.
-
setConnectionTimeoutInMs
public SdkBuilder setConnectionTimeoutInMs(int connectionTimeoutInMs)
Sets the (initial) timeout for each request. A timeout error will occur if nothing is received from the underlying socket in the given time span. The initial timeout will be altered depending on the #backoffMultiplier and failed retries.- Parameters:
connectionTimeoutInMs
- initial timeout- Returns:
- The builder instance to enable chaining.
-
setMaxNumberOfRetries
public SdkBuilder setMaxNumberOfRetries(int maxNumberOfRetries)
Sets the maximal number of retries for each network request.- Parameters:
maxNumberOfRetries
- maximal number of retries.- Returns:
- The builder instance to enable chaining.
-
setConnectionBackOffMultiplier
public SdkBuilder setConnectionBackOffMultiplier(float backOffMultiplier)
Sets the backoff multiplication factor for connection retries. In case of failed retries the timeout of the last request attempt is multiplied with this factor- Parameters:
backOffMultiplier
- the backoff multiplication factor- Returns:
- The builder instance to enable chaining.
-
setCredentialsStore
public SdkBuilder setCredentialsStore(@NonNull CredentialsStore credentialsStore)
Set the credentials store which is used by the Gini SDK to store user credentials. If no credentials store is set, the net.gini.android.authorization.SharedPreferencesCredentialsStore is used by default.- Parameters:
credentialsStore
- A credentials store instance (specified by the CredentialsStore interface).- Returns:
- The builder instance to enable chaining.
-
setCache
public SdkBuilder setCache(@NonNull com.android.volley.Cache cache)
Set the cache implementation to use with Volley. If no cache is set, the default Volley cache will be used.- Parameters:
cache
- A cache instance (specified by the com.android.volley.Cache interface).- Returns:
- The builder instance to enable chaining.
-
setTrustManager
public SdkBuilder setTrustManager(@NonNull javax.net.ssl.TrustManager trustManager)
Set a customTrustManager
implementation to have full control over which certificates to trust.Please be aware that if you set a custom TrustManager implementation here than it will override any network security configuration you may have set.
- Parameters:
trustManager
- ATrustManager
implementation.- Returns:
- The builder instance to enable chaining.
-
build
public Gini build()
Builds the Gini instance with the configuration settings of the builder instance.- Returns:
- The fully configured Gini instance.
-
getSessionManager
@NonNull public SessionManager getSessionManager()
Return theSessionManager
set via #setSessionManager. If no SessionManager has been set, default toAnonymousSessionManager
.- Returns:
- The SessionManager instance.
-
-