package fr.mmarie.api.gitlab;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.annotations.VisibleForTesting;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.validation.constraints.NotNull;
import java.util.List;

@Data
@NoArgsConstructor
@ToString(of = "type")
@JsonIgnoreProperties(ignoreUnknown = true)
public class Event {

    public enum Type {
        PUSH("push"),
        TAG_PUSH("tag_push"),
        ISSUE("issue"),
        NOTE("note"),
        MERGE_REQUEST("merge_request");

        private String label;

        Type(String label) {
            this.label = label;
        }

        @Override
        public String toString() {
            return label;
        }
    }

    @JsonProperty("object_kind")
    @NotNull
    private Type type;

    @JsonProperty("before")
    private String before;

    @JsonProperty("after")
    private String after;

    @JsonProperty("ref")
    private String ref;

    @JsonProperty("user_id")
    private Long userId;

    @JsonProperty("user_name")
    private String userName;

    @JsonProperty("user_email")
    private String userEmail;

    @JsonProperty("project_id")
    private Long projectId;

    @JsonProperty("repository")
    private Repository repository;

    @JsonProperty("commits")
    private List<Commit> commits;

    @VisibleForTesting
    public Event(Type type) {
        this.type = type;
    }
}

@@ -496,16 +496,8 @@
 PUSH
-(%22push%22)
 ,%0A  
@@ -514,20 +514,8 @@
 PUSH
-(%22tag_push%22)
 ,%0A  
@@ -529,17 +529,8 @@
 SSUE
-(%22issue%22)
 ,%0A  
@@ -543,16 +543,8 @@
 NOTE
-(%22note%22)
 ,%0A  
@@ -566,219 +566,8 @@
 UEST
-(%22merge_request%22);%0A%0A        private String label;%0A%0A        Type(String label) %7B%0A            this.label = label;%0A        %7D%0A%0A        @Override%0A        public String toString() %7B%0A            return label;%0A        %7D
 %0A   

remove useless labels from event types