package com.github.seratch.jslack.lightning.request.builtin;

import com.github.seratch.jslack.common.json.GsonFactory;
import com.github.seratch.jslack.lightning.context.builtin.DefaultContext;
import com.github.seratch.jslack.lightning.request.Request;
import com.github.seratch.jslack.lightning.request.RequestHeaders;
import com.github.seratch.jslack.lightning.request.RequestType;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import lombok.ToString;

@ToString(callSuper = true)
public class EventRequest extends Request<DefaultContext> {

    private final String requestBody;
    private final RequestHeaders headers;
    private final String eventType;

    public EventRequest(
            String requestBody,
            RequestHeaders headers) {
        this.requestBody = requestBody;
        this.headers = headers;
        JsonObject payload = GsonFactory.createSnakeCase().fromJson(requestBody, JsonElement.class).getAsJsonObject();
        this.eventType = payload.get("event").getAsJsonObject().get("type").getAsString();
        this.getContext().setTeamId(payload.get("team_id").getAsString());
    }

    private DefaultContext context = new DefaultContext();

    @Override
    public DefaultContext getContext() {
        return context;
    }

    @Override
    public RequestType getRequestType() {
        return RequestType.Event;
    }

    @Override
    public String getRequestBodyAsString() {
        return requestBody;
    }

    @Override
    public RequestHeaders getHeaders() {
        return this.headers;
    }

    public String getEventType() {
        return eventType;
    }
}

@@ -1133,16 +1133,196 @@
 ing());%0A
+        JsonElement enterpriseId = payload.get(%22enterprise_id%22);%0A        if (enterpriseId != null) %7B%0A            this.getContext().setTeamId(enterpriseId.getAsString());%0A        %7D%0A
     %7D%0A%0A 

Add enterprise_id in event request context