package com.gh.gamecenter.login.retrofit;

import com.gh.gamecenter.login.entity.LoginTokenEntity;
import com.gh.gamecenter.login.entity.UserInfoEntity;

import io.reactivex.Observable;
import io.reactivex.Single;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Url;

public interface ApiService {

    /**
     * 刷新accessToken
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @POST()
    Observable<LoginTokenEntity> refreshToken(@Url String url, @Body RequestBody body);

    /**
     * 修改用户信息
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @PUT("users/{user_id}")
    Observable<ResponseBody> changeUserInfo(@Body RequestBody body, @Path("user_id") String userId);

    /**
     * 注销登录
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @POST("logout")
    Observable<ResponseBody> logout();

    /**
     * 获取第三方授权登陆信息
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @POST("/users/grant")
    Observable<LoginTokenEntity> grant(@Body RequestBody body);

    /**
     * 获取用户信息（头像/用户名）
     */
    @POST
    Observable<UserInfoEntity> getUserInfo(@Url String url);

    // Header作为区分 userinfo 的唯一标识
    @POST()
    Observable<UserInfoEntity> getRetryUserInfo(@Url String url, @Header("retry") String tag); // 在OkHttpRetryInterceptor使用主要是不允许这个接口重试

    /**
     * 获取用户礼仪考试状态
     */
    @GET("users/{user_id}/exam/etiquette")
    Single<ResponseBody> getUserRegulationTestStatus(@Path("user_id") String userId);

    /**
     * 手机登录获取验证码
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @POST("login/mobile?step=1")
    Observable<ResponseBody> loginByCaptcha(@Body RequestBody body);

    /**
     * 手机登录
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @POST("login/mobile?step=2")
    Observable<LoginTokenEntity> loginByMobile(@Body RequestBody body);

    /**
     * QQ登录
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @POST("login/qq")
    Observable<LoginTokenEntity> loginByQQ(@Body RequestBody body);

    /**
     * 微博登录
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @POST("login/weibo")
    Observable<LoginTokenEntity> loginByWeibo(@Body RequestBody body);

    /**
     * 微信登录
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @POST("login/wechat")
    Observable<LoginTokenEntity> loginByWechat(@Body RequestBody body);

    /**
     * 抖音登录
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @POST("login/douyin")
    Observable<LoginTokenEntity> loginByDouYin(@Body RequestBody body);

    /**
     * 一键登录
     */
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @POST("login/mobile_oauth")
    Observable<LoginTokenEntity> loginByOauth(@Body RequestBody body);

    /**
     * 更新实名认证
     */
    @POST("certification")
    Single<ResponseBody> postCertification(@Body RequestBody body);

    /**
     * 同步从其他游戏传过来的实名认证
     */
    @POST("./certification:sync")
    Observable<ResponseBody> postSyncCertification(@Body RequestBody body);


}
