package dev.inmo.postssystem.services.posts.client

import dev.inmo.micro_utils.ktor.client.UnifiedRequester
import dev.inmo.micro_utils.ktor.common.buildStandardUrl
import dev.inmo.micro_utils.repos.ReadCRUDRepo
import dev.inmo.micro_utils.repos.ktor.client.crud.KtorReadStandardCrudRepo
import dev.inmo.postssystem.features.posts.common.PostId
import dev.inmo.postssystem.features.posts.common.RegisteredPost
import dev.inmo.postssystem.services.posts.common.ReadPostsService
import dev.inmo.postssystem.services.posts.common.postsRootPath
import kotlinx.serialization.builtins.nullable

class ClientReadPostsService(
    private val baseUrl: String,
    private val unifiedRequester: UnifiedRequester
) : ReadPostsService, ReadCRUDRepo<RegisteredPost, PostId> by KtorReadStandardCrudRepo(
    buildStandardUrl(baseUrl, postsRootPath),
    unifiedRequester,
    RegisteredPost.serializer(),
    RegisteredPost.serializer().nullable,
    PostId.serializer()
)
