Android SDK
Getting applications set up to leverage the Experience Server requires the installation of our SDK (Dinghy).
If you do not have the Android SDK, please contact your account executive, or contact Ketch support.
Setup
In order to use Ketch resources, KetchRepository
should be properly initialized and set up. KetchRepository.Builder
class should be used for that purpose.
- Method
organizationCode(String)
: The code of Organization (required) - Method
propertyCode(String)
: The code of Property (required) - Method
context(Context)
: android context - Method
cacheProvider(CacheProvider)
: instance ofCacheProvider
interface implementation - Throws:
IllegalStateException
in case if required parameters are missing
fun KetchRepository.Builder().organizationCode(foo).propertyCode(bar).context(context).cacheProvider(SharedPreferencesCacheProvider(context)).build()
Requests
The next methods send requests to the back-end
Get BootstrapConfiguration
Retrieves bootstrap configuration needed for full config. Uses organizationCode
and propertyCode
to form a full URL. Is executed on IO thread. Result will be cached for each unique pair of organizationCode
and propertyCode
. In case of response fail previously cached data will be allegedly returned as Result.Success
.
- Returns:
Flow
ofResult
withBootstrapConfiguration
if successful and with an error if request or its handling failed
fun getBootstrapConfiguration(): Flow<Result<RequestError, BootstrapConfiguration>>
Get FullConfiguration with coordinates
Retrieves full configuration data. Should be used if location latitude and longitude are provided. Tries to determine locationCode based on provided coordinates using Android components. If fails, fallbacks to using Ketch resources. Is executed on IO thread. Result will be cached for each unique set of of organizationCode
, propertyCode
, environment
, scope
and languageCode
.
- Parameter
configuration
: bootstrap configuration - Parameter
environment
: environment value that should match one of environment patterns - Parameter
languageCode
: current locale code (e.g. en_US) - Parameter
latitude
: current location latitude - Parameter
longitude
:current location longitude - Returns:
Flow
ofResult
withConfiguration
if successful and with an error if request or its handling failed
fun getFullConfiguration(configuration: BootstrapConfiguration, environment: String, languageCode: String, latitude: Double, longitude: Double): Flow<Result<RequestError, Configuration>>
Get FullConfiguration with IP address
Retrieves full configuration data. Should be used if location latitude and longitude are absent or Android component failed to get location code. Tries to determine locationCode using Ketch ASTROLABE resource. Is executed on IO thread. Result will be cached for each unique set of of organizationCode
, propertyCode
, environment
, scope
and languageCode
.
- Parameter
configuration
: bootstrap configuration - Parameter
environment
: environment value that should match one of environment patterns - Parameter
languageCode
: current locale code (e.g. en_US) - Returns:
Flow
ofResult
withConfiguration
if successful and with an error if request or its handling failed
fun getFullConfiguration(configuration: BootstrapConfiguration, environment: String, languageCode: String): Flow<Result<RequestError, Configuration>>
Get Consent Status
Retrieves currently set consent status. Uses organizationCode
to form a full URL. Is executed on IO thread. Result will be cached for each unique set of organizationCode
, propertyCode
, environment
, identities
and purposes
.
- Parameter
configuration
: full configuration - Parameter
identities
: map ofidentityCodes
andidentityValues
. Keys and values shouldn't be null - Parameter
purposes
: map of activitynames
and names oflegalBasisCode
of this activity. * * Keys and values shouldn't be null - Returns:
Flow
ofResult
withMap<String, ConsentStatus>>
if successful and with an error if request or its handling failed
fun getConsentStatus(configuration: Configuration, identities: Map<String, String>, purposes: Map<String, String>): Flow<Result<RequestError, Map<String, ConsentStatus>>>
Update Consent Status
Sends a request for updating consent status. Uses organizationCode
to form a full URL. Is executed on IO thread.
- Parameter configuration: full
configuration
- Parameter
identities
: map ofidentityCodes
andidentityValues
. Keys and values shouldn't be null - Parameter
consents
: map of consent names and information if this particular legalBasisCode should be allowed or not. Keys and values shouldn't be null - Parameter
migrationOption
: rule that represents how updating should be performed - Returns:
Flow
ofResult.Success
if successful and with an error if request or its handling failed
fun updateConsentStatus(configuration: Configuration, identities: Map<String, String>, consents: Map<String, ConsentStatus>, migrationOption: MigrationOption): Flow<Result<RequestError, Unit>>
Invoke Rights
Sends a request for updating consent status. Uses organizationCode
to form a full URL. Is executed on IO thread.
- Parameter
configuration
: full configuration - Parameter
identities
: map ofidentityCodes
andidentityValues
. Keys and values shouldn't be null - Parameter
userData
: consists user information like email - Parameter
rights
: list of strings of rights. Rights shouldn't bu null - Returns:
Flow
ofResult.Success
if successful and with an error if request or its handling failed
fun invokeRights(configuration: Configuration, identities: Map<String, String>, userData: UserData, rights: List<String>): Flow<Result<RequestError, Unit>>
Updated 8 months ago