package kr.co.vividnext.sodalive.explorer.profile.creator_community

import io.reactivex.rxjava3.core.Single
import kr.co.vividnext.sodalive.audio_content.comment.ModifyCommentRequest
import kr.co.vividnext.sodalive.common.ApiResponse
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.PostCommunityPostLikeRequest
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.PurchasePostRequest
import kr.co.vividnext.sodalive.explorer.profile.creator_community.all.comment.CreateCommunityPostCommentRequest
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Part
import retrofit2.http.Path
import retrofit2.http.Query

interface CreatorCommunityApi {
    @POST("/creator-community")
    @Multipart
    fun createCommunityPost(
        @Part audioFile: MultipartBody.Part?,
        @Part postImage: MultipartBody.Part?,
        @Part("request") request: RequestBody,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @PUT("/creator-community")
    @Multipart
    fun modifyCommunityPost(
        @Part postImage: MultipartBody.Part?,
        @Part("request") request: RequestBody,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @GET("/creator-community")
    fun getCommunityPostList(
        @Query("creatorId") creatorId: Long,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Query("timezone") timezone: String,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<List<GetCommunityPostListResponse>>>

    @GET("/creator-community/latest")
    fun getLatestPostListFromCreatorsYouFollow(
        @Query("timezone") timezone: String,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<List<GetCommunityPostListResponse>>>

    @POST("/creator-community/like")
    fun communityPostLike(
        @Body request: PostCommunityPostLikeRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @GET("/creator-community/{id}/comment")
    fun getCommunityPostCommentList(
        @Path("id") postId: Long,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Query("timezone") timezone: String,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetCommunityPostCommentListResponse>>

    @POST("/creator-community/comment")
    fun createCommunityPostComment(
        @Body request: CreateCommunityPostCommentRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @PUT("/creator-community/comment")
    fun modifyComment(
        @Body request: ModifyCommentRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @GET("/creator-community/comment/{id}")
    fun getCommentReplyList(
        @Path("id") commentId: Long,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Query("timezone") timezone: String,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetCommunityPostCommentListResponse>>

    @GET("/creator-community/{id}")
    fun getCommunityPostDetail(
        @Path("id") postId: Long,
        @Query("timezone") timezone: String,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetCommunityPostListResponse>>

    @POST("/creator-community/purchase")
    fun purchaseCommunityPost(
        @Body request: PurchasePostRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetCommunityPostListResponse>>
}
