
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;

/**
 * Created by SonPhung on Monday, 20-Jul-2026
 */
@Getter
@RequiredArgsConstructor
public enum VelocityPeriod {
    PER_QUARTER("Q"),
    PER_WEEK("W"),
    PER_YEAR("Y"),
    PER_DAY("D"),
    PER_MONTH("M");

    @JsonValue
    private final String code;

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