Merge branch 'master' into onetomanyktorimpl

This commit is contained in:
InsanusMokrassar 2020-08-26 11:08:11 +06:00
commit 01ab884e68
2 changed files with 6 additions and 4 deletions

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.ReadPublishingKeysRepo 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.ktor.client.uniget
import com.insanusmokrassar.postssystem.publishing.ktor.getPostIdByTriggerControlKeyRoute import com.insanusmokrassar.postssystem.publishing.ktor.getPostIdByTriggerControlKeyRoute
import com.insanusmokrassar.postssystem.publishing.ktor.getTriggerControlKeyByPostIdRoute import com.insanusmokrassar.postssystem.publishing.ktor.getTriggerControlKeyByPostIdRoute
@ -15,12 +16,12 @@ class ReadPublishingKeysRepoKtorClient (
private val client: HttpClient = HttpClient() private val client: HttpClient = HttpClient()
) : ReadPublishingKeysRepo { ) : ReadPublishingKeysRepo {
override suspend fun getPostIdByTriggerControlKey(key: TriggerControlKey): PostId? = client.uniget( override suspend fun getPostIdByTriggerControlKey(key: TriggerControlKey): PostId? = client.uniget(
"$baseUrl/$getPostIdByTriggerControlKeyRoute/$key", buildStandardUrl(baseUrl, "$getPostIdByTriggerControlKeyRoute/$key"),
PostId.serializer().nullable PostId.serializer().nullable
) )
override suspend fun getTriggerControlKeyByPostId(postId: PostId): TriggerControlKey? = client.uniget( override suspend fun getTriggerControlKeyByPostId(postId: PostId): TriggerControlKey? = client.uniget(
"$baseUrl/$getTriggerControlKeyByPostIdRoute/$postId", buildStandardUrl(baseUrl, "$getTriggerControlKeyByPostIdRoute/$postId"),
TriggerControlKey.serializer().nullable TriggerControlKey.serializer().nullable
) )
} }

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()
) )