
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;

/**
 * {@link #SMS}
 * {@link #EMAIL}
 * {@link #PUSH_NOTIFICATIONS}
 */
@Getter
@RequiredArgsConstructor
public enum NotificationChannel {
    SMS("SMS"),
    EMAIL("EMAIL"),
    PUSH_NOTIFICATIONS("NOTIFY");

    @JsonValue
    private final String code;

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