package com.caliverse.admin.domain.entity.web3;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum ResponseErrorCode {
    FIN_GRHST_000("FIN.GRHST_000","not found data"),
    FIN_PWRH_001("FIN.PWRH.001", "server_type 누락"),
    FIN_PWRH_002("FIN.PWRH.002", "requestor 누락"),
    FIN_PWRH_004("FIN.PWRH.004", "history_message 누락"),
    FIN_PWRH_005("FIN.PWRH.005", "amount 값은 음수여야한다."),
    RET_PWRH_001("RET.PWRH.101", "DB Insert Fail"),
    FIN_GWRH_000("FIN.GWRH.000", "not found data"),
    FIN_GWRH_001("FIN.GWRH.001", "invalid objectId format");

    private final String code;
    private final String message;

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

    public static Optional<ResponseErrorCode> fromCode(String code) {
        return Arrays.stream(ResponseErrorCode.values())
                .filter(errorCode -> errorCode.getCode().equals(code))
                .findFirst();
    }
}
