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

import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.utils.StringKit;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/***
* 厂商设备参数   智谷物联
*
* @author zx
*
* @date 2021/12/30 9:01
*/
@Data
public class ZgwlParams extends DeviceParams {

    public ZgwlParams(ProviderParams providerParams) {
        this.providerParams = providerParams;
    }

    public ZgwlParams(ProviderParams providerParams, DeviceParams deviceParams, BizConfigParams bizConfigParams) {
        this.providerParams = providerParams;
        this.deviceParams = deviceParams;
        this.bizConfigParams = bizConfigParams;
    }

    public ProviderParams providerParams;

    public DeviceParams deviceParams;

    public BizConfigParams bizConfigParams;

    @Data
    public static class ProviderParams {
        /**
         * accessKeyId
         */
        private String accessKeyId;

        /**
         * accessKeySecret
         */
        private String accessKeySecret;

        /**
         * 实例ID
         */
        private String instanceId;

        /**
         * 公网接入点
         */
        private String endPoint;

        /**
         * Topic
         */
        private String topic;

        /**
         * GroupId
         */
        private String groupId;
    }

    @Data
    public static class DeviceParams {

        /**
         * 设备号
         */
        private String deviceNo;

    }

    @Data
    public static class BizConfigParams {

        /**
         * 打印联数
         */
        private Integer printNum;

        /**
         * 打印机模式
         */
        private Byte printMode;

    }

    @Override
    public String deSenData() {
        ProviderParams params = this.getProviderParams();
        if (params != null && StringUtils.isNotBlank(params.getAccessKeySecret())) {
            params.setAccessKeySecret(StringKit.autoDesensitization(params.getAccessKeySecret()));
        }

        return JSONObject.toJSONString(params);
    }

}
