package top.octopusyan.manager.http;

import top.octopusyan.http.api.NotParamApi;
import top.octopusyan.http.api.ParamApi;
import top.octopusyan.http.api.PathParamApi;
import top.octopusyan.http.config.BodyType;
import top.octopusyan.http.config.HttpConstant;
import top.octopusyan.manager.ProxyManager;
import top.octopusyan.manager.http.request.*;

/**
 * @author : octopus yan
 * @email : octopus_yan@foxmail.com
 * @description :  业务请求接口
 * @create : 2022-4-1 23:08
 */
public class Api {
    /** 登录接口 获取Cookie */
    public static final ParamApi<LoginParam, String> Login = new ParamApi<>(
            "/?action=login&page=login",
            HttpConstant.Method.POST,
            BodyType.FORM
    );

    /** 发送邮箱验证码 */
    public static final ParamApi<SendEmailCheckParam, String> SendEmailCheck = new ParamApi<>(
            "/?action=sendmail",
            HttpConstant.Method.POST,
            BodyType.FORM
    );

    /** 用户注册 */
    public static final ParamApi<RegisterParam, String> Register = new ParamApi<>(
            "/?action=register&page=register",
            HttpConstant.Method.POST,
            BodyType.FORM
    );

    /** 找回密码 */
    public static ParamApi<FindPassParam, String> findpass = new ParamApi<>(
            "/?action=findpass&page=findpass",
            HttpConstant.Method.POST,
            BodyType.FORM
    );

    /** 获取服务器配置 */
    public static NotParamApi<String> getServerConfiguration(int node){
        return new NotParamApi<>(
                "/?page=panel&module=configuration&server="+node,
                HttpConstant.Method.GET
        );
    }

    /** 隧道列表 */
    public static final NotParamApi<String> ProxyList = new NotParamApi<>(
            "/?page=panel&module=proxies",
            HttpConstant.Method.GET
    );

    /** 隧道详情 */
    public static PathParamApi<String> ProxyInfo() {
        return new PathParamApi<>(
                "/?page=panel&module=proxies&getproxyinfo={0}&csrf=" + ProxyManager.getCsrf(),
                HttpConstant.Method.GET
        );
    }

    /** 添加隧道 */
    public static ParamApi<ProxySetup, String> AddProxy() {
        return new ParamApi<>(
                "/?page=panel&module=addproxy&action=addproxy&csrf=" + ProxyManager.getCsrf(),
                HttpConstant.Method.POST,
                BodyType.FORM
        );
    }

    /** 删除隧道 */
    public static PathParamApi<String> DeleteProxy() {
        return new PathParamApi<>(
                "/?page=panel&module=proxies&delete={0}&csrf=" + ProxyManager.getCsrf(),
                HttpConstant.Method.GET
        );
    }

    /** 随机端口 */
    public static NotParamApi<String> RandomPort() {
        return new NotParamApi<>(
                "/?page=panel&module=addproxy&randomport&csrf=" + ProxyManager.getCsrf(),
                HttpConstant.Method.GET
        );
    }
}
