update creating case
This commit is contained in:
business_cases/post_creating
client
src
commonMain
kotlin
dev
inmo
postssystem
business_cases
post_creating
common
src
commonMain
kotlin
dev
inmo
postssystem
business_cases
post_creating
server
src
jvmMain
kotlin
dev
inmo
postssystem
business_cases
post_creating
@ -1,22 +1,26 @@
|
||||
package dev.inmo.postssystem.business_cases.post_creating.client
|
||||
|
||||
import dev.inmo.micro_utils.ktor.client.*
|
||||
import dev.inmo.postssystem.business_cases.post_creating.server.*
|
||||
import dev.inmo.postssystem.core.content.Content
|
||||
import dev.inmo.postssystem.core.post.RegisteredPost
|
||||
import dev.inmo.postssystem.core.publishing.TriggerId
|
||||
import dev.inmo.micro_utils.ktor.client.BodyPair
|
||||
import dev.inmo.micro_utils.ktor.client.unipost
|
||||
import dev.inmo.micro_utils.ktor.common.buildStandardUrl
|
||||
import io.ktor.client.HttpClient
|
||||
import kotlinx.serialization.builtins.nullable
|
||||
|
||||
class PostCreatingClientCase(
|
||||
private val baseUrl: String,
|
||||
private val client: HttpClient
|
||||
private val unifiedRequester: UnifiedRequester,
|
||||
private val rootRoute: String? = postCreatingRootRoute
|
||||
) : PostCreatingCase {
|
||||
private val realBaseUrl = "$baseUrl/$postCreatingRootRoute"
|
||||
override suspend fun createPost(postContent: List<Content>, triggerId: TriggerId?): RegisteredPost? = client.unipost(
|
||||
private val realBaseUrl = rootRoute ?.let { "$baseUrl/$rootRoute" } ?: baseUrl
|
||||
override suspend fun createPost(
|
||||
postContent: List<Content>,
|
||||
triggerId: TriggerId?
|
||||
): RegisteredPost? = unifiedRequester.unipost(
|
||||
buildStandardUrl(realBaseUrl, postCreatingCreatePostRoute),
|
||||
BodyPair(PostCreatingCreatePostModel.serializer(), PostCreatingCreatePostModel(postContent, triggerId)),
|
||||
RegisteredPost.serializer()
|
||||
RegisteredPost.serializer().nullable
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user