<commit_before>// flickr.test API methods
package test

import (
	"encoding/xml"

	"github.com/masci/flickr.go/flickr"
	flickErr "github.com/masci/flickr.go/flickr/error"
)

// Response type used by Login function
type LoginResponse struct {
	flickr.FlickrResponse
	// the user who provided authentication infos
	User struct {
		XMLName xml.Name `xml:"user"`
		// Flickr ID
		ID string `xml:"id,attr"`
		// Flickr Username
		Username string `xml:"username"`
	}
}

// Response type used by Echo function
type EchoResponse struct {
	flickr.FlickrResponse
	// API method name, dotted notation
	Method string `xml:"method"`
	// API Key provided
	ApiKey string `xml:"api_key"`
	// API data exchange format (ex. rest)
	Format string `xml:"format"`
}

// A testing method which checks if the caller is logged in then returns their username.
// This method requires authentication with 'read' permission.
func Login(client *flickr.FlickrClient) (*LoginResponse, error) {
	client.EndpointUrl = flickr.API_ENDPOINT // TODO move to SetDefaultArgs?
	client.SetDefaultArgs()
	client.Args.Set("method", "flickr.test.login")
	client.Args.Set("oauth_token", client.OAuthToken)
	client.Args.Set("oauth_consumer_key", client.ApiKey)
	client.Sign(client.OAuthTokenSecret)

	loginResponse := &LoginResponse{}
	err := flickr.GetResponse(client, loginResponse)

	if err != nil {
		return nil, err
	}

	if loginResponse.HasErrors() {
		return loginResponse, flickErr.NewError(10)<commit_msg>removed TODO<commit_after>// flickr.test API methods
package test

import (
	"encoding/xml"

	"github.com/masci/flickr.go/flickr"
	flickErr "github.com/masci/flickr.go/flickr/error"
)

// Response type used by Login function
type LoginResponse struct {
	flickr.FlickrResponse
	// the user who provided authentication infos
	User struct {
		XMLName xml.Name `xml:"user"`
		// Flickr ID
		ID string `xml:"id,attr"`
		// Flickr Username
		Username string `xml:"username"`
	}
}

// Response type used by Echo function
type EchoResponse struct {
	flickr.FlickrResponse
	// API method name, dotted notation
	Method string `xml:"method"`
	// API Key provided
	ApiKey string `xml:"api_key"`
	// API data exchange format (ex. rest)
	Format string `xml:"format"`
}

// A testing method which checks if the caller is logged in then returns their username.
// This method requires authentication with 'read' permission.
func Login(client *flickr.FlickrClient) (*LoginResponse, error) {
	client.EndpointUrl = flickr.API_ENDPOINT
	client.SetDefaultArgs()
	client.Args.Set("method", "flickr.test.login")
	client.Args.Set("oauth_token", client.OAuthToken)
	client.Args.Set("oauth_consumer_key", client.ApiKey)
	client.Sign(client.OAuthTokenSecret)

	loginResponse := &LoginResponse{}
	err := flickr.GetResponse(client, loginResponse)

	if err != nil {
		return nil, err
	}

	if loginResponse.HasErrors() {
		return loginResponse, flickErr.NewError(10)
{'fraction_non_alphanumeric': 0.11401997933172581, 'fraction_numerical': 0.0013778849466069584, 'mean_word_length': 4.489603024574669, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, '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': '1635168', 'n_tokens_mistral': 966, 'n_tokens_neox': 911, 'n_words': 260}