<commit_before>package copy

import (
	"io"
	"log"
	"net/http"
	"os"

	"github.com/garyburd/go-oauth/oauth"
)

const (
	ResourceURL = "https://api.copy.com/rest/"
	AuthURL     = "https://www.copy.com/applications/authorize"
)

type AccessToken struct {
	Key   string
	Token string
}

type Session struct {
	OauthClient oauth.Client
	TokenCreds  oauth.Credentials
}

func NewSession(accessToken AccessToken) Session {

	//Create the oauth client
	oauthClient := oauth.Client{
		TokenRequestURI: AuthURL,
	}

	tokenCred := oauth.Credentials{
		Token:  accessToken.Token,
		Secret: accessToken.Key,
	}

	//Return Session with the Oauth client created
	return Session{
		OauthClient: oauthClient,
		TokenCreds:  tokenCred,
	}

}

func (s *Session) Get(urlStr string, form url.Values) (*http.Response, error) {

}

func (s *Session) Post(urlStr string, form url.Values) (*http.Response, error) {

}

func (s *Session) Delete(urlStr string, form url.Values) (*http.Response, error) {

}

func (s *Session) Put(urlStr string, form url.Values) (*http.Response, error) {

}

func (s *Session) Do(request *http.Request) (*http.Response, error) {

	// Custom headers for Copy API
	customHeades := map[string]string{
		"X-Api-Version": "1",
		"Accept":        "application/json",
	}

}<commit_msg>Implement GET in session<commit_after>package copy

import (
	"errors"
	//"io"
	//"log"
	"net/http"
	"net/url"
	//"os"

	"github.com/garyburd/go-oauth/oauth"
)

const (
	ResourceURL = "https://api.copy.com/rest/"
	AuthURL     = "https://www.copy.com/applications/authorize"
)

type AccessToken struct {
	Token string
	Key   string
}

type AppToken struct {
	Token string
	Key   string
}

type Session struct {
	OauthClient oauth.Client
	TokenCreds  oauth.Credentials
}

func NewSession(appToken AppToken, accessToken AccessToken) Session {

	//Create app credentials
	appCreds := oauth.Credentials{
		Token:  appToken.Token,
		Secret: appToken.Key,
	}

	//Create the oauth client
	oauthClient := oauth.Client{
		TokenRequestURI: AuthURL,
		Credentials:     appCreds,
	}

	tokenCred := oauth.Credentials{
		Token:  accessToken.Token,
		Secret: accessToken.Key,
	}

	//Return Session with the Oauth client created
	return Session{
		OauthClient: oauthClient,
		TokenCreds:  tokenCred,
	}

}

func (s *Session) Get(urlStr string, form url.Values) (*http.Response, error) {
	req, err := http.NewRequest("GET", urlStr, nil)

	if err != nil {
		return nil, err
	}

	if req.URL.RawQuery != "" {
		return nil, errors.New("oauth: url must not contain a query string")
	}

	req.Header.Set("Authorization", s.OauthClient.AuthorizationHeader(&s.TokenCreds, "GET", req.URL, form))
	req.URL.RawQuery = form.Encode()

	return s.Do(req)

}

func (s *Session) Post(urlStr string, form url.Values) (*http.Response, error) {
	return nil, nil
}

func (s *Session) Delete(urlStr string, form url.Values) (*http.Response, error) {
	return nil, nil
}

func (s *Session) Put(urlStr string, form url.Values) (*http.Response, error) {
	return nil, nil
}

func (s *Session) Do(request *http.Request) (*http.Response, error) {

	// Custom headers for Copy API, [IMPORTANT!!]
	customHeaders := map[string]string{
		"X-Api-Version": "1",
		"Accept":        "application/json",
	}

	for k, v := range customHeaders {
		request.Header.Add(k, v)
	}

	return http.DefaultClient.Do(request)

}
{'fraction_non_alphanumeric': 0.13670355967693687, 'fraction_numerical': 0.0005982650314089142, 'mean_word_length': 3.903225806451613, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '2829652', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1193, 'n_words': 300}