<commit_before>// Package pagerduty provides an API library for interacting with PagerDuty.
// Much of this code is inspired by https://github.com/google/go-github <3
package pagerduty

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"net/url"
	"reflect"

	"github.com/danryan/env"
	"github.com/danryan/hal"
	"github.com/davecgh/go-spew/spew"
	"github.com/google/go-querystring/query"
)

var _ = spew.Sdump()

// Client is an API client
type Client struct {
	client        *http.Client
	APIKey        string
	Subdomain     string
	ServiceAPIKey string
	ScheduleID    string
	Room          string
	BaseURL       *url.URL

	Incidents *IncidentsService
	Users     *UsersService
}

type config struct {
	APIKey        string `env:"key=HAL_PAGERDUTY_API_KEY required"`
	Subdomain     string `env:"key=HAL_PAGERDUTY_SUBDOMAIN required"`
	ServiceAPIKey string `env:"key=HAL_PAGERDUTY_SERVICE_API_KEY"` // not sure if required
	ScheduleID    string `env:"key=HAL_PAGERDUTY_SCHEDULE_ID required"`
	Room          string `env:"key=HAL_PAGERDUTY_ROOM"`
}

// Config returns a pointer to an initialized config
func newConfig() *config {
	c := &config{}
	env.MustProcess(c)

	return c
}

// NewClient returns an API client.
func NewClient(httpClient *http.Client) *Client {
	if httpClient == nil {
		httpClient = http.DefaultClient
	}

	c := newConfig()
	u, _ := url.Parse(fmt.Sprintf("https://%s.pagerduty.com/api/v1/", c.Subdomain))

	client := &Client{
		client:        httpClient,
		APIKey:        c.APIKey,
		Subdomain:     c.Subdomain,
		ServiceAPIKey: c.ServiceAPIKey,
		BaseURL:       u,
	}<commit_msg>remove dependency on github.com/danryan/env<commit_after>// Package pagerduty provides an API library for interacting with PagerDuty.
// Much of this code is inspired by https://github.com/google/go-github <3
package pagerduty

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"net/url"
	"reflect"

	"github.com/danryan/hal"
	"github.com/davecgh/go-spew/spew"
	"github.com/google/go-querystring/query"
)

var _ = spew.Sdump()

// Client is an API client
type Client struct {
	client    *http.Client
	Subdomain string
	APIKey    string
	BaseURL   *url.URL

	Incidents *IncidentsService
	Users     *UsersService
}

// New returns a Client with the default http.Client
func New(sub, key string) *Client {
	return NewClient(sub, key, nil)
}

// NewClient returns a default cliente
func NewClient(sub, key string, httpClient *http.Client) *Client {
	if httpClient == nil {
		httpClient = http.DefaultClient
	}
	u, _ := url.Parse(fmt.Sprintf("https://%s.pagerduty.com/api/v1/", sub))
	client := &Client{
		client:    httpClient,
		APIKey:    key,
		Subdomain: sub,
		BaseURL:   u,
	}

{'fraction_non_alphanumeric': 0.11779816513761468, 'fraction_numerical': 0.0014678899082568807, 'mean_word_length': 3.513245033112583, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '6777641', 'n_tokens_mistral': 1019, 'n_tokens_neox': 983, 'n_words': 241}