impl publishing klient and kerver
This commit is contained in:
78
publishing/ktor/client/build.gradle
Normal file
78
publishing/ktor/client/build.gradle
Normal file
@@ -0,0 +1,78 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version"
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
||||
}
|
||||
|
||||
project.version = "$core_version"
|
||||
project.group = "com.insanusmokrassar"
|
||||
|
||||
apply from: "publish.gradle"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven { url "https://kotlin.bintray.com/kotlinx" }
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
js()
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib')
|
||||
|
||||
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
|
||||
api "com.insanusmokrassar:postssystem.core.ktor.common:$core_version"
|
||||
api "com.insanusmokrassar:postssystem.ktor.client:$core_version"
|
||||
} else {
|
||||
api projectByName("postssystem.publishing.ktor.common")
|
||||
api projectByName("postssystem.ktor.client")
|
||||
}
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-common')
|
||||
implementation kotlin('test-annotations-common')
|
||||
}
|
||||
}
|
||||
jvmMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib-jdk8')
|
||||
}
|
||||
}
|
||||
jvmTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-junit')
|
||||
}
|
||||
}
|
||||
jsMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib-js')
|
||||
}
|
||||
}
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-js')
|
||||
implementation kotlin('test-junit')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
0
publishing/ktor/client/publish.gradle
Normal file
0
publishing/ktor/client/publish.gradle
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.insanusmokrassar.postssystem.publishing.ktor.client
|
||||
|
||||
import com.insanusmokrassar.postssystem.core.publishing.repos.PublishingKeysRepo
|
||||
import com.insanusmokrassar.postssystem.core.publishing.repos.ReadPublishingKeysRepo
|
||||
import com.insanusmokrassar.postssystem.core.publishing.repos.WritePublishingKeysRepo
|
||||
|
||||
class PublishingKeysRepoKtorClient (
|
||||
readPublishingKeysClient: ReadPublishingKeysRepoKtorClient,
|
||||
writePublishingKeysClient: WritePublishingKeysRepoKtorClient
|
||||
) : PublishingKeysRepo, ReadPublishingKeysRepo by readPublishingKeysClient, WritePublishingKeysRepo by writePublishingKeysClient
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.insanusmokrassar.postssystem.publishing.ktor.client
|
||||
|
||||
import com.insanusmokrassar.postssystem.core.post.PostId
|
||||
import com.insanusmokrassar.postssystem.core.publishing.TriggerControlKey
|
||||
import com.insanusmokrassar.postssystem.core.publishing.repos.ReadPublishingKeysRepo
|
||||
import com.insanusmokrassar.postssystem.ktor.client.uniget
|
||||
import com.insanusmokrassar.postssystem.publishing.ktor.getPostIdByTriggerControlKeyRoute
|
||||
import com.insanusmokrassar.postssystem.publishing.ktor.getTriggerControlKeyByPostIdRoute
|
||||
import io.ktor.client.HttpClient
|
||||
import kotlinx.serialization.builtins.nullable
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
class ReadPublishingKeysRepoKtorClient (
|
||||
private val baseUrl: String,
|
||||
private val client: HttpClient = HttpClient()
|
||||
) : ReadPublishingKeysRepo {
|
||||
override suspend fun getPostIdByTriggerControlKey(key: TriggerControlKey): PostId? = client.uniget(
|
||||
"$baseUrl/$getPostIdByTriggerControlKeyRoute",
|
||||
PostId.serializer().nullable
|
||||
)
|
||||
|
||||
override suspend fun getTriggerControlKeyByPostId(postId: PostId): TriggerControlKey? = client.uniget(
|
||||
"$baseUrl/$getTriggerControlKeyByPostIdRoute",
|
||||
TriggerControlKey.serializer().nullable
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.insanusmokrassar.postssystem.publishing.ktor.client
|
||||
|
||||
import com.insanusmokrassar.postssystem.core.post.PostId
|
||||
import com.insanusmokrassar.postssystem.core.publishing.TriggerControlKey
|
||||
import com.insanusmokrassar.postssystem.core.publishing.repos.WritePublishingKeysRepo
|
||||
import com.insanusmokrassar.postssystem.ktor.client.BodyPair
|
||||
import com.insanusmokrassar.postssystem.ktor.client.unipost
|
||||
import com.insanusmokrassar.postssystem.publishing.ktor.SetPostTriggerControlKeyObject
|
||||
import com.insanusmokrassar.postssystem.publishing.ktor.setPostTriggerControlKeyRoute
|
||||
import com.insanusmokrassar.postssystem.publishing.ktor.unsetPostTriggerControlKeyRoute
|
||||
import io.ktor.client.HttpClient
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
class WritePublishingKeysRepoKtorClient (
|
||||
private val baseUrl: String,
|
||||
private val client: HttpClient = HttpClient()
|
||||
) : WritePublishingKeysRepo {
|
||||
override suspend fun setPostTriggerControlKey(postId: PostId, key: TriggerControlKey): Boolean = client.unipost(
|
||||
"$baseUrl/$setPostTriggerControlKeyRoute",
|
||||
BodyPair(SetPostTriggerControlKeyObject.serializer(), SetPostTriggerControlKeyObject(postId, key)),
|
||||
Boolean.serializer()
|
||||
)
|
||||
|
||||
override suspend fun unsetPostTriggerControlKey(postId: PostId): Boolean = client.unipost(
|
||||
"$baseUrl/$unsetPostTriggerControlKeyRoute",
|
||||
BodyPair(PostId.serializer(), postId),
|
||||
Boolean.serializer()
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user