
package dev.sonpx.loyalty.mcp.reward.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Arrays;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum RunSchedule {
    DAILY("D"),
    MONTHLY("M"),
    ANNUALLY("A"),
    N_DAYS_AFTER_AOD("NDAA"),
    STATEMENT_CYCLE("SCD");

    @JsonValue
    private final String code;

    @JsonCreator
    public static RunSchedule fromCode(String code) {
        return Arrays.stream(values())
                .filter(e -> e.code.equalsIgnoreCase(code))
                .findFirst()
                .orElse(null);
    }
}
