small refactor of readPublishingKeysRepo ktor client

This commit is contained in:
InsanusMokrassar 2020-08-26 11:06:03 +06:00
parent ac7c3a1dc5
commit a5fd24e682

View File

@ -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
)
}