<commit_before>package notifications

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"

	"github.com/pivotal-golang/lager"
)

//go:generate counterfeiter . Notifier

type Notifier interface {
	SendNotification(message string) error
}

type slackNotifier struct {
	webhookUrl string
	client     *http.Client
	logger     lager.Logger
}

type slackNotification struct {
	Text string `json:"text"`
}

func NewSlackNotifier(logger lager.Logger, webhookUrl string) Notifier {
	if webhookUrl == "" {
		return &nullSlackNotifier{
			logger: logger,
		}
	}

	return &slackNotifier{
		webhookUrl: webhookUrl,
		client:     &http.Client{},
		logger:     logger,
	}
}

func (n *slackNotifier) SendNotification(message string) error {
	logger := n.logger.Session("send-notification", lager.Data{
		"message": message,
	})

	notification := &slackNotification{Text: message}
	body, err := json.Marshal(notification)
	if err != nil {
		logger.Error("unmarshal-faiiled", err)
		return err
	}
	req, err := http.NewRequest("POST", n.webhookUrl, bytes.NewBuffer(body))
	if err != nil {
		logger.Error("request-failed", err)
		return err
	}
	resp, _ := n.client.Do(req)
	if err != nil {
		logger.Error("response-error", err)<commit_msg>rename webhookUrl to webhookURL<commit_after>package notifications

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"

	"github.com/pivotal-golang/lager"
)

//go:generate counterfeiter . Notifier

type Notifier interface {
	SendNotification(message string) error
}

type slackNotifier struct {
	logger lager.Logger

	webhookURL string
	client     *http.Client
}

type slackNotification struct {
	Text string `json:"text"`
}

func NewSlackNotifier(logger lager.Logger, webhookURL string) Notifier {
	if webhookURL == "" {
		return &nullSlackNotifier{
			logger: logger,
		}
	}

	return &slackNotifier{
		webhookURL: webhookURL,
		client:     &http.Client{},
		logger:     logger,
	}
}

func (n *slackNotifier) SendNotification(message string) error {
	logger := n.logger.Session("send-notification", lager.Data{
		"message": message,
	})

	notification := &slackNotification{Text: message}
	body, err := json.Marshal(notification)
	if err != nil {
		logger.Error("unmarshal-faiiled", err)
		return err
	}

	req, err := http.NewRequest("POST", n.webhookURL, bytes.NewBuffer(body))
	if err != nil {
		logger.Error("request-failed", err)
		return err
	}

	resp, err := n.client.Do(req)
	if err != nil {
		logger.Error("response-error", err)
{'fraction_non_alphanumeric': 0.1292157659488013, 'fraction_numerical': 0.0, 'mean_word_length': 4.271948608137045, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2752950', 'n_tokens_mistral': 890, 'n_tokens_neox': 842, 'n_words': 193}