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

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import dev.sonpx.loyalty.mcp.enums.EnumBase;
import java.util.Arrays;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum ScheduleRecurrenceType implements EnumBase {
    ONE_TIME("O"),
    RECURRING("R");

    @JsonValue
    private final String code;

    @JsonCreator
    public static ScheduleRecurrenceType fromCode(String code) {
        return Arrays.stream(values())
                .filter(scheduleType -> scheduleType.getCode().equals(code))
                .findFirst()
                .orElse(null);
    }
}
