package cokr.xit.ens.core.monitor.slack.struct;

import cokr.xit.ens.core.utils.MapDeserailizer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import lombok.experimental.SuperBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.entity.ContentType;
import org.springframework.http.HttpHeaders;

import java.util.Map;

@Slf4j
@SuperBuilder
public abstract class SlackSenderTemplate implements SlackSenderStrategy {

    protected String API_URL;

    protected final Gson gson = new GsonBuilder().registerTypeAdapter(Map.class, new MapDeserailizer()).disableHtmlEscaping().create();

    protected HttpHeaders createHeaders(ContentType contentType, String token) {
        HttpHeaders headers = new HttpHeaders();
        headers.add("Authorization", "Bearer " + token);
        headers.add("Content-type", contentType.toString());
        return headers;
    }

}
