com.deque.networking.usageservice.UsageServiceClient.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of axe-devtools-android-core Show documentation
Show all versions of axe-devtools-android-core Show documentation
The Axe Devtools Android Core Library
package com.deque.networking.usageservice
import com.deque.networking.interfaces.DashboardService
import com.deque.networking.models.ResultCallAdapterFactory
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory
internal class UsageServiceClient(
private val baseUrl: String
) {
private val usageServiceInterface: UsageServiceInterface =
Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(
ScalarsConverterFactory.create()
)
.addConverterFactory(
MoshiConverterFactory.create(
Moshi.Builder()
.addLast(KotlinJsonAdapterFactory())
.build()
)
)
.addCallAdapterFactory(ResultCallAdapterFactory())
.build()
.create(UsageServiceInterface::class.java)
suspend fun sendEvent(event: UsageServiceEvent): Result {
return usageServiceInterface.sendEvent(
UsageServiceEventV2Data(
event = event.eventName,
dateTime = System.currentTimeMillis(),
distinctId = UsageService.distinctId,
userId = DashboardService.email,
organization = UsageService.orgId,
)
)
}
suspend fun healthCheck(): Result {
return usageServiceInterface.healthCheck()
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy