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 PsSpeakerParams extends DeviceParams {

    public ProviderParams providerParams;

    public DeviceParams deviceParams;

    public BizConfigParams bizConfigParams;

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

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

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

        /**
         * appSecret
         */
        private String password;

        /**
         * 支付成功语音播报内容
         */
        private String customContent;

    }

    @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.getPassword())) {
            params.setPassword(StringKit.autoDesensitization(params.getPassword()));
        }

        return JSONObject.toJSONString(params);
    }

}
