-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DefaultGBNetworkDispatcher was moved into separate module
- Loading branch information
1 parent
4128e97
commit d145939
Showing
12 changed files
with
152 additions
and
27 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
plugins { | ||
kotlin("multiplatform") | ||
id("com.android.library") | ||
kotlin("plugin.serialization") | ||
id("maven-publish") | ||
id("signing") | ||
} | ||
|
||
group = "io.growthbook.sdk" | ||
version = "1.0.0" | ||
|
||
kotlin { | ||
android { | ||
publishLibraryVariants("release") | ||
} | ||
|
||
jvm { | ||
compilations.all { | ||
kotlinOptions.jvmTarget = "1.8" | ||
} | ||
} | ||
|
||
val ktorVersion = "2.1.2" | ||
sourceSets { | ||
val commonMain by getting { | ||
dependencies { | ||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.0") | ||
|
||
implementation("io.ktor:ktor-client-core:$ktorVersion") | ||
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion") | ||
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion") | ||
|
||
implementation("io.growthbook.sdk:Core:1.0.0") | ||
} | ||
} | ||
val androidTest by getting { | ||
dependencies { | ||
implementation(kotlin("test-junit")) | ||
implementation("io.ktor:ktor-client-mock:$ktorVersion") | ||
} | ||
} | ||
} | ||
} | ||
|
||
android { | ||
compileSdk = 34 | ||
namespace = "com.sdk.growthbook.default_network_dispatcher" | ||
defaultConfig { | ||
minSdk = 21 | ||
} | ||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
} | ||
debug { | ||
isMinifyEnabled = false | ||
} | ||
} | ||
} | ||
|
||
val sonatypeUsername: String? = System.getenv("GB_SONATYPE_USERNAME") | ||
val sonatypePassword: String? = System.getenv("GB_SONATYPE_PASSWORD") | ||
|
||
/** | ||
* Publishing Task for MavenCentral | ||
*/ | ||
publishing { | ||
repositories { | ||
maven { | ||
name = "kotlin" | ||
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") | ||
val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") | ||
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl | ||
credentials { | ||
username = sonatypeUsername | ||
password = sonatypePassword | ||
} | ||
} | ||
} | ||
|
||
publications { | ||
withType<MavenPublication> { | ||
//artifact(javadocJar) | ||
pom { | ||
name.set("kotlin") | ||
description.set("Default network dispatcher for GrowthBook") | ||
licenses { | ||
license { | ||
name.set("MIT") | ||
url.set("https://opensource.org/licenses/MIT") | ||
} | ||
} | ||
url.set("https://github.com/growthbook/growthbook-kotlin") | ||
issueManagement { | ||
system.set("Github") | ||
url.set("https://github.com/growthbook/growthbook-kotlin/issues") | ||
} | ||
scm { | ||
connection.set("https://github.com/growthbook/growthbook-kotlin.git") | ||
url.set("https://github.com/growthbook/growthbook-kotlin") | ||
} | ||
developers { | ||
developer { | ||
name.set("Bohdan Kim") | ||
email.set("user576g@gmail.com") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Signing JAR using GPG Keys | ||
*/ | ||
signing { | ||
useInMemoryPgpKeys( | ||
System.getenv("GPG_PRIVATE_KEY"), | ||
System.getenv("GPG_PRIVATE_PASSWORD") | ||
) | ||
sign(publishing.publications) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="com.sdk.growthbook" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
</manifest> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
package com.sdk.growthbook.network | ||
|
||
import com.sdk.growthbook.PlatformDependentIODispatcher | ||
import com.sdk.growthbook.utils.Resource | ||
import com.sdk.growthbook.utils.readSse | ||
import com.sdk.growthbook.utils.toJsonElement | ||
import kotlinx.coroutines.Job | ||
import io.ktor.client.HttpClient | ||
import io.ktor.client.call.body | ||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation | ||
import io.ktor.client.request.HttpRequestBuilder | ||
import io.ktor.serialization.kotlinx.json.json | ||
import kotlinx.serialization.json.Json | ||
import kotlinx.coroutines.CoroutineScope | ||
import com.sdk.growthbook.PlatformDependentIODispatcher | ||
import kotlinx.coroutines.launch | ||
import io.ktor.client.request.get | ||
import io.ktor.client.request.headers | ||
import io.ktor.client.request.post | ||
import io.ktor.client.request.prepareGet | ||
import io.ktor.client.request.setBody | ||
import io.ktor.client.call.body | ||
import io.ktor.client.statement.HttpStatement | ||
import io.ktor.http.ContentType | ||
import io.ktor.http.contentType | ||
import io.ktor.serialization.kotlinx.json.json | ||
import io.ktor.client.request.headers | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import io.ktor.utils.io.ByteReadChannel | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Job | ||
import com.sdk.growthbook.utils.readSse | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import kotlinx.coroutines.launch | ||
import kotlinx.serialization.json.Json | ||
import io.ktor.http.ContentType | ||
import io.ktor.http.contentType | ||
//import io.ktor.client.request.setBody | ||
//import com.sdk.growthbook.utils.toJsonElement | ||
import io.ktor.client.request.HttpRequestBuilder | ||
|
||
internal fun createDefaultHttpClient(): HttpClient = | ||
HttpClient { | ||
|
@@ -39,7 +39,7 @@ internal fun createDefaultHttpClient(): HttpClient = | |
/** | ||
* Default Ktor Implementation for Network Dispatcher | ||
*/ | ||
class DefaultGBNetworkClient( | ||
class DefaultGBNetworkDispatcher( | ||
|
||
/** | ||
* Ktor http client instance for sending request | ||
|
@@ -122,7 +122,7 @@ class DefaultGBNetworkClient( | |
append("Accept", "application/json") | ||
} | ||
contentType(ContentType.Application.Json) | ||
setBody(bodyParams.toJsonElement()) | ||
//setBody(bodyParams.toJsonElement()) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Bohdan-Kim
Author
Collaborator
|
||
println("body = $body") | ||
} | ||
onSuccess(response.body()) | ||
|
@@ -142,4 +142,4 @@ class DefaultGBNetworkClient( | |
url.parameters.remove(key) | ||
url.parameters.append(key, it) | ||
} ?: Unit | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@vazarkevych I've noticed that the body is not being sent in Ktor's dispatcher, while it is sent in the OkHttp dependency.
Is this intentional? Is it documented somewhere?