Skip to main content

Kotlin

You are reading an outdated document

Get the latest developer guides on Fynd Partners Help

How to install Kotlin FDK Client

  1. Add the dependency in your app build.gradle implementation 'com.github.gofynd:fdk-client-kotlin:v0.0.7' in your app build.gradle
  2. Add it in your root build.gradle at the end of repositories: allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
  3. Start integrating

Sample Usage - ApplicationClient

  var config: ApplicationConfig? = null
try {
config = ApplicationConfig(
applicationId = "YOUR_APPLICATION_ID",
applicationToken = "YOUR_APPLICATION_TOKEN"
)
} catch (e: Exception) {
print(e.message)
}
applicationConfig?.let { config ->
val applicationClient = ApplicationClient(config = config)
GlobalScope.launch {
applicationClient.catalog.getProductDetailBySlug(slug: "product-slug")
.safeAwait{ response,error ->
response?.let{
print(it.peekContent()?.name)
}
error?.let{
print(it.message)
}
}
}

Sample Usage - PlatformClient

  var config: PlatformConfig? = null
try {
config = PlatformConfig(
companyId = "COMPANY_ID",
apiKey = "API_KEY",
apiSecret = "API_SECRET",
domain = "DOMAIN"
)
} catch (e: Exception) {
print(e.message)
}
platormConfig?.let { config ->
val platfromClient = PlatformClient(config = config)
GlobalScope.launch {
platformClient.catalog.getCompanyDetail()
.safeAwait{ response,error ->
response?.let{
print(it.peekContent()?.name)
}
error?.let{
print(it.message)
}
}
}