Android Core SDK
Android Core SDK Documentation
Revisions:
Versions | Details | Date | Author |
---|---|---|---|
1.0 | Initial Version | 02/12/2021 | CPI |
1.0.2 | Updates to include: - Revised document - Added the name of the documents - API_URL updated | 19/01/2022 | CPI |
1.3.0 | Updates to include: - Fleksy version upgrade - Kindred maven credentials removed | 16/03/2022 | CPI |
2.0.0 | Updates to include: - Logic improvements | 15/07/2022 | CPI |
2.1.0 | Updates to include: - Added API configuration - Added CDN configuration | 22/07/2022 | CPI |
2.1.1 | Updates to include: - Deals with coupons hotfix | 22/07/2022 | CPI |
2.2.1 | Updates to include: - Country & currency configuration fix - Active deal fix - Logic improvements | 28/09/2022 | CPI |
2.7.0 | Updates to include: - Network requests bug-fixes | 19/01/2023 | CPI |
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.
-
First, you need to generate an access token from your account;
-
From Github, click your user icon, then click on settings.
-
At the bottom, click Developer Settings
-
Click on Personal access tokens and then click on Generate new token.
-
Add a note, select the expiration time, select the checkbox "read:packages" and click to "Generate token"
-
-
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"
}
- 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'
- 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 + "\"")
}
...
}
...
}
- 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}"'
...
- Disable gradle offline mode.
- 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.
- 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]")
}
- 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”
})
- 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
id | String | “fdb0a392-9149-472d-b2bc-edcce07651b7” |
---|---|---|
storeName | String | “footshop.pl” |
cashback | Double | 4.8 |
cashbackType | String | “Percentage” / “fixed” |
currency | String? | If cashbackType is fixed, “USD” |
logo | String? | “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” |
Codes | List? | True |
Date | Long? | A date for the developer. When was the deal activated? |
Coupon Class
Code | String | “FTSHPPLCOUP7” |
---|---|---|
Summary | String | “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.” |
Active | Boolean | A bool for the developer. Is it active? |
Updated 28 days ago