package com.fshark.overseas.advert.modle;

import com.fshark.overseas.advert.util.Constants;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zhouml [zhouml@kingnet.com]
 * @date 2019-03-01
 */
public enum EventTypeEnum {

    /*
        第一次创角作为注册
    */
    REGISTER("createrole"),
    CREATE_ROLE("createrole"),
    SDK_LOGIN("sdk login"),
    FAST_LOGIN("fast login"),
    GAME_LOGIN("gamelogin"),
    ROLE_LOGIN("rolelogin"),
    ACTIVATION("install"),
    PURCHASE("af_purchase"),
    RE_ENGAGEMENT("re-engagement"),
    RE_ATTRIBUTION("re-attribution"),
    HEARTBEAT("heartbeat"),
    LV_2("lv 2");

    private String name;

    EventTypeEnum(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public static List<String> getEvents() {
        return Arrays.stream(values()).map(EventTypeEnum::getName).distinct().collect(Collectors.toList());
    }

    public static boolean roleLoginEvent(AppsFlyerEvent event) {
        return (ROLE_LOGIN.getName().equals(event.getEvent())
                || CREATE_ROLE.getName().equals(event.getEvent())) && !event.getUid().equals(Constants.DEFAULT_FIELD_VALUE);
    }

    public static boolean createRoleEvent(AppsFlyerEvent event) {
        return CREATE_ROLE.getName().equals(event.getEvent()) && !event.getUid().equals(Constants.DEFAULT_FIELD_VALUE);
    }


    public static boolean roleEvent(AppsFlyerEvent event) {
        return (CREATE_ROLE.getName().equals(event.getEvent()) || ROLE_LOGIN.getName().equals(event.getEvent())) && !event.getUid().equals(Constants.DEFAULT_FIELD_VALUE);
    }


    public static boolean installEvent(AppsFlyerEvent event) {
        return (ACTIVATION.getName().equals(event.getEvent()) || RE_ENGAGEMENT.getName().equals(event.getEvent()) || RE_ATTRIBUTION.getName().equals(event.getEvent()))&& !event.getUid().equals(Constants.DEFAULT_FIELD_VALUE);
    }

    public static boolean orderEvent(AppsFlyerEvent event) {
        return PURCHASE.getName().equals(event.getEvent()) && !event.getUid().equals(Constants.DEFAULT_FIELD_VALUE);
    }

    public static boolean notHeartBeatEvent(AppsFlyerEvent event) {
        return !HEARTBEAT.getName().equals(event.getEvent()) && !event.getUid().equals(Constants.DEFAULT_FIELD_VALUE);
    }

}
