package com.yutou.biliapi.api;

import com.yutou.biliapi.bean.login.CheckCookieBean;
import com.yutou.biliapi.bean.login.LoginInfoBean;
import com.yutou.biliapi.bean.login.QRCodeGenerateBean;
import com.yutou.common.okhttp.FileBody;
import com.yutou.common.okhttp.HttpBody;
import retrofit2.Call;
import retrofit2.http.*;

public interface LoginApi {
    /**
     * 获取登陆二维码
     */
    @GET("/x/passport-login/web/qrcode/generate")
    Call<HttpBody<QRCodeGenerateBean>> getQRCodeGenerate();

    /**
     * 通过二维码登录
     */
    @GET("/x/passport-login/web/qrcode/poll")
    Call<HttpBody<LoginInfoBean>> loginQRCode(@Query("qrcode_key") String qrcode_key);

    /**
     * 检查cookie是否有效，太麻烦了以后做
     */
    @GET("x/passport-login/web/cookie/info")
    Call<HttpBody<CheckCookieBean>> checkCookie();

    @GET("https://www.bilibili.com/correspond/1/{correspondPath}")
    Call<FileBody<String>> getCorrespond(@Path("correspondPath") String correspondPath);

    @POST("/x/passport-login/web/cookie/refresh")
    @FormUrlEncoded
    Call<HttpBody<LoginInfoBean>> refreshCookie(@Field("csrf") String bili_jct
            , @Field("refresh_csrf") String refresh_csrf
            , @Field("source") String source
            , @Field("refresh_token") String refresh_token
    );
    @POST("/x/passport-login/web/confirm/refresh")
    @FormUrlEncoded
    Call<HttpBody<LoginInfoBean>> confirmRefreshCookie(
             @Field("csrf") String refresh_csrf
            , @Field("refresh_token") String old_token
    );

}
