package com.gh.gamecenter.message.retrofit

import com.gh.gamecenter.feature.entity.*
import com.gh.gamecenter.message.entity.MessageFold
import com.gh.gamecenter.message.entity.MessageGameEntity
import com.gh.gamecenter.message.entity.MessageKeFuEntity
import com.gh.gamecenter.message.entity.SortedMessageEntity
import io.reactivex.Observable
import io.reactivex.Single
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.http.*

interface ApiService {

    @GET("users/{user_id}/messages")
    fun getMessage(
        @Path("user_id") user_id: String,
        @Query("view") type: String? = null,
        @Query("timestamp") timestamp: Long,
        @Query("page") page: Int
    ): Observable<List<MessageEntity>>

    /**
     * 互动消息会话-删除单个消息内容
     */
    @POST("users/{user_id}/messages/{message_id}:inactivate")
    fun deleteMessage(
        @Path("user_id") userId: String,
        @Path("message_id") messageId: String
    ): Observable<ResponseBody>

    /**
     * 将消息标记为已读
     */
    @POST("users/{user_id}/messages/{message_id}:read")
    fun postMessageRead(
        @Path("user_id") userId: String,
        @Path("message_id") messageId: String,
        @Body body: RequestBody?
    ): Observable<ResponseBody>

    /**
     * 获取消息-客服数据
     */
    @GET("users/{user_id}/private_messages")
    fun getMessageKeFuData(
        @Path("user_id") user_id: String,
        @Query("page") page: Int,
        @QueryMap params: Map<String, String>? = null
    ): Observable<List<MessageKeFuEntity>>

    /**
     * 系统通知/光环客服会话-删除单个消息内容
     */
    @POST("users/{user_id}/private_messages/{message_id}:inactivate")
    fun deletePrivateMessage(
        @Path("user_id") userId: String,
        @Path("message_id") messageId: String
    ): Observable<ResponseBody>

    @GET("users/{user_id}/messages/{resource_id}/fold-list")
    fun getMessageFoldList(
        @Path("user_id") userId: String,
        @Path("resource_id") resourceId: String
    ): Observable<List<MessageFold>>

    /**
     * 获取用户关注的游戏
     */
    @GET("users/{user_id}/follows/games")
    fun getConcern(@Path("user_id") user_id: String): Observable<List<GameEntity>>

    /**
     * 获取资讯-关注
     */
    @GET("users/{user_id}/follows/articles")
    fun getZiXunConcern(@Path("user_id") user_id: String, @Query("page") page: Int): Observable<List<ConcernEntity>>

    /**
     * 获取新闻评论数
     */
    @GET("articles/{article_id}/comments:count")
    fun getNewsCommentnum(
        @Path("article_id") article_id: String,
        @Query("timestamp") timestamp: Long
    ): Observable<List<CommentnumEntity>>

    /**
     * 获取新闻阅读量
     */
    @GET("articles/visits")
    fun getArticlesVisits(@Query("filter") filter: String): Observable<List<ViewsEntity>>

    /**
     * 统计新闻阅读量
     */
    @POST("articles/{article_id}:stat_visit")
    fun postArticleVisit(@Path("article_id") articleId: String?): Observable<ResponseBody>

    /**
     * 消息分类列表
     */
    @GET("messages")
    fun getSortedMessage(): Observable<List<SortedMessageEntity>>

    /**
     * 消息分类列表-标记已读
     */
    @POST("messages/{id}/read")
    fun postSortedMessageRead(@Path("id") id: String): Single<ResponseBody>

    /**
     * 消息分类列表-设置
     */
    @PATCH("messages/{id}/setting")
    fun patchSortedMessageSetting(@Path("id") id: String, @Body body: RequestBody): Single<ResponseBody>

    /**
     * 消息分类列表-删除会话
     */
    @DELETE("messages/{id}")
    fun deleteSortedMessage(@Path("id") id: String): Single<ResponseBody>

    /**
     * 消息分类-二级列表内容-游戏会话
     */
    @GET("messages/game")
    fun getMessageGameList(
        @QueryMap params: Map<String, String>,
        @Query("page") page: Int
    ): Observable<List<MessageGameEntity>>

    /**
     * 游戏/论坛会话-删除单个消息内容
     */
    @DELETE("messages/contents/{message_id}")
    fun deleteContentMessage(@Path("message_id") messageId: String): Observable<ResponseBody>
}