<commit_before>package client

import (
	"fmt"

	"github.com/peterjliu/rest"
)

type Client struct {
	AppId  string // Parse-Application-Id
	ApiKey string // Parse REST API key
}

// Get new Parse REST client
func New(id, key string) *Client {
	c := new(Client)
	c.AppId = id
	c.ApiKey = key
	return c
}

// Get Parse object and fill in struct
func (c Client) GetObj(class, id string, out interface{}) error {
	r := rest.Request{
		Method: rest.GET,
		Headers: map[string]string{
			"X-Parse-Application-Id": c.AppId,
			"X-Parse-REST-API-Key":   c.ApiKey,
		},
		Url: fmt.Sprintf("https://api.parse.com/1/classes/%s/%s", class, id),
	}
	err := r.Do(&out)
	if err != nil {
		fmt.Println("Failed to get object")
		return err
	}
	return nil
}

// Get Parse object, without specifying type
func (c Client) GetObjMap(class, id string) (map[string]interface{}, error) {
	var v interface{}
	err := rest.Get(fmt.Sprintf("https://api.parse.com/1/classes/%s/%s", class, id),
		map[string]string{
			"X-Parse-Application-Id": c.AppId,
			"X-Parse-REST-API-Key":   c.ApiKey,
		}, &v)
	if err != nil {
		fmt.Println("Failed to get object")
		return nil, err
	}
	return v.(map[string]interface{}), nil<commit_msg>added Headers() method to Client<commit_after>package client

import (
	"fmt"

	"github.com/peterjliu/rest"
)

type Client struct {
	AppId  string // Parse-Application-Id
	ApiKey string // Parse REST API key
}

// Get new Parse REST client
func New(id, key string) *Client {
	c := new(Client)
	c.AppId = id
	c.ApiKey = key
	return c
}

func (c Client) Headers() map[string]string {
	return map[string]string{
		"X-Parse-Application-Id": c.AppId,
		"X-Parse-REST-API-Key":   c.ApiKey,
	}
}

// Get Parse object and fill in struct
func (c Client) GetObj(class, id string, out interface{}) error {
	r := rest.Request{
		Method:  rest.GET,
		Headers: c.Headers(),
		Url:     fmt.Sprintf("https://api.parse.com/1/classes/%s/%s", class, id),
	}
	err := r.Do(&out)
	if err != nil {
		fmt.Println("Failed to get object")
		return err
	}
	return nil
}

// Get Parse object, without specifying type
func (c Client) GetObjMap(class, id string) (map[string]interface{}, error) {
	var v interface{}
	r := rest.Request{
		Method:  rest.GET,
		Headers: c.Headers(),
		Url:     fmt.Sprintf("https://api.parse.com/1/classes/%s/%s", class, id),
	}
	err := r.Do(&v)
	if err != nil {
		fmt.Println("Failed to get object")
		return nil, err
	}
	return v.(map[string]interface{}), nil
{'fraction_non_alphanumeric': 0.1620633631194151, 'fraction_numerical': 0.0016246953696181965, 'mean_word_length': 3.453887884267631, 'pattern_counts': {'":': 6, '<': 3, '<?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': '1809253', 'n_tokens_mistral': 951, 'n_tokens_neox': 909, 'n_words': 248}