package cn.axzo.msg.center.service.pending.request;

import cn.axzo.basics.common.exception.ServiceException;
import cn.axzo.msg.center.service.enums.CardBizState;
import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

/**
 * @author yanglin
 */
@Setter
@Getter
public class CardUpdateStateRequest extends CardUpdateRequest {

    /**
     * 业务状态, 结合模版配置控制状态戳(状态图片). bizState 和 cardCompleted 两选一
     */
    private CardBizState bizState;

    /**
     * 是否将卡片设置为完成状态, 结合模版配置控制按钮可见性.  bizState 和 cardCompleted 两选一
     */
    private Boolean cardCompleted;

    public void validate() {
        if (!isValid()) throw new ServiceException("cardCompleted 和 bizState 不能同时为空");
    }

    public boolean isValid() {
        return determineIsCardCompleted() || bizState != null;
    }

    public boolean determineIsCardCompleted() {
        return cardCompleted != null && cardCompleted;
    }

    @Override public String toString() {
        return JSON.toJSONString(this);
    }

}