<commit_before>package mackerel

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

// Channel represents a Mackerel notification channel.
// ref. https://mackerel.io/api-docs/entry/channels
type Channel struct {
	ID string `json:"id"`
	ChannelWithoutID
}

// ChannelWithoutID represents a Mackerel notification channel without the ID.
type ChannelWithoutID struct {
	Name string `json:"name"`
	Type string `json:"type"`

	// Exists when the type is "email"
	Emails  []string `json:"emails,omitempty"`
	UserIDs []string `json:"userIds,omitempty"`

	// Exists when the type is "slack"
	Mentions struct {
		OK       string `json:"ok,omitempty"`
		Warning  string `json:"warning,omitempty"`
		Critical string `json:"critical,omitempty"`
	} `json:"mentions,omitempty"`
	EnabledGraphImage bool `json:"enabledGraphImage,omitempty"`

	// Exists when the type is "slack" or "webhook"
	URL string `json:"url,omitempty"`

	// Exists when the type is "email", "slack", or "webhook"
	Events []string `json:"events,omitempty"`
}

// ListChannels requests the channels API and returns a list of Channel
func (c *Client) ListChannels() ([]*Channel, error) {
	req, err := http.NewRequest("GET", c.urlFor("/api/v0/channels").String(), nil)
	if err != nil {
		return nil, err
	}<commit_msg>separate the mentions struct definition<commit_after>package mackerel

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

// Channel represents a Mackerel notification channel.
// ref. https://mackerel.io/api-docs/entry/channels
type Channel struct {
	ID string `json:"id"`
	ChannelWithoutID
}

// ChannelWithoutID represents a Mackerel notification channel without the ID.
type ChannelWithoutID struct {
	Name string `json:"name"`
	Type string `json:"type"`

	// Exists when the type is "email"
	Emails  []string `json:"emails,omitempty"`
	UserIDs []string `json:"userIds,omitempty"`

	// Exists when the type is "slack"
	Mentions          Mentions `json:"mentions,omitempty"`
	EnabledGraphImage bool     `json:"enabledGraphImage,omitempty"`

	// Exists when the type is "slack" or "webhook"
	URL string `json:"url,omitempty"`

	// Exists when the type is "email", "slack", or "webhook"
	Events []string `json:"events,omitempty"`
}

// Mentions represents the structure used for slack channel mentions
type Mentions struct {
	OK       string `json:"ok,omitempty"`
	Warning  string `json:"warning,omitempty"`
	Critical string `json:"critical,omitempty"`
}

// ListChannels requests the channels API and returns a list of Channel
func (c *Client) ListChannels() ([]*Channel, error) {
	req, err := http.NewRequest("GET", c.urlFor("/api/v0/channels").String(), nil)
	if err != nil {
		return nil, err
	}
{'fraction_non_alphanumeric': 0.13203300825206302, 'fraction_numerical': 0.0007501875468867217, 'mean_word_length': 4.6265822784810124, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1138648', 'n_tokens_mistral': 845, 'n_tokens_neox': 817, 'n_words': 262}