From a5fd24e682648f82ff8550316caa9705477e2f3b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 26 Aug 2020 11:06:03 +0600 Subject: [PATCH 1/2] small refactor of readPublishingKeysRepo ktor client --- .../ktor/client/ReadPublishingKeysRepoKtorClient.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/ReadPublishingKeysRepoKtorClient.kt b/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/ReadPublishingKeysRepoKtorClient.kt index 216b8428..87023abc 100644 --- a/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/ReadPublishingKeysRepoKtorClient.kt +++ b/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/ReadPublishingKeysRepoKtorClient.kt @@ -3,6 +3,7 @@ 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.buildStandardUrl import com.insanusmokrassar.postssystem.ktor.client.uniget import com.insanusmokrassar.postssystem.publishing.ktor.getPostIdByTriggerControlKeyRoute import com.insanusmokrassar.postssystem.publishing.ktor.getTriggerControlKeyByPostIdRoute @@ -15,12 +16,12 @@ class ReadPublishingKeysRepoKtorClient ( private val client: HttpClient = HttpClient() ) : ReadPublishingKeysRepo { override suspend fun getPostIdByTriggerControlKey(key: TriggerControlKey): PostId? = client.uniget( - "$baseUrl/$getPostIdByTriggerControlKeyRoute/$key", + buildStandardUrl(baseUrl, "$getPostIdByTriggerControlKeyRoute/$key"), PostId.serializer().nullable ) override suspend fun getTriggerControlKeyByPostId(postId: PostId): TriggerControlKey? = client.uniget( - "$baseUrl/$getTriggerControlKeyByPostIdRoute/$postId", + buildStandardUrl(baseUrl, "$getTriggerControlKeyByPostIdRoute/$postId"), TriggerControlKey.serializer().nullable ) } \ No newline at end of file From 553ddded2808346b6bdd6c3cfc0b4587372ab484 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 26 Aug 2020 11:07:44 +0600 Subject: [PATCH 2/2] small refactor of readPublishingKeysRepo ktor client --- .../ktor/client/WritePublishingKeysRepoKtorClient.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/WritePublishingKeysRepoKtorClient.kt b/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/WritePublishingKeysRepoKtorClient.kt index 16a9be59..bc4bc6b8 100644 --- a/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/WritePublishingKeysRepoKtorClient.kt +++ b/publishing/ktor/client/src/commonMain/kotlin/com/insanusmokrassar/postssystem/publishing/ktor/client/WritePublishingKeysRepoKtorClient.kt @@ -3,6 +3,7 @@ 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.buildStandardUrl import com.insanusmokrassar.postssystem.ktor.client.BodyPair import com.insanusmokrassar.postssystem.ktor.client.unipost import com.insanusmokrassar.postssystem.publishing.ktor.SetPostTriggerControlKeyObject @@ -16,13 +17,13 @@ class WritePublishingKeysRepoKtorClient ( private val client: HttpClient = HttpClient() ) : WritePublishingKeysRepo { override suspend fun setPostTriggerControlKey(postId: PostId, key: TriggerControlKey): Boolean = client.unipost( - "$baseUrl/$setPostTriggerControlKeyRoute", + buildStandardUrl(baseUrl, setPostTriggerControlKeyRoute), BodyPair(SetPostTriggerControlKeyObject.serializer(), SetPostTriggerControlKeyObject(postId, key)), Boolean.serializer() ) override suspend fun unsetPostTriggerControlKey(postId: PostId): Boolean = client.unipost( - "$baseUrl/$unsetPostTriggerControlKeyRoute", + buildStandardUrl(baseUrl, unsetPostTriggerControlKeyRoute), BodyPair(PostId.serializer(), postId), Boolean.serializer() )