<commit_before>package layer

import (
	"fmt"
	"net/http"
	"strings"
	"time"
)

const (
	base   = "https://api.layer.com"
	prefix = "apps"
)

// Layer is an instance of a layer api object
type Layer struct {
	token   string
	appID   string
	version string
	timeout time.Duration
}

// Parameters contains the options passed in from the caller of request
type Parameters struct {
	dedupe *string
	path   string
	body   []byte
}

// NewLayer returns a new instance of a Layer struct
func NewLayer(token, appID, version string, timeout time.Duration) *Layer {
	return &Layer{
		token:   token,
		appID:   appID,
		version: version,
		timeout: timeout,
	}
}

func (l *Layer) request(method string, p Parameters) (*http.Response, error) {
	method = strings.ToUpper(method)
	client := http.Client{Timeout: l.timeout}
	req, err := http.NewRequest(method, fmt.Sprintf("%s/%s/%s/%s", base, prefix, l.appID, p.path), nil)
	if err != nil {
		fmt.Println("ERROR")
	}

	if method == "PATCH" {
		req.Header.Set("Content-Type", "application/vnd.layer-patch+json")
	} else {
		req.Header.Set("Content-Type", "application/json")
	}

	if p.dedupe != nil {
		req.Header.Set("If-None-Match", *p.dedupe)
	}

	req.Header.Set("Accept", fmt.Sprintf("application/vnd.layer+json; version=%s", l.version))
	req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", l.token))

	return client.Do(req)

}<commit_msg>made parameters public<commit_after>package layer

import (
	"fmt"
	"net/http"
	"strings"
	"time"
)

const (
	base   = "https://api.layer.com"
	prefix = "apps"
)

// Layer is an instance of a layer api object
type Layer struct {
	token   string
	appID   string
	version string
	timeout time.Duration
}

// Parameters contains the options passed in from the caller of request
type Parameters struct {
	Dedupe *string
	Path   string
	Body   []byte
}

// NewLayer returns a new instance of a Layer struct
func NewLayer(token, appID, version string, timeout time.Duration) *Layer {
	return &Layer{
		token:   token,
		appID:   appID,
		version: version,
		timeout: timeout,
	}
}

func (l *Layer) request(method string, p Parameters) (*http.Response, error) {
	method = strings.ToUpper(method)
	client := http.Client{Timeout: l.timeout}
	req, err := http.NewRequest(method, fmt.Sprintf("%s/%s/%s/%s", base, prefix, l.appID, p.Path), nil)
	if err != nil {
		fmt.Println("ERROR")
	}

	if method == "PATCH" {
		req.Header.Set("Content-Type", "application/vnd.layer-patch+json")
	} else {
		req.Header.Set("Content-Type", "application/json")
	}

	if p.Dedupe != nil {
		req.Header.Set("If-None-Match", *p.Dedupe)
	}

	req.Header.Set("Accept", fmt.Sprintf("application/vnd.layer+json; version=%s", l.version))
	req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", l.token))

	return client.Do(req)

}
{'fraction_non_alphanumeric': 0.14897445124145375, 'fraction_numerical': 0.0, 'mean_word_length': 3.920353982300885, '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': '7257857', 'n_tokens_mistral': 1005, 'n_tokens_neox': 966, 'n_words': 260}