
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 TriggerCampaignRule {
    AWARD("AWD"),
    REDEEM("RED");

    @JsonValue
    private final String code;

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