add post creating business case
This commit is contained in:
74
business_cases/post_creating/client/build.gradle
Normal file
74
business_cases/post_creating/client/build.gradle
Normal file
@@ -0,0 +1,74 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version"
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
||||
}
|
||||
|
||||
project.version = "$core_version"
|
||||
project.group = "com.insanusmokrassar"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven { url "https://kotlin.bintray.com/kotlinx" }
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
js (BOTH) {
|
||||
browser()
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib')
|
||||
|
||||
api projectByName("business_cases.post_creating.common")
|
||||
api projectByName("core.ktor.client")
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-common')
|
||||
implementation kotlin('test-annotations-common')
|
||||
}
|
||||
}
|
||||
jvmMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib-jdk8')
|
||||
}
|
||||
}
|
||||
jvmTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-junit')
|
||||
}
|
||||
}
|
||||
jsMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib-js')
|
||||
}
|
||||
}
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-js')
|
||||
implementation kotlin('test-junit')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.insanusmokrassar.postssystem.business_cases.post_creating.client
|
||||
|
||||
import com.insanusmokrassar.postssystem.business_cases.post_creating.server.*
|
||||
import com.insanusmokrassar.postssystem.core.content.Content
|
||||
import com.insanusmokrassar.postssystem.core.post.RegisteredPost
|
||||
import com.insanusmokrassar.postssystem.core.publishing.TriggerId
|
||||
import com.insanusmokrassar.postssystem.ktor.buildStandardUrl
|
||||
import com.insanusmokrassar.postssystem.ktor.client.BodyPair
|
||||
import com.insanusmokrassar.postssystem.ktor.client.unipost
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.request.post
|
||||
|
||||
class PostCreatingClientCase(
|
||||
private val baseUrl: String,
|
||||
private val client: HttpClient
|
||||
) : PostCreatingCase {
|
||||
private val realBaseUrl = "$baseUrl/$postCreatingRootRoute"
|
||||
override suspend fun createPost(postContent: List<Content>, triggerId: TriggerId): RegisteredPost? = client.unipost(
|
||||
buildStandardUrl(realBaseUrl, postCreatingCreatePostRoute),
|
||||
BodyPair(PostCreatingCreatePostModel.serializer(), PostCreatingCreatePostModel(postContent, triggerId)),
|
||||
RegisteredPost.serializer()
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user