Android Core SDK

Android Core SDK Documentation

Revisions:

VersionsDetailsDateAuthor
1.0Initial Version02/12/2021CPI
1.0.2Updates to include:

- Revised document
- Added the name of the documents
- API_URL updated
19/01/2022CPI
1.3.0Updates to include:

- Fleksy version upgrade
- Kindred maven credentials removed
16/03/2022CPI
2.0.0Updates to include:

- Logic improvements
15/07/2022CPI
2.1.0Updates to include:

- Added API configuration
- Added CDN configuration
22/07/2022CPI
2.1.1Updates to include:

- Deals with coupons hotfix
22/07/2022CPI
2.2.1Updates to include:

- Country & currency configuration fix
- Active deal fix
- Logic improvements
28/09/2022CPI
2.7.0Updates to include:

- Network requests bug-fixes
19/01/2023CPI

Getting Started

Follow these instructions to add the Kindred Core SDK to an existing application.

For any questions or support with your integration, or to receive your API details, please email [email protected].

Notes:

  • Instructions contained by "[]" need to be adapted for each application.
    
  • Instructions contained by "{}" might change on each SDK revision.
    
  1. First, you need to generate an access token from your account;

    1. From Github, click your user icon, then click on settings.

    2. At the bottom, click Developer Settings

    3. Click on Personal access tokens and then click on Generate new token.

    4. Add a note, select the expiration time, select the checkbox "read:packages" and click to "Generate token"

  2. Add the kindred.properties file in the root of your project. This will include authentication for Maven repositories and authentication for the Kindred Core SDK.
    Replace the USERNAME with your Github user name and the TOKEN by the code that has been generated in the previous step

ext {
    API_URL="https://api-partners.kindred.co"
    ASSETS_CDN_URL="https://cdn.kindred.co"
    AUTH_CLIENT_ID="[AUTH_CLIENT_ID]"
    AUTH_CLIENT_SECRET="[AUTH_CLIENT_SECRET]"
    AUTH_SHARED_KEY="[AUTH_SHARED_KEY]"

    kindred_sdk_maven_url=https:"maven.pkg.github.com/kindred-app/KindredAndroidPackages"
    kindred_sdk_user="USERNAME"
    kindred_sdk_secret_key="TOKEN"
}
  1. Add the SDK’s and dependencies maven repository to settings.gradle file and make sure you apply the "kindred.properties":
apply from: "kindred.properties"

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter()

        // Kindred Keyboard SDK Dependency
        maven {
            name = "GitHubPackages"
            url = uri(kindred_sdk_maven_url)
          	credentials {
                username = kindred_sdk_user
                password = kindred_sdk_secret_key
            }
        }
    }
}
rootProject.name = "your_app"
include ':app'
  1. Add the Auth Settings to the defaultConfig in the module build.gradle. This is later passed down to the Core SDK during configuration. Make sure you apply the "kindred.properties":
apply from: "../kindred.properties"
...
android {
    ...
      defaultConfig {
      ...
        buildConfigField("String", "API_URL", "\"" + API_URL + "\"")
        buildConfigField("String", "ASSETS_CDN_URL", "\"" + ASSETS_CDN_URL + "\"")
        buildConfigField("String", "AUTH_CLIENT_ID", "\"" + AUTH_CLIENT_ID + "\"")
        buildConfigField("String", "AUTH_CLIENT_SECRET", "\"" + AUTH_CLIENT_SECRET + "\"")
        buildConfigField("String", "AUTH_SHARED_KEY", "\"" + AUTH_SHARED_KEY + "\"")
      }
 		 ...
    }
    ...
}
  1. Edit the app’s module build.gradle file, and add dependency with the latest version
...
implementation 'com.kindred.libraries:kindred-core-sdk:"{x.x.x}"'
...
  1. Disable gradle offline mode.

  1. Add the “Automatically convert third-party libraries to use AndroidX” parameter to gradle.properties.
android.enableJetifier=true

API Reference

The Kindred Core SDK is simple to use. The developer just needs to declare a CoreService instance by providing the application context.
Just a couple of functions are currently available, one for getting deals and another for deals activation that provides the deal URL.
The deals come in a JSON string formatted into an object of a class called DealResponse.

  1. In a class with application context access init an instance of CoreService and set the provided user ID
private val apiConfiguration: ApiConfiguration = ApiConfiguration(
  urlBase = BuildConfig.API_URL,
  clientID = BuildConfig.AUTH_CLIENT_ID,
  clientSecret = BuildConfig.AUTH_CLIENT_SECRET,
  sharedKey = BuildConfig.AUTH_SHARED_KEY
)
private val cdnConfiguration: CDNConfiguration = CDNConfiguration(BuildConfig.ASSETS_CDN_URL)
private val coreConfiguration: CoreConfiguration = CoreConfiguration(
  apiConfiguration,
  cdnConfiguration
)
private val coreService by lazy { CoreService(applicationContext, coreConfiguration) }

override fun onCreate() {
  coreService.setUserId("[user_id]")
}
  1. To get the deals, simply call dealsProvider.getDeals from CoreService. See:

You should be providing the term: String for deals filtering and you’ll receive an Array which can be accessed by using “it”

coreService.dealsProvider.getDeals(term, callback = {
		// Do something with “it”
 })
  1. To get the deal link, simply call dealsProvider.handleDealClick from CoreService. See:

You should be providing the deal: DealResponse & the coupon: Coupon? (optionally) and you’ll receive the link as a String.

coreService.dealsProvider.handleDealClick(deal, coupon, callback = {
  performSearch(it)
})

Classes

DealResponse Class

idString“fdb0a392-9149-472d-b2bc-edcce07651b7”
storeNameString“footshop.pl”
cashbackDouble4.8
cashbackTypeString“Percentage” / “fixed”
currencyString?If cashbackType is fixed, “USD”
logoString?“download?path=https%3a%2f%2fimages.viglink.com%2fmerchant%2flogo%2fofficial%2f300x126%2ffootshop-pl%2fbd7b4ed695a259a41081617b0029c087733ba9ff.jpg%3furl%3dhttp%253A%252F%252Fwww.viglink.com%252Fmerchants%252F58949.gif%26text%3dfootshop.pl”
CodesList?True
DateLong?A date for the developer. When was the deal activated?

Coupon Class

CodeString“FTSHPPLCOUP7”
SummaryString“Use this discount code to get 7% off all full-priced items at Footshop.pl. Doesn't work on items in sale and on Jordan.”
ActiveBooleanA bool for the developer. Is it active?