package com.jeequan.jeepay.core.model.oauth2;

import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.constants.CS;

/***
* oauth2 参数定义
*
* @author terrfly
*
* @date 2022/11/10 9:00
*/
public abstract class Oauth2Params {

    public static Oauth2Params factory(String ifCode, String paramsStr){

        if(CS.IF_CODE.WXPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, WxpayOauth2Params.class);
        }else if(CS.IF_CODE.ALIPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, AlipayOauth2Params.class);
        }
        return null;
    }

    public static <T> T factory(String ifCode, String paramsStr, Class<T> cls){

        if(CS.IF_CODE.WXPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, cls);
        }else if(CS.IF_CODE.ALIPAY.equals(ifCode)){
            return JSONObject.parseObject(paramsStr, cls);
        }
        return null;
    }

    /**
     *  敏感数据脱敏
    */
    public abstract String deSenData();

}
