package com.munjaon.client.server.config;

import lombok.Getter;

@Getter
public enum ErrorCode {
    OK(200, "Success"),
    ERROR_DATA_IS_NULL(300, "DATA is null"),
    /* MSG_ID : 31X */
    ERROR_MSGID_IS_NULL(310, "MSG_ID is null"),
    ERROR_MSGID_IS_CAPACITY(311, "MSG_ID : SIZE is Zero Or Over"),
    /* SENDER : 32X */
    ERROR_SENDER_IS_NULL(320, "SENDER is null"),
    ERROR_SENDER_IS_CAPACITY(321, "SENDER : SIZE is Zero Or Over"),
    /* RECEIVER : 33X */
    ERROR_RECEIVER_IS_NULL(330, "RECEIVER is null"),
    ERROR_RECEIVER_IS_CAPACITY(331, "RECEIVER : SIZE is Zero Or Over"),
    ERROR_RECEIVER_IS_INVALID(332, "RECEIVER is invalid number"),
    /* SMS MESSAGE : 34X */
    ERROR_SMS_MSG_IS_NULL(340, "SMS MESSAGE is null"),
    ERROR_SMS_MSG_IS_CAPACITY(341, "SMS MESSAGE : SIZE is Zero Or Over"),
    /* LMS, MMS SUBJECT : 35X */
    ERROR_SUBJECT_IS_NULL(350, "Subject is null"),
    ERROR_SUBJECT_OVER_CAPACITY(351, "Subject is over capacity"),
    /* LMS, MMS MESSAGE : 36X */
    ERROR_MULTI_MESSAGE_IS_NULL(360, "Multimedia Message is null"),
    ERROR_MULTI_MESSAGE_OVER_CAPACITY(361, "Multimedia Message is over capacity"),
    /* MMS IMAGE : 37X */
    ERROR_MMS_IMAGE_IS_NULL(370, "MMS_IMAGE is not exist"),
    ERROR_MMS_IMAGE_IS_EXT(371, "MMS_IMAGE is not support extension"),
    ERROR_MMS_IMAGE_IS_NOT_PATH(372, "MMS_IMAGE is not exists"),
    ERROR_MMS_IMAGE_IS_OVER_CAPACITY(373, "MMS_IMAGE is over capacity"),
    /* KAKAO_SENDER_KEY : 38X */
    ERROR_KAKAO_SENDER_KEY_IS_NULL(380, "KAKAO_SENDER_KEY is null"),
    ERROR_KAKAO_SENDER_KEY_OVER_CAPACITY(381, "KAKAO_SENDER_KEY is over capacity"),
    /* KAKAO_TEMPLATE_CODE : 39X */
    ERROR_KAKAO_TEMPLATE_CODE_IS_NULL(390, "KAKAO_TEMPLATE_CODE is null"),
    ERROR_KAKAO_TEMPLATE_CODE_OVER_CAPACITY(391, "KAKAO_TEMPLATE_CODE is over capacity"),
    /* KAKAO_JSON_FILE : 40X */
    ERROR_KAKAO_JSON_FILE_IS_NULL(400, "KAKAO_JSON_FILE is not exist"),
    ERROR_KAKAO_JSON_FILE_IS_EXT(401, "KAKAO_JSON_FILE is not support extension"),
    ERROR_KAKAO_JSON_FILE_IS_NOT_PATH(402, "KAKAO_JSON_FILE is not exists"),
    ERROR_KAKAO_JSON_FILE_IS_OVER_CAPACITY(403, "KAKAO_JSON_FILE is over capacity"),

    ERROR_FILE_NOT_FOUND(390, "File Not Found"),
    ERROR_FILE_CAPACITY_EXCEED(391, "File capacity exceeded");



    private Integer code;
    private String message;

    ErrorCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static String getMessage(Integer code) {
        if (code == null) {
            return "etc";
        }

        for (ErrorCode resCode : values()) {
            if (resCode.getCode().equals(code)) {
                return resCode.getMessage();
            }
        }

        return "etc";
    }
}
