package kr.co.vividnext.sodalive.audio_content

import io.reactivex.rxjava3.core.Single
import kr.co.vividnext.sodalive.audio_content.all.GetNewContentAllResponse
import kr.co.vividnext.sodalive.audio_content.all.by_theme.GetContentByThemeResponse
import kr.co.vividnext.sodalive.audio_content.comment.GetAudioContentCommentListResponse
import kr.co.vividnext.sodalive.audio_content.comment.ModifyCommentRequest
import kr.co.vividnext.sodalive.audio_content.comment.RegisterAudioContentCommentRequest
import kr.co.vividnext.sodalive.audio_content.curation.GetCurationContentResponse
import kr.co.vividnext.sodalive.audio_content.detail.GetAudioContentDetailResponse
import kr.co.vividnext.sodalive.audio_content.detail.PutAudioContentLikeRequest
import kr.co.vividnext.sodalive.audio_content.detail.PutAudioContentLikeResponse
import kr.co.vividnext.sodalive.audio_content.donation.AudioContentDonationRequest
import kr.co.vividnext.sodalive.audio_content.main.GetAudioContentBannerResponse
import kr.co.vividnext.sodalive.audio_content.main.GetAudioContentCurationResponse
import kr.co.vividnext.sodalive.audio_content.main.GetAudioContentMainItem
import kr.co.vividnext.sodalive.audio_content.main.GetAudioContentRanking
import kr.co.vividnext.sodalive.audio_content.main.GetNewContentUploadCreator
import kr.co.vividnext.sodalive.audio_content.order.GetAudioContentOrderListResponse
import kr.co.vividnext.sodalive.audio_content.order.OrderRequest
import kr.co.vividnext.sodalive.audio_content.order.OrderType
import kr.co.vividnext.sodalive.audio_content.upload.theme.GetAudioContentThemeResponse
import kr.co.vividnext.sodalive.common.ApiResponse
import kr.co.vividnext.sodalive.explorer.profile.GetAudioContentListResponse
import kr.co.vividnext.sodalive.settings.ContentType
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.DELETE
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 AudioContentApi {
    @GET("/audio-content")
    fun getAudioContentList(
        @Query("creator-id") id: Long,
        @Query("category-id") categoryId: Long,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Query("sort-type") sort: AudioContentViewModel.Sort,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetAudioContentListResponse>>

    @GET("/audio-content/theme")
    fun getAudioContentThemeList(
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<List<GetAudioContentThemeResponse>>>

    @GET("/audio-content/theme/{id}/content")
    fun getAudioContentByTheme(
        @Path("id") id: Long,
        @Query("isAdultContentVisible") isAdultContentVisible: Boolean,
        @Query("contentType") contentType: ContentType,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Query("sort-type") sort: AudioContentViewModel.Sort,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetContentByThemeResponse>>

    @POST("/audio-content")
    @Multipart
    fun uploadAudioContent(
        @Part coverImage: MultipartBody.Part,
        @Part contentFile: MultipartBody.Part,
        @Part("request") request: RequestBody,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @GET("/audio-content/{id}")
    fun getAudioContentDetail(
        @Path("id") id: Long,
        @Query("timezone") timezone: String,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetAudioContentDetailResponse>>

    @POST("/order/audio-content")
    fun orderAudioContent(
        @Body request: OrderRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @GET("/order/audio-content")
    fun getAudioContentOrderList(
        @Query("orderType") orderType: OrderType? = null,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetAudioContentOrderListResponse>>

    @POST("/audio-content/playback-tracking")
    fun addAllPlaybackTracking(
        @Body request: AddAllPlaybackTrackingRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @POST("/audio-content/comment")
    fun registerComment(
        @Body request: RegisterAudioContentCommentRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @GET("/audio-content/{id}/comment")
    fun getAudioContentCommentList(
        @Path("id") id: Long,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Query("timezone") timezone: String,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetAudioContentCommentListResponse>>

    @GET("/audio-content/comment/{id}")
    fun getAudioContentCommentCommentList(
        @Path("id") id: Long,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Query("timezone") timezone: String,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetAudioContentCommentListResponse>>

    @PUT("/audio-content/like")
    fun likeContent(
        @Body request: PutAudioContentLikeRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<PutAudioContentLikeResponse>>

    @PUT("/audio-content")
    @Multipart
    fun modifyAudioContent(
        @Part coverImage: MultipartBody.Part?,
        @Part("request") request: RequestBody,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @DELETE("/audio-content/{id}")
    fun deleteAudioContent(
        @Path("id") id: Long,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @GET("/audio-content/main/new")
    fun getNewContentOfTheme(
        @Query("theme") theme: String,
        @Query("isAdultContentVisible") isAdultContentVisible: Boolean,
        @Query("contentType") contentType: ContentType,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<List<GetAudioContentMainItem>>>

    @GET("/audio-content/main/new/all")
    fun getNewContentAllOfTheme(
        @Query("theme") theme: String,
        @Query("isAdultContentVisible") isAdultContentVisible: Boolean,
        @Query("contentType") contentType: ContentType,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetNewContentAllResponse>>

    @POST("/audio-content/donation")
    fun donation(
        @Body request: AudioContentDonationRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

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

    @GET("/audio-content/curation/{id}")
    fun getAudioContentListByCurationId(
        @Path("id") id: Long,
        @Query("isAdultContentVisible") isAdultContentVisible: Boolean,
        @Query("contentType") contentType: ContentType,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Query("sort-type") sort: AudioContentViewModel.Sort,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetCurationContentResponse>>

    @GET("/audio-content/main/theme")
    fun getNewContentThemeList(
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<List<String>>>

    @GET("/audio-content/ranking-sort-type")
    fun getContentRankingSortType(
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<List<String>>>

    @GET("/audio-content/ranking")
    fun getContentRanking(
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Query("sort-type") sortType: String,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetAudioContentRanking>>

    @GET("/audio-content/main/curation-list")
    fun getCurationList(
        @Query("isAdultContentVisible") isAdultContentVisible: Boolean,
        @Query("contentType") contentType: ContentType,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<List<GetAudioContentCurationResponse>>>

    @GET("/audio-content/main/new-content-upload-creator")
    fun getNewContentUploadCreatorList(
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<List<GetNewContentUploadCreator>>>

    @GET("/audio-content/main/banner-list")
    fun getMainBannerList(
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<List<GetAudioContentBannerResponse>>>

    @GET("/audio-content/main/order-list")
    fun getMainOrderList(
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<List<GetAudioContentMainItem>>>

    @POST("/audio-content/pin-to-the-top/{id}")
    fun pinContent(
        @Path("id") audioContentId: Long,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @PUT("/audio-content/unpin-at-the-top/{id}")
    fun unpinContent(
        @Path("id") audioContentId: Long,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>
}
