package com.jeequan.jeepay.thirdparty.channel.yspay.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * TODO
 *
 * @author crystal
 * @date 2023/12/1 18:26
 */
@Data
public class ReqMethod {

    private static final String DOMAIN = "https://ysgate.ysepay.com/openapi/";

    private static final String DEFAULT_VERSION = "1.0";

    private static final String VERSION_1_1 = "1.1";

    private static final String VERSION_1_2 = "1.2";

    private static final String VERSION_1_3 = "1.3";

    @Getter
    @AllArgsConstructor
    public enum Method {

        ADD_CUST_INFO_APPLY("t1/smsc/addCustInfoApply", VERSION_1_1, "进件资料上送"),
        MODIFY_CUST_INFO_APPLY("smsc/modifyCustInfoApply", VERSION_1_1, "未进件成功时资料修改"),
        SETTLE_INFO_QUERY("pregate/settle/progressNotOrg", VERSION_1_1, "结算进度查询(只支持结算周期为T1和D1的结算进度查询)"),
        UPLOAD("FILE/SMSC/UPLOAD", DEFAULT_VERSION, "进件图片上传"),
        AUDIT_CUST_INFO_APPLY("t1/smsc/auditCustInfoApply", VERSION_1_1, "资料确认初审"),
        QUERY_CUST_APPLY("smsc/queryCustApply", VERSION_1_1, "查询进件状态"),
        SIGN("t1/smsc/sign", VERSION_1_1, "合同签约申请"),
        SEND_SMS_OR_EMAIL_MSG("smsc/sign/sendSmsOrEmailMsg", DEFAULT_VERSION, "签约短信重发"),
        QUERY_AUTH_INFO("smsc/saas/constract/queryAuthInfo", VERSION_1_1, "签约状态查询"),
        QUERY_CONTRACT("smsc/sign/queryContract", DEFAULT_VERSION, "电子合同状态查询"),
        SWEEP_REPORT("smsc/saas/sweep/sweepreport", DEFAULT_VERSION, "渠道报备"),
        CHANGE_MERC_BASE_INFO("smsc/changeMercBaseInfo", VERSION_1_3, "基本信息变更"),
        UPLOAD_CHANGE_PIC("file/smsc/uploadChangePic", DEFAULT_VERSION, "商户信息变更图片上传"),
        QUERY_CUST_CHANGE("smsc/queryCustChange", VERSION_1_2, "变更状态查询"),
        CHANGE_MERC_STL_ACC_INFO("t1/smsc/changeMercStlAccInfo", VERSION_1_3, "结算信息变更"),
        CHANGE_RATE("smsc/changeRate", VERSION_1_3, "费率变更"),
        OPEN_ONLINE_PAY("smsc/saas/authority/online", DEFAULT_VERSION, "开通/关闭线上D0权限"),
        REGION_LIST("pregate/trade/findCmmtAreaInfoList", DEFAULT_VERSION, "地区信息查询"),

        ALI_PAY_GET_AUTH_STATE("pregate/alipay/getAuthState", DEFAULT_VERSION, "支付宝授权状态查询"),
        WX_PAY_GET_AUTH_STATE("trade/scan/wechat/auth/getAuthState", DEFAULT_VERSION, "微信授权状态查询"),
        GET_REPORT_INFO("report/scan/union/repAndAppIdQry", DEFAULT_VERSION, "查询报备信息"),

        APPID_ADD_OR_UPDATE("report.scan.union.appIdAddOrUpdate", DEFAULT_VERSION, "新增/修改appid"),

        AUTH_PATH_ADD("report.scan.union.authPathAdd", DEFAULT_VERSION, "新增/修改appid"),

        QUERY_SETTLE("pregate.settle.progressNotOrg", DEFAULT_VERSION, "新增/修改appid"),

        /**
         * 查询银盛D0分账
         */
        QUERY_D0_DIVISION_SETTLE("trade.division.immediately.settleProgrQry", DEFAULT_VERSION, "查询银盛D0分账"),
        ;

        private final String method;

        private final String version;

        private final String desc;

        public String getVersion() {
            if (StringUtils.isEmpty(this.version)) {
                return DEFAULT_VERSION;
            }
            return version;
        }
    }

    /**
     * 获取请求接口地址
     *
     * @param method
     * @return
     */
    public static String getUrl(Method method) {
        return DOMAIN + method.getMethod().replace(".", "/");
    }

    /**
     * 获取返回参数的最外层key
     *
     * @param method
     * @return
     */
    public static String getResponseKey(Method method) {
        return method.getMethod().replace(".", "_") + "_response";
    }
}
