<commit_before>package xbl

import (
	"fmt"
	"strconv"
)

// Profile describe's a gamer's Xbox Live account.
type Profile struct {
	ID             string `json:"-"`
	Gamertag       string `json:"Gamertag"`
	Gamerscore     int    `json:"Gamerscore"`
	GamerPicture   string `json:"GameDisplayPicRaw"`
	AccountTier    string `json:"AccountTier"`
	Reputation     string `json:"XboxOneRep"`
	PreferredColor string `json:"PreferredColor"`
	Tenure         int    `json:"TenureLevel"`
}

// Profile retrieves the profile for a user with the provided ID.
func (c *Client) Profile(userID string) (*Profile, error) {
	const url = "https://profile.xboxlive.com/users/batch/profile/settings"

	req := struct {
		Settings []string `json:"settings"`
		UserIDs  []string `json:"userIds"`
	}{
		Settings: []string{
			"Gamerscore", "Gamertag", "GameDisplayPicRaw", "AccountTier",
			"XboxOneRep", "PreferredColor", "TenureLevel",
		},
		UserIDs: []string{userID},
	}

	var resp struct {
		ProfileUsers []struct {
			ID       string              `json:"id"`
			Settings []map[string]string `json:"settings"`
		} `json:"profileUsers"`
	}
	err := c.post(url, vXboxOne, req, &resp)
	if err != nil {
		return nil, err
	}
	if len(resp.ProfileUsers) == 0 {
		return nil, fmt.Errorf("user id %s not found", userID)
	}
	m := map[string]string{}
	for _, setting := range resp.ProfileUsers[0].Settings {
		m[setting["id"]] = setting["value"]
	}
	tenure, err := strconv.Atoi(m["TenureLevel"])
	if err != nil {
		return nil, err
	}
	gamerscore, err := strconv.Atoi(m["Gamerscore"])
	if err != nil {
		return nil, err
	}

	return &Profile{
		ID:             userID,
		Gamertag:       m["Gamertag"],
		Gamerscore:     gamerscore,
		GamerPicture:   m["GameDisplayPicRaw"],
		AccountTier:    m["AccountTier"],
		Reputation:     m["XboxOneRep"],
		PreferredColor: m["PreferredColor"],
		Tenure:         tenure,
	}, nil
}
<commit_msg>fix json tags<commit_after>package xbl

import (
	"fmt"
	"strconv"
)

// Profile describe's a gamer's Xbox Live account.
type Profile struct {
	ID             string `json:"-"`
	Gamertag       string `json:"gamertag"`
	Gamerscore     int    `json:"gamerscore"`
	GamerPicture   string `json:"gamer_picture"`
	AccountTier    string `json:"account_tier"`
	Reputation     string `json:"reputation"`
	PreferredColor string `json:"preferred_color"`
	Tenure         int    `json:"tenure_level"`
}

// Profile retrieves the profile for a user with the provided ID.
func (c *Client) Profile(userID string) (*Profile, error) {
	const url = "https://profile.xboxlive.com/users/batch/profile/settings"

	req := struct {
		Settings []string `json:"settings"`
		UserIDs  []string `json:"userIds"`
	}{
		Settings: []string{
			"Gamerscore", "Gamertag", "GameDisplayPicRaw", "AccountTier",
			"XboxOneRep", "PreferredColor", "TenureLevel",
		},
		UserIDs: []string{userID},
	}

	var resp struct {
		ProfileUsers []struct {
			ID       string              `json:"id"`
			Settings []map[string]string `json:"settings"`
		} `json:"profileUsers"`
	}
	err := c.post(url, vXboxOne, req, &resp)
	if err != nil {
		return nil, err
	}
	if len(resp.ProfileUsers) == 0 {
		return nil, fmt.Errorf("user id %s not found", userID)
	}
	m := map[string]string{}
	for _, setting := range resp.ProfileUsers[0].Settings {
		m[setting["id"]] = setting["value"]
	}
	tenure, err := strconv.Atoi(m["TenureLevel"])
	if err != nil {
		return nil, err
	}
	gamerscore, err := strconv.Atoi(m["Gamerscore"])
	if err != nil {
		return nil, err
	}

	return &Profile{
		ID:             userID,
		Gamertag:       m["Gamertag"],
		Gamerscore:     gamerscore,
		GamerPicture:   m["GameDisplayPicRaw"],
		AccountTier:    m["AccountTier"],
		Reputation:     m["XboxOneRep"],
		PreferredColor: m["PreferredColor"],
		Tenure:         tenure,
	}, nil
}

{'fraction_non_alphanumeric': 0.15072463768115943, 'fraction_numerical': 0.001054018445322793, 'mean_word_length': 3.5679903730445246, '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': '6757363', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1326, 'n_words': 318}