package io.delphiplatform.api.v3.model.ads;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Set;

public enum GroupByAdsPerformance {

    AD_SET("ad_set"),
    AGE_BAND("age_band"),
    ARTIST("artist"),
    CAMPAIGN("campaign"),
    CATEGORY("category"),
    CHARTWEEK("chartweek"),
    DATE("date"),
    GENDER("gender"),
    LINK_TYPE("link_type"),
    LINK_URL("link_url"),
    MONTH("month"),
    OBJECTIVE("objective"),
    PLATFORM("platform"),
    PROJECT("project"),
    PROVIDER("provider"),
    REFERRER_DOMAIN("referrer_domain"),
    REFERRER_NAME("referrer_name"),
    REGION("region"),
    SUB_CATEGORY("sub_category"),
    WEEK("week");

    public static final Set<GroupByAdsPerformance> CAMPAIGN_BASED =
        Set.of(CAMPAIGN, CATEGORY, SUB_CATEGORY, OBJECTIVE);

    public static final Set<GroupByAdsPerformance> PROJECT_BASED =
        Set.of(PROJECT, ARTIST);

    private final String value;

    GroupByAdsPerformance(String value) {
        this.value = value;
    }

    @JsonCreator
    public static GroupByAdsPerformance fromValue(String value) {
        for (GroupByAdsPerformance b : GroupByAdsPerformance.values()) {
            if (b.value.equals(value)) {
                return b;
            }
        }
        throw new IllegalArgumentException("Unexpected value '" + value + "'");
    }

    @JsonValue
    public String getValue() {
        return value;
    }

    @Override
    public String toString() {
        return String.valueOf(value);
    }

    public String getAlias() {
        return name();
    }
}

