package kr.co.vividnext.sodalive.message

import io.reactivex.rxjava3.core.Single
import kr.co.vividnext.sodalive.common.ApiResponse
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 MessageApi {
    @POST("/message/send/text")
    fun sendTextMessage(
        @Body request: SendTextMessageRequest,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @POST("/message/send/voice")
    @Multipart
    fun sendVoiceMessage(
        @Part voiceFile: MultipartBody.Part,
        @Part("request") request: RequestBody,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @GET("/message/sent/text")
    fun getSentTextMessage(
        @Query("timezone") timezone: String,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetTextMessageResponse>>

    @GET("/message/received/text")
    fun getReceivedTextMessage(
        @Query("timezone") timezone: String,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetTextMessageResponse>>

    @GET("/message/keep/text")
    fun getKeepTextMessage(
        @Query("timezone") timezone: String,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetTextMessageResponse>>

    @GET("/message/sent/voice")
    fun getSentVoiceMessage(
        @Query("timezone") timezone: String,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetVoiceMessageResponse>>

    @GET("/message/received/voice")
    fun getReceivedVoiceMessage(
        @Query("timezone") timezone: String,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetVoiceMessageResponse>>

    @GET("/message/keep/voice")
    fun getKeepVoiceMessage(
        @Query("timezone") timezone: String,
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<GetVoiceMessageResponse>>

    @DELETE("/message/{messageId}")
    fun deleteMessage(
        @Path("messageId") messageId: Long,
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @PUT("/message/keep/text/{id}")
    fun keepTextMessage(
        @Path("id") id: Long,
        @Body container: String = "aos",
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>

    @PUT("/message/keep/voice/{id}")
    fun keepVoiceMessage(
        @Path("id") id: Long,
        @Body container: String = "aos",
        @Header("Authorization") authHeader: String
    ): Single<ApiResponse<Any>>
}
