
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 Friday, 10-Nov-2023
 * al-capping-limit-type
 */
@Getter
@RequiredArgsConstructor
public enum RewardLimitResultType {
    TRACKED_IN_COUNTER("C"),
    PER_CAMPAIGN_RULE("R");

    @JsonValue
    private final String code;

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