package com.sheep.gamegroup.util;


import android.support.annotation.IntDef;

import com.alibaba.fastjson.JSONObject;
import com.sheep.gamegroup.model.entity.BaseMessage;
import com.sheep.jiuyan.samllsheep.SheepApp;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by realicing on 2018/11/2.
 * realicing@sina.com
 */
public class ApiJSONUtil {
    public static final int COMMENT_TYPE_GAME = 1;
    public static final int COMMENT_TYPE_ARTICLE = 2;
    public static final int COMMENT_TYPE_VIDEO = 3;
    @IntDef({COMMENT_TYPE_GAME, COMMENT_TYPE_ARTICLE, COMMENT_TYPE_VIDEO})
    @Retention(RetentionPolicy.SOURCE)
    public @interface COMMENT_TYPE {
    }
    /**
     * 用户游戏评论
     * CommentType       int8    `description:"评论类型 1：游戏 2：资讯" json:"comment_type"`
     * app_id:	integer ($int64) 应用id
     * content:	string 评论内容
     * score:	integer ($int32) 评分 1-10
     */
    public static Observable<BaseMessage> postGameUserUserGameComment(@COMMENT_TYPE int comment_type, int app_id, String content, int score) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("comment_type", comment_type);
        jsonObject.put("app_id", app_id);
        jsonObject.put("content", content);
        jsonObject.put("score", score);
        return SheepApp.getInstance().getNetComponent().getApiService().postGameUserUserGameComment(jsonObject)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    /**
     * 用户评论用户
     * UserCommentReq{
     * content:	string  评论内容
     * user_comment_id:	integer ($int64) 评论id
     * }
     */
    public static Observable<BaseMessage> postGameUserUserComment(int user_comment_id, String content) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("user_comment_id", user_comment_id);
        jsonObject.put("content", content);
        return SheepApp.getInstance().getNetComponent().getApiService().postGameUserUserComment(jsonObject);
    }
    /**
     * 在自己的评论详情中，自己去回复 用户对自己的评论
     * UserCommentReq{
     * content:	string  评论内容
     * user_comment_id:	integer ($int64) 评论id
     * }
     */
    public static Observable<BaseMessage> postGameUserReplyComment(int user_comment_reply_id, String content) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("user_comment_reply_id", user_comment_reply_id);
        jsonObject.put("content", content);
        return SheepApp.getInstance().getNetComponent().getApiService().postGameUserReplyComment(jsonObject);
    }

}
