<commit_before>package bittrex

import (
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"net/http"
	"time"
)

func init() {
	defaultConnOpts = ConnectOptions{
		ConnTimeout: time.Second * 5,
	}
}

// BaseURL represents the base URL for all requests
const (
	BaseURL    = "https://bittrex.com/api"
	Private    = "auth"
	Public     = "pub"
	APIVersion = "2.0"
)

// Auth represents the auth credentials to authenticate to the Bittrex API:
//
// It consists of a set of a private and a public key.
type Auth struct {
	PublicKey  string // The public key to connect to bittrex API.
	PrivateKey string // The private key to connect to bittrex API.
}

// defaultConnOpts represents the default configuration for ConnectOptions.
var defaultConnOpts ConnectOptions

// ConnectOptions represents custom Connect
// Configurations for HTTP requests.
type ConnectOptions struct {
	hmacSignature interface{}
	Auth          Auth
	ConnTimeout   time.Duration
}

// fixBrokenOpts checks the specified options and sets them to the default values.
func fixBrokenOpts(options **ConnectOptions) {
	*options = &defaultConnOpts
}

// apiCall performs a generic API call.
func apiCall(Version, Visibility, Entity, Feature string, GetParameters *publicParams, PostParameters *privateParams, options *ConnectOptions) (*json.RawMessage, error) {
	fixBrokenOpts(&options)
	client := http.Client{
		Timeout: options.ConnTimeout,
	}
	URL := fmt.Sprintf("%s/v%s/%s/%s/%s", BaseURL, Version, Visibility, Entity, Feature)
	req, err := http.NewRequest("GET", URL, nil)
	if err != nil {
		return nil, err
	}
	req.Header.Add("Accept", "application/json")

	if Visibility == Public && GetParameters != nil { // Add them to query string
		queryString := req.URL.Query()
		GetParameters.AddToQueryString(&queryString)
		req.URL.RawQuery = queryString.Encode()
	} else if Visibility == Private {
		addSecurityHeaders(req.Header)
		if PostParameters != nil {
			PostParameters.AddToPostForm(&req.PostForm)
		}
	}

	resp, err := client.Do(req)
	if err != nil {
		return nil, err
	}

	if resp.StatusCode != 200 {
		return nil, fmt.Errorf("Status Code: %s", err)
	}
	defer resp.Body.Close()

	content, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}

	fmt.Print(string(content))
	var ret response
	err = json.Unmarshal(content, &ret)<commit_msg>removed unnecessary output from tests<commit_after>package bittrex

import (
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"net/http"
	"time"
)

func init() {
	defaultConnOpts = ConnectOptions{
		ConnTimeout: time.Second * 5,
	}
}

// BaseURL represents the base URL for all requests
const (
	BaseURL    = "https://bittrex.com/api"
	Private    = "auth"
	Public     = "pub"
	APIVersion = "2.0"
)

// Auth represents the auth credentials to authenticate to the Bittrex API:
//
// It consists of a set of a private and a public key.
type Auth struct {
	PublicKey  string // The public key to connect to bittrex API.
	PrivateKey string // The private key to connect to bittrex API.
}

// defaultConnOpts represents the default configuration for ConnectOptions.
var defaultConnOpts ConnectOptions

// ConnectOptions represents custom Connect
// Configurations for HTTP requests.
type ConnectOptions struct {
	hmacSignature interface{}
	Auth          Auth
	ConnTimeout   time.Duration
}

// fixBrokenOpts checks the specified options and sets them to the default values.
func fixBrokenOpts(options **ConnectOptions) {
	*options = &defaultConnOpts
}

// apiCall performs a generic API call.
func apiCall(Version, Visibility, Entity, Feature string, GetParameters *publicParams, PostParameters *privateParams, options *ConnectOptions) (*json.RawMessage, error) {
	fixBrokenOpts(&options)
	client := http.Client{
		Timeout: options.ConnTimeout,
	}
	URL := fmt.Sprintf("%s/v%s/%s/%s/%s", BaseURL, Version, Visibility, Entity, Feature)
	req, err := http.NewRequest("GET", URL, nil)
	if err != nil {
		return nil, err
	}
	req.Header.Add("Accept", "application/json")

	if Visibility == Public && GetParameters != nil { // Add them to query string
		queryString := req.URL.Query()
		GetParameters.AddToQueryString(&queryString)
		req.URL.RawQuery = queryString.Encode()
	} else if Visibility == Private {
		addSecurityHeaders(req.Header)
		if PostParameters != nil {
			PostParameters.AddToPostForm(&req.PostForm)
		}
	}

	resp, err := client.Do(req)
	if err != nil {
		return nil, err
	}

	if resp.StatusCode != 200 {
		return nil, fmt.Errorf("Status Code: %s", err)
	}
	defer resp.Body.Close()

	content, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}

	var ret response
	err = json.Unmarshal(content, &ret)
{'fraction_non_alphanumeric': 0.11295180722891567, 'fraction_numerical': 0.0025817555938037868, 'mean_word_length': 3.9775160599571735, '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': '5128214', 'n_tokens_mistral': 1507, 'n_tokens_neox': 1464, 'n_words': 458}