//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.tmerclub.cloud.payment.allinpay.bean;

import com.tmerclub.cloud.payment.allinpay.util.OpenUtils;
import lombok.Data;
import lombok.ToString;

import java.io.Serializable;
/**
 * @author lanhai
 */
@Data
@ToString
public class OpenConfig implements Serializable {
    private static final long serialVersionUID = 1L;
    private String url;
    private String appId;
    private String secretKey;
    private String certPath;
    private String certPwd;
    private String tlCertPath;
    private String format;
    private String charset;
    private String signType;
    private String version;
    private String notifyUrl;

    public OpenConfig(String url, String appId, String secretKey, String certPath, String certPwd, String tlCertPath) {
        this(url, appId, secretKey, certPath, certPwd, tlCertPath, "SHA256WithRSA");
    }

    public OpenConfig(String url, String appId, String secretKey, String certPath, String certPwd, String tlCertPath, String signType) {
        this.format = "JSON";
        this.charset = "utf-8";
        this.version = "1.0";
        this.url = url;
        this.appId = appId;
        this.secretKey = secretKey;
        this.certPath = certPath;
        this.certPwd = certPwd;
        this.tlCertPath = tlCertPath;
        this.signType = signType;
    }

    public OpenConfig() {
        this.format = "JSON";
        this.charset = "utf-8";
        this.signType = "SHA256WithRSA";
        this.version = "1.0";
    }

    public void validate() {
        OpenUtils.assertNotNull(this.url, "property url must be configured");
        OpenUtils.assertNotNull(this.appId, "property appId must be configured");
        OpenUtils.assertNotNull(this.secretKey, "property secretKey must be configured");
        OpenUtils.assertNotNull(this.certPath, "property certPath must be configured");
        OpenUtils.assertNotNull(this.certPwd, "property certPwd must be configured");
        OpenUtils.assertNotNull(this.tlCertPath, "property tlCertPath must be configured");
    }
}
