Skip to content

Commit

Permalink
MOBILE-1482: Provide common user agent (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
aurimas-zarskis authored Oct 21, 2022
1 parent 2f1bf73 commit cf2731d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eu.kevin.accounts.networking

import eu.kevin.accounts.BuildConfig
import eu.kevin.common.helpers.UserAgentProvider
import eu.kevin.core.plugin.Kevin

internal object AccountsClientProvider {
Expand All @@ -11,7 +12,7 @@ internal object AccountsClientProvider {
} else {
BuildConfig.KEVIN_ACCOUNTS_API_URL
},
userAgent = "",
userAgent = UserAgentProvider.getUserAgent(),
timeout = BuildConfig.HTTP_CLIENT_TIMEOUT,
logLevel = BuildConfig.HTTP_LOGGING_LEVEL
).createClient()
Expand Down
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,4 @@ task clean(type: Delete) {
delete rootProject.buildDir
}

task check {
dependsOn "installKotlinterPrePushHook"
}

apply from: "${rootDir}/maven/publish-root.gradle"
2 changes: 2 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ android {
minSdk 21
targetSdk 33

buildConfigField "String", "KEVIN_SDK_VERSION", "\"$sdkVersion\""

consumerProguardFiles "proguard-rules.pro"
resConfigs("en", "lt", "ru", "bg", "ro", "hu", "el", "et", "pt", "pl", "lv", "sk", "cs", "fi", "sv", "no", "da", "de", "nl", "fr", "es", "it", "sl", "is")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
11 changes: 11 additions & 0 deletions common/src/main/java/eu/kevin/common/helpers/UserAgentProvider.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package eu.kevin.common.helpers

import eu.kevin.common.BuildConfig

object UserAgentProvider {
fun getUserAgent(): String {
return "Kevin Android SDK ${BuildConfig.KEVIN_SDK_VERSION} " +
"${android.os.Build.MODEL} " +
"Android ${android.os.Build.VERSION.RELEASE}"
}
}
5 changes: 3 additions & 2 deletions demo/src/main/java/eu/kevin/demo/data/ClientProvider.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eu.kevin.demo.data

import eu.kevin.common.helpers.UserAgentProvider
import eu.kevin.demo.BuildConfig
import eu.kevin.demo.BuildConfig.KEVIN_API_URL
import eu.kevin.demo.BuildConfig.KEVIN_MOBILE_DEMO_API_URL
Expand All @@ -10,7 +11,7 @@ internal object ClientProvider {
val kevinApiClient: KevinDataClient by lazy {
KevinDataClientFactory(
baseUrl = KEVIN_API_URL,
userAgent = "",
userAgent = UserAgentProvider.getUserAgent(),
timeout = 120000,
logLevel = BuildConfig.HTTP_LOGGING_LEVEL
).createClient()
Expand All @@ -19,7 +20,7 @@ internal object ClientProvider {
val kevinDemoApiClient: KevinApiClient by lazy {
KevinApiClientFactory(
baseUrl = KEVIN_MOBILE_DEMO_API_URL,
userAgent = "",
userAgent = UserAgentProvider.getUserAgent(),
timeout = 120000,
logLevel = BuildConfig.HTTP_LOGGING_LEVEL
).createClient()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eu.kevin.inapppayments.networking

import eu.kevin.accounts.BuildConfig
import eu.kevin.common.helpers.UserAgentProvider
import eu.kevin.core.plugin.Kevin

internal object KevinPaymentsClientProvider {
Expand All @@ -11,7 +12,7 @@ internal object KevinPaymentsClientProvider {
} else {
BuildConfig.KEVIN_ACCOUNTS_API_URL
},
userAgent = "",
userAgent = UserAgentProvider.getUserAgent(),
timeout = BuildConfig.HTTP_CLIENT_TIMEOUT,
logLevel = BuildConfig.HTTP_LOGGING_LEVEL
).createClient()
Expand Down

0 comments on commit cf2731d

Please sign in to comment.