package com.tzld.piaoquan.api.common.enums.wecom;

import lombok.Getter;

import java.util.Objects;

@Getter
public enum WeComThirdPartyCallBackTypeEnum {

    // 登录回调
    SCAN_CODE(100001, "扫码返回数据"),
    CONFIRM_SCAN_CODE(100002, "确认扫码返回数据"),
    CANCEL_SCAN_CODE(100003, "取消扫码返回"),
    NEED_VERIFY_CODE(100004, "需要输入验证码消息回调"),
    LOGIN_SUCCESS(104001, "登录成功返回数据"),

    // 断开回调
    SECOND_VERIFY_NOTIFY(100012, "二次验证消息通知"),
    LOGIN_END(100005, "手机端结束登录"),
    OTHER_DEVICE_LOGIN(100008, "当前账号在其他设备登录"),
    QR_CODE_SCAN_TIMEOUT(100009, "初始化接口二维码扫码超时断开"),
    EXCEPTION_DISCONNECT(100007, "异常断开"),

    other(999, "其他");

    private final Integer val;
    private final String description;

    WeComThirdPartyCallBackTypeEnum(Integer val, String description) {
        this.val = val;
        this.description = description;
    }

    public static WeComThirdPartyCallBackTypeEnum from(Integer val) {
        for (WeComThirdPartyCallBackTypeEnum typeEnum : WeComThirdPartyCallBackTypeEnum.values()) {
            if (Objects.equals(typeEnum.getVal(), val)) {
                return typeEnum;
            }
        }

        return other;
    }
}
