package com.emato.ich.api;

import android.content.Context;
import android.view.View;

import com.emato.ich.entity.vo.ResponseData;
import com.emato.ich.utils.ToastUtils;
import com.google.android.material.snackbar.Snackbar;

import java.util.Arrays;

public enum ICSPResponseCodeEnum {

    OK("0", ""),
    SYSTEM_ERROR("50000", "系统异常"),
    FILED_VALID_FAILED("50001", "请输入正确的信息"),

    DELIVERER_AUTH("50003", "需要登录快递员操作才能操作"),
    CABINET_NOT_FOUND("50004", "机柜信息不存在"),
    DELIVERER_NOT_FOUND("50005", "投递员信息不存在"),
    CABINET_LOCKER_NOT_AVAILABLE("50006", "暂无可用柜门"),
    ORDER_NOT_FOUND("50007", "订单号不存在"),
    PICK_UP_NOT_FOUND("50008", "取货码不存在"),
    MAIL_NO_NOT_FOUND("50010", "快递单号不存在"),
    MAIL_NO_QUERY_FAIL("50011", "获取快递信息失败"),
    ORDER_CONFIRM_FAIL("50012", "已取消或关闭的订单无法确认完成"),
    PREPARED_ORDER_FAILED("50013", "该单号已投递，无法重复投递")
    ;

    public static void responseHint(Context context, ResponseData responseData){
        Arrays.stream(ICSPResponseCodeEnum.values()).forEach(icspResponseCodeEnum -> {
            if (responseData != null && !responseData.getCode().equals(ICSPResponseCodeEnum.OK.getCode()) && responseData.getCode().equals(icspResponseCodeEnum.getCode())) {
                ToastUtils.make(context, responseData.getMsg());
            }
        });
    }

    private String code;

    private String msg;

    ICSPResponseCodeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }
}
