<commit_before>package hitGox

import (
	"bytes"
	"encoding/json"
	"github.com/valyala/fasthttp"
)

type (
	// Account is a response body about current user account.
	AccountInformation struct {
		UserID            string `json:"user_id,omitempty"`
		UserName          string `json:"user_name,omitempty"`
		UserLogo          string `json:"user_logo,omitempty"`
		UserLogoSmall     string `json:"user_logo_small,omitempty"`
		UserBanned        string `json:"user_banned,omitempty"`
		UserPartner       string `json:"user_partner,omitempty"`
		UserBannedChannel string `json:"user_banned_channel,omitempty"`
		SuperAdmin        string `json:"superadmin,omitempty"`
		LivestreamCount   string `json:"livestream_count,omitempty"`
		Followers         string `json:"followers,omitempty"`
		AuthToken         string `json:"authToken,omitempty"`
		Login             string `json:"login,omitempty"`
		Data              Data   `json:"data"`
		Access            string `json:"access,omitempty"`
		App               string `json:"app,omitempty"`
	}

	// Data is a part Account response body about current user account.
	Data struct {
		UserID            string `json:"user_id,omitempty"`
		UserName          string `json:"user_name,omitempty"`
		UserLogo          string `json:"user_logo,omitempty"`
		UserLogoSmall     string `json:"user_logo_small,omitempty"`
		UserBanned        string `json:"user_banned,omitempty"`
		UserPartner       string `json:"user_partner,omitempty"`
		UserBannedChannel string `json:"user_banned_channel,omitempty"`
		SuperAdmin        string `json:"superadmin,omitempty"`
		LivestreamCount   string `json:"livestream_count,omitempty"`
		Followers         string `json:"followers,omitempty"`
		AuthToken         string `json:"authToken,omitempty"`
		Login             string `json:"login,omitempty"`
		App               string `json:"app,omitempty"`
	}
)

// Login used for authentication by user login and password.
func (authToken AuthToken) Login(app Application) (AccountInformation, error) {
	args := fasthttp.AcquireArgs()
	args.Add("app", app.Name)
	args.Add("authToken", authToken.AuthToken)
	statusCode, body, err := fasthttp.Post(nil, API+"/auth/login", args)
	if statusCode != 200 || err != nil {
		return AccountInformation{}, err
	}
	var obj AccountInformation
	if err = json.NewDecoder(bytes.NewReader(body)).Decode(&obj); err != nil {
		return AccountInformation{}, err
	}
	return obj, nil
}<commit_msg>✅ Approved login<commit_after>package hitGox

import (
	"bytes"
	"encoding/json"
	"errors"
	"github.com/valyala/fasthttp"
)

// Account is about authentication of user account.
type Account struct {
	Access    string `json:"access"`
	App       string `json:"app"`
	AuthToken string `json:"authToken"`
	Data      struct {
		App               string `json:"app"`
		AuthToken         string `json:"authToken"`
		Followers         string `json:"followers"`
		LivestreamCount   string `json:"livestream_count"`
		Login             string `json:"login"`
		Superadmin        string `json:"superadmin"`
		UserBanned        string `json:"user_banned"`
		UserBannedChannel string `json:"user_banned_channel"`
		UserID            string `json:"user_id"`
		UserLogo          string `json:"user_logo"`
		UserLogoSmall     string `json:"user_logo_small"`
		UserName          string `json:"user_name"`
		UserPartner       string `json:"user_partner"`
	} `json:"data"`
	Followers         string `json:"followers"`
	LivestreamCount   string `json:"livestream_count"`
	Login             string `json:"login"`
	Superadmin        string `json:"superadmin"`
	UserBanned        string `json:"user_banned"`
	UserBannedChannel string `json:"user_banned_channel"`
	UserID            string `json:"user_id"`
	UserLogo          string `json:"user_logo"`
	UserLogoSmall     string `json:"user_logo_small"`
	UserName          string `json:"user_name"`
	UserPartner       string `json:"user_partner"`
}

// Login authenticates and returns account information.
func (app *Application) Login(login string, pass string, authToken string) (*Account, error) {
	switch {
	case app.Name == "":
		return nil, errors.New("no name of application, create new application first")
	case login == "" && pass == "" && authToken == "":
		return nil, errors.New("empty details, use authtoken or login/pass")
	case (login == "" || pass == "") && authToken == "":
		return nil, errors.New("account details can not be empty")
	}

	var args fasthttp.Args
	args.Add("app", app.Name)
	args.Add("authToken", authToken)
	args.Add("login", login)
	args.Add("pass", pass)

	url := APIEndpoint + "/auth/login"
	_, resp, err := fasthttp.Post(nil, url, &args)
	if err != nil {
		return nil, err
	}

	var obj Account
	if err = json.NewDecoder(bytes.NewReader(resp)).Decode(&obj); err != nil {
		return nil, err
	}

	return &obj, nil
}
{'fraction_non_alphanumeric': 0.12125623960066556, 'fraction_numerical': 0.0006239600665557404, 'mean_word_length': 3.5975143403441683, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '5542124', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1431, 'n_words': 361}