package com.swago.baseswago.inter

import com.swago.baseswago.model.MomentModel
import com.swago.baseswago.model.RedEnvelope
import com.swago.baseswago.model.live.*
import com.swago.baseswago.model.live.audio.*
import com.swago.baseswago.model.live.game.GameListModel
import com.swago.baseswago.model.live.gift.GiftAllModel
import com.swago.baseswago.model.live.gift.GiftSendModel
import com.swago.baseswago.model.live.mic.ApplyLianMaiResultModel
import com.swago.baseswago.model.live.mic.LianMaiListModel
import com.swago.baseswago.model.live.mic.LianMaiUserModel
import com.swago.baseswago.model.live.mic.RoomLianMaiInfo
import com.swago.baseswago.model.live.pk.ListPKLiverModel
import com.swago.baseswago.model.live.pk.PKInfoModel
import okhttp3.RequestBody
import retrofit2.http.*

/**
 *@date 2021/10/20 21:26
 *description:
 */
interface RoomApi {

    /**
     * 游戏列表
     */
    @POST("/v2/rtc/game/list")
    suspend fun getGameList(): GameListModel

    /**
     * 开播
     * broadcast_type 直播间类型(1视频2语音)
     */
    @FormUrlEncoded
    @POST("/v3/rtc/start/broadcast")
    suspend fun startLive(@Field("broadcast_type")broadcast_type:Int): RoomModel


    /**
     * 关播
     */
    @POST("/v1/rtc/end/broadcast")
    suspend fun closeLive(): AnchorClosedModel


    /**
     * 加入房间
     */
    @FormUrlEncoded
    @POST("/v1/rtc/join/broadcast")
    suspend fun joinRoom(@Field("room_id") room_id: String): RoomModel

    /**
     * 退出房间
     */
    @FormUrlEncoded
    @POST("/v1/rtc/leave/broadcast")
    suspend fun leaveRoom(@Field("room_id") room_id: String): Any


    /**
     * 观众列表
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/user/list")
    suspend fun getRoomUser(
        @Field("room_id") room_id: String,
        @Field("page") page: Int = 1,
        @Field("page_size") page_size: Int = 5
    ): RoomUserModel

    /**
     * 直播间排行榜
     * 排行榜类型(1日榜2周榜3月榜)rank_type
     */
    @FormUrlEncoded
    @POST("/v1/rtc/fans/rank/list")
    suspend fun getRankList(
        @Field("room_id") room_id: String,
        @Field("rank_type") rank_type: Int,
        @Field("page") page: Int = 1,
        @Field("page_size") page_size: Int = 20
    ): RankListModel


    /**
     * 直播间礼物
     */
    @POST("/v1/rtc/gift/list")
    suspend fun getGiftList(): List<GiftAllModel>

    /**
     * 直播间礼物
     */
    @POST("/v3/rtc/yuying/gift/list")
    suspend fun getAudioGiftList(): List<GiftAllModel>

    /**
     * 赠送礼物
     */
    @FormUrlEncoded
    @POST("/v3/rtc/buy/gift")
    suspend fun sendGift(
        @Field("room_id") room_id: String,
        @Field("gift_id") gift_id: String,
        @Field("gift_batch") gift_batch: Int,
        @Field("gift_receive_id") gift_receive_id: String,
        @Field("is_combo") is_combo: Int,
        @Field("gift_num") gift_num: Int,
        @Field("pk_id") pk_id: String,
    ): GiftSendModel

    /**
     * 用户在直播间权限
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/auth")
    suspend fun getUserRoomAuth(
        @Field("room_id") room_id: String,
        @Field("user_id") user_id: String
    ): RoomAuthModel

    /**
     * 剔除直播间
     * type 1 添加  0移除
     */
    @FormUrlEncoded
    @POST("/v1/rtc/remove/user")
    suspend fun kickUserFromRoom(
        @Field("room_id") room_id: String,
        @Field("user_id") user_id: String,
        @Field("type") type: Int
    )

    /**
     * 用户禁言
     */
    @FormUrlEncoded
    @POST("/v1/rtc/forbid/user/msg")
    suspend fun muteUerFromRoom(
        @Field("room_id") room_id: String,
        @Field("user_id") user_id: String,
        @Field("type") type: Int
    )

    /**
     * 直播间拉黑
     * black_type  用户类型 1拉黑主播 2拉黑用户
     * type 类型(0取消拉黑1拉黑)
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/black/user")
    suspend fun blackUser(
        @Field("black_user_id") black_user_id: String,
        @Field("black_type") black_type: Int,
        @Field("type") type: Int
    )


    /**
     * 获取分享配置
     */
    @POST("/v1/rtc/broadcast/live/share/link")
    suspend fun getShareConfig(): ShareConfig

    /**
     * 获取直播间配置
     */
    @POST("/v1/rtc/broadcast/setting")
    suspend fun getRoomConfig(): RoomConfig

    /**
     * 获取红包列表
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/package/list")
    suspend fun getRedEnvelopeList(@Field("room_id") room_id: String): ArrayList<RedEnvelope>


    /**
     * 发送红包接口
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/send/package")
    suspend fun sendRedEnvelope(
        @Field("room_id") room_id: String,
        @Field("package_total_coins") package_total_coins: String,
        @Field("package_total_num") package_total_num: Int,
    ): Any


    /**
     * 领取红包接口
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/receive/package")
    suspend fun getRedEnvelopeCoin(
        @Field("room_id") room_id: String,
        @Field("package_id") package_id: String
    ): RedEnvelopeResult


    /**
     * 根据主播ID获取主播信息
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/user/detail")
    suspend fun getMomentModel(@Field("room_id") room_id: String): MomentModel


    /***********************PK*********************************/

    /**
     * 获取主播PK列表
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/pk/list")
    suspend fun getPKLiverList(@Field("search_keyword") search_keyword: String): ListPKLiverModel

    /**
     * 用户发起PK接口
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/pk")
    suspend fun invitePK(@Field("pk_user_id") pk_user_id: String): Any

    /**
     * 被邀请的对象接受或者主动拒绝
     *  //类型(1接受2拒绝)
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/pk/accept")
    suspend fun acceptRefusePK(
        @Field("type") type: Int,
        @Field("user_id") user_id: String
    ): Any

    /**
     * 发起PK方主动取消邀请
     */
    @POST("/v1/rtc/broadcast/pk/cancel")
    suspend fun cancelInvitePK(): Any

    /**
     * PK确认接口
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/pk/act")
    suspend fun pkSure(@Field("pk_id") pk_id: String): Any


    /**
     * 获取直播间信息
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/pk/detail")
    suspend fun getPKInfo(@Field("room_id") room_id: String): PKInfoModel

    /***********************连麦*********************************/

    /**
     * 申请连麦
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/lianmai")
    suspend fun applyLianMai(@Field("room_id") room_id: String,
        @Field("broadcast_log_id") broadcast_log_id: String): ApplyLianMaiResultModel

    /**
     * 连麦列表
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/lianmai/list")
    suspend fun getLianMaiList(@Field("room_id") room_id: String,
                             @Field("broadcast_log_id") broadcast_log_id: String): LianMaiListModel

    /**
     * 主播拒绝连麦 或者用户取消连麦
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/lianmai/cancel")
    suspend fun refuseOrCancelLianMai(@Field("room_id") room_id: String,
                               @Field("broadcast_log_id") broadcast_log_id: String,
                              @Field("lianmai_id") lianmai_id: String): Any

    /**
     * 接受连麦
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/lianmai/accept")
    suspend fun acceptLianMai(@Field("room_id") room_id: String,
                              @Field("broadcast_log_id") broadcast_log_id: String,
                              @Field("lianmai_id") lianmai_id: String): Any


    /**
     * 关闭连麦
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/lianmai/end")
    suspend fun closeLianMai(@Field("room_id") room_id: String,
                              @Field("broadcast_log_id") broadcast_log_id: String,
                              @Field("lianmai_id") lianmai_id: String): Any

    /**
     * 连麦确认接口
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/lianmai/ack")
    suspend fun lianMaiSuccess(@Field("room_id") room_id: String,
                             @Field("broadcast_log_id") broadcast_log_id: String,
                             @Field("lianmai_id") lianmai_id: String): Any

    /**
     * 直播间连麦信息
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/lianmai/detail")
    suspend fun getLianMaiInfo(@Field("room_id") room_id: String,
                               @Field("broadcast_log_id") broadcast_log_id: String): RoomLianMaiInfo




    /*************************语音房*******************************************/

    /**
     * 获取麦位列表
     * type 1开播前 2开播中
     */
    @FormUrlEncoded
    @POST("/v3/rtc/yuying/position/list")
    suspend fun getAudioList(@Field("room_id") room_id: String,
                             @Field("type") type: Int): AudioSeatList

    /**
     * 锁麦和解锁麦位
     * type类型(1锁麦2解锁)
     */
    @FormUrlEncoded
    @POST("/v3/rtc/yuying/position/lock")
    suspend fun lockAndUnLockMic(@Field("room_id") room_id: String,
                                 @Field("broadcast_log_id") broadcast_log_id: String,
                                 @Field("position_id") position_id: Int,
                                 @Field("type") type: Int):Any

    /**
     * 邀请用户上麦
     */
    @FormUrlEncoded
    @POST("/v3/rtc/yuying/position/invite")
    suspend fun inviteOnMic(@Field("room_id") room_id: String,
                            @Field("broadcast_log_id") broadcast_log_id: String,
                            @Field("position_id") position_id: Int,
                            @Field("user_id") user_id: String):Any


    /**
     * 主播对用户开闭麦
     * "type": 1, //类型(1闭麦2开麦)
     */
    @FormUrlEncoded
    @POST("/v3/rtc/yuying/position/open")
    suspend fun operateMicByAnchor(@Field("room_id") room_id: String,
                                   @Field("broadcast_log_id") broadcast_log_id: String,
                                   @Field("position_id") position_id: Int,
                                   @Field("user_id") user_id: String,
                                   @Field("type") type: Int):Any

    /**
     * 主播对用户下麦操作
     */
    @FormUrlEncoded
    @POST("/v3/rtc/yuying/position/down")
    suspend fun downMicByAnchor(@Field("room_id") room_id: String,
                                   @Field("broadcast_log_id") broadcast_log_id: String,
                                   @Field("position_id") position_id: Int,
                                   @Field("user_id") user_id: String):Any

    /**
     * 主播同意用户上麦
     * "type": 1, //类型(1闭麦2开麦)
     */
    @FormUrlEncoded
    @POST("/v3/rtc/yuying/position/access")
    suspend fun agreeUserOnMic(@Field("room_id") room_id: String,
                                @Field("broadcast_log_id") broadcast_log_id: String,
                                @Field("position_id") position_id: Int,
                                @Field("user_id") user_id: String):Any

    /**
     * 用户上麦成功确认
     */
    @FormUrlEncoded
    @POST("/v3/rtc/yuying/position/ack")
    suspend fun userOnMicCallBack(@Field("room_id") room_id: String,
                               @Field("broadcast_log_id") broadcast_log_id: String,
                               @Field("apply_id") apply_id: String):Any


    /**
     * 用户申请上麦
     */
    @FormUrlEncoded
    @POST("/v3/rtc/yuying/position/apply")
    suspend fun userApplyOnMic(@Field("room_id") room_id: String,
                               @Field("broadcast_log_id") broadcast_log_id: String,
                               @Field("position_id") position_id: Int):Any


    /**
     * 观众同意主播的邀请上麦
     * "type": 1 //操作类型(1同意 2拒绝)
     */
    @FormUrlEncoded
    @POST("/v3/rtc/yuying/position/agree")
    suspend fun userAgreeAnchorInvite(@Field("room_id") room_id: String,
                                      @Field("broadcast_log_id") broadcast_log_id: String,
                                      @Field("apply_id") apply_id: String,
                                      @Field("type") type: Int):Any


    /**
     * 积分清零
     */
    @FormUrlEncoded
    @POST("/v3/rtc/yuying/position/jifen/reset")
    suspend fun clearJiFen(@Field("room_id") room_id: String,
                           @Field("broadcast_log_id") broadcast_log_id: String):Any


    /**
     * 语音房被邀请用户列表
     */
    @FormUrlEncoded
    @POST("/v3/rtc/yuying/user/list")
    suspend fun getCanAudioInviteUserList(@Field("room_id") room_id: String,
                           @Field("broadcast_log_id") broadcast_log_id: String): List<AudioInviteUserModel>

    /**
     * 语音房公告变更
     */
    @FormUrlEncoded
    @POST("/v3/rtc/yuying/broadcast/notice/content")
    suspend fun updateAudioNotice(@Field("room_id") room_id: String,
                                  @Field("yuying_notice_content") yuying_notice_content: String):Any


    @POST("/v3/rtc/yuying/buy/gift")
    suspend fun sendAudioGift(@Body requestBody: RequestBody): AudioSendGiftModel

    /**
     * 语音房里麦上的用户信息
     */
    @FormUrlEncoded
    @POST("/v3/rtc/yuying/position/user/list")
    suspend fun getMaiUserList(@Field("broadcast_log_id") broadcast_log_id: String): MaiUserModel

    /**
     * 发送弹幕
     */
    @FormUrlEncoded
    @POST("/v1/rtc/barrage/send")
    suspend fun sendDanMu(@Field("room_id") room_id: String,@Field("message") message: String):Any

    /**
     * 红包领取详情
     */
    @FormUrlEncoded
    @POST("/v1/rtc/broadcast/package/detail")
    suspend fun getRedReceivedList(@Field("package_id") package_id: String):RedReceiveListModel
}