package com.jeequan.jeepay.core.model.params.adapay;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.annotate.ChannelMchId;
import com.jeequan.jeepay.core.constants.ChannelMchIdTypeEnum;
import com.jeequan.jeepay.core.model.params.NormalMchParams;
import com.jeequan.jeepay.core.utils.StringKit;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/*
 * 汇付天下 配置信息
 *
 * @author pangxiaoyu
 *
 * @date 2021/6/8 18:02
 */
@Data
public class AdapayNormalMchParams extends NormalMchParams {

    /** 是否沙箱环境 */
    private Byte sandbox;

    /** appId **/
    @ChannelMchId(type = ChannelMchIdTypeEnum.MCH_NO)
    private String appId;

    /** apiKey **/
    private String apiKey;

    /** rsaPrivateKey **/
    private String rsaPrivateKey;

    /** publicKey 汇付公钥**/
    private String publicKey;

    @Override
    public String deSenData() {

        AdapayNormalMchParams adaParams = this;
        if (StringUtils.isNotBlank(this.apiKey)) {
            adaParams.setApiKey(StringKit.autoDesensitization(this.apiKey));
        }
        if (StringUtils.isNotBlank(this.publicKey)) {
            adaParams.setPublicKey(StringKit.autoDesensitization(this.publicKey));
        }
        if (StringUtils.isNotBlank(this.rsaPrivateKey)) {
            adaParams.setRsaPrivateKey(StringKit.autoDesensitization(this.rsaPrivateKey));
        }
        return ((JSONObject) JSON.toJSON(adaParams)).toJSONString();
    }

}
