
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 PostTransactionUnderPa {
    BY_BASED_ON_ATG("ACA"), // PA  based on ATG of Pool
    BY_HIGHEST_SPEND("PHS"), // PA with highest spend in the past month + month to date
    BY_LOWEST_SPEND("PL"), // PA with lowest spend in the past month + month-to-date
    BY_MOST_RECENT("PM"); // PA with most recent customer-initiated transaction

    @JsonValue
    private final String code;

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