small refactor of readPublishingKeysRepo ktor client

This commit is contained in:
InsanusMokrassar 2020-08-26 11:07:44 +06:00
parent a5fd24e682
commit 553ddded28

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.post.PostId
import com.insanusmokrassar.postssystem.core.publishing.TriggerControlKey import com.insanusmokrassar.postssystem.core.publishing.TriggerControlKey
import com.insanusmokrassar.postssystem.core.publishing.repos.WritePublishingKeysRepo 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.BodyPair
import com.insanusmokrassar.postssystem.ktor.client.unipost import com.insanusmokrassar.postssystem.ktor.client.unipost
import com.insanusmokrassar.postssystem.publishing.ktor.SetPostTriggerControlKeyObject import com.insanusmokrassar.postssystem.publishing.ktor.SetPostTriggerControlKeyObject
@ -16,13 +17,13 @@ class WritePublishingKeysRepoKtorClient (
private val client: HttpClient = HttpClient() private val client: HttpClient = HttpClient()
) : WritePublishingKeysRepo { ) : WritePublishingKeysRepo {
override suspend fun setPostTriggerControlKey(postId: PostId, key: TriggerControlKey): Boolean = client.unipost( override suspend fun setPostTriggerControlKey(postId: PostId, key: TriggerControlKey): Boolean = client.unipost(
"$baseUrl/$setPostTriggerControlKeyRoute", buildStandardUrl(baseUrl, setPostTriggerControlKeyRoute),
BodyPair(SetPostTriggerControlKeyObject.serializer(), SetPostTriggerControlKeyObject(postId, key)), BodyPair(SetPostTriggerControlKeyObject.serializer(), SetPostTriggerControlKeyObject(postId, key)),
Boolean.serializer() Boolean.serializer()
) )
override suspend fun unsetPostTriggerControlKey(postId: PostId): Boolean = client.unipost( override suspend fun unsetPostTriggerControlKey(postId: PostId): Boolean = client.unipost(
"$baseUrl/$unsetPostTriggerControlKeyRoute", buildStandardUrl(baseUrl, unsetPostTriggerControlKeyRoute),
BodyPair(PostId.serializer(), postId), BodyPair(PostId.serializer(), postId),
Boolean.serializer() Boolean.serializer()
) )