package com.fshark.overseas.advert.modle;

import java.util.ArrayList;
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"),
    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());
    }

    public static boolean createRoleEvent(AppsFlyerEvent event) {
        return CREATE_ROLE.getName().equals(event.getEvent());
    }

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

    public static boolean orderEvent(AppsFlyerEvent event) {
        return PURCHASE.getName().equals(event.getEvent());
    }

}
