Android Application Setup

Getting applications set up to leverage the Experience Server requires the installation of our SDK (Dinghy).

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 of CacheProvider 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 of Result with BootstrapConfiguration 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 of Result with Configuration 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 of Result with Configuration 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 of identityCodes and identityValues. Keys and values shouldn't be null
  • Parameter purposes: map of activity names and names of legalBasisCode of this activity. * * Keys and values shouldn't be null
  • Returns: Flow of Result with Map<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 of identityCodes and identityValues. 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 of Result.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 of identityCodes and identityValues. 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 of Result.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>>