<commit_before>package stripe

import (
	"net/url"
	"strconv"
)

type Fund struct {
	Amount   int64  `json:"amount"`
	Currency string `json:"currency"`
}

type Balance struct {
	Object    string  `json:"object"`
	Livemode  bool    `json:"livemode"`
	Available []*Fund `json:"available"`
	Pending   []*Fund `json:"pending"`
}

type FeeDetails struct {
	Amount      int64  `json:"amount"`
	Currency    string `json:"currency"`
	Type        string `json:"type"`
	Description string `json:"description"`
	Application string `json:"application"`
}

type BalanceTransaction struct {
	Id          string        `json:"id"`
	Object      string        `json:"object"`
	Source      string        `json:"source"`
	Amount      int64         `json:"amount"`
	Currency    string        `json:"currency"`
	Net         int64         `json:"net"`
	Type        string        `json:"type"`
	Created     int64         `json:"created"`
	AvailableOn int64         `json:"available_on"`
	Status      string        `json:"status"`
	Fee         int64         `json:"fee"`
	FeeDetails  []*FeeDetails `json:"fee_details"`
}

type BalanceClient struct{}

// Retrieve loads a balance.
//
// For more information: https://stripe.com/docs/api#retrieve_balance
func (c *BalanceClient) Retrieve() (*Balance, error) {
	balance := Balance{}
	err := get("/balance", nil, &balance)
	return &balance, err
}

// RetrieveTransaction loads a balance transaction.
//
// For more information: https://stripe.com/docs/api#retrieve_balance_transaction
func (c *BalanceClient) RetrieveTransaction(id string) (*BalanceTransaction, error) {
	balanceTransaction := BalanceTransaction{}
	err := get("/balance/history/"+id, nil, &balanceTransaction)
	return &balanceTransaction, err
}

// History lists the first 10 balances in the balance history. It calls HistoryCount
// with 10 as the count and 0 as the offset, which are the defaults in the
// Stripe API.
//
// For more information: https://stripe.com/docs/api#balance_history
func (c *BalanceClient) History() ([]*BalanceTransaction, error) {
	return c.HistoryCount(10, 0)
}

// HistoryCount lists `count` balances in the balance history starting at `offset`.
//
// For more information: https://stripe.com/docs/api#balance_history
func (c *BalanceClient) HistoryCount(count, offset int) ([]*BalanceTransaction, error) {
	type balances struct{ Data []*BalanceTransaction }
	list := balances{}

	params := url.Values{
		"count":  {strconv.Itoa(count)},
		"offset": {strconv.Itoa(offset)},
	}

	err := get("/balance/history", params, &list)
	return list.Data, err
}<commit_msg>updated balance from #HistoryCount to #HistoryWithFilters<commit_after>package stripe

import (
	"net/url"
)

type Fund struct {
	Amount   int64  `json:"amount"`
	Currency string `json:"currency"`
}

type Balance struct {
	Object    string  `json:"object"`
	Livemode  bool    `json:"livemode"`
	Available []*Fund `json:"available"`
	Pending   []*Fund `json:"pending"`
}

type FeeDetails struct {
	Amount      int64  `json:"amount"`
	Currency    string `json:"currency"`
	Type        string `json:"type"`
	Description string `json:"description"`
	Application string `json:"application"`
}

type BalanceTransaction struct {
	Id          string        `json:"id"`
	Object      string        `json:"object"`
	Source      string        `json:"source"`
	Amount      int64         `json:"amount"`
	Currency    string        `json:"currency"`
	Net         int64         `json:"net"`
	Type        string        `json:"type"`
	Created     int64         `json:"created"`
	AvailableOn int64         `json:"available_on"`
	Status      string        `json:"status"`
	Fee         int64         `json:"fee"`
	FeeDetails  []*FeeDetails `json:"fee_details"`
}

type BalanceTransactionListResponse struct {
	Object string  `json:"object"`
	Url    string  `json:"url"`
	Count  int     `json:"count"`
	Data   []*BalanceTransaction `json:"data"`
}

type BalanceClient struct{}

// Retrieve loads a balance.
//
// For more information: https://stripe.com/docs/api#retrieve_balance
func (c *BalanceClient) Retrieve() (*Balance, error) {
	balance := Balance{}
	err := get("/balance", nil, &balance)
	return &balance, err
}

// RetrieveTransaction loads a balance transaction.
//
// For more information: https://stripe.com/docs/api#retrieve_balance_transaction
func (c *BalanceClient) RetrieveTransaction(id string) (*BalanceTransaction, error) {
	balanceTransaction := BalanceTransaction{}
	err := get("/balance/history/"+id, nil, &balanceTransaction)
	return &balanceTransaction, err
}

// History lists the first 10 balances in the balance history. It calls
// HistoryWithFilters with a blank Filters so all defaults are used.
//
// For more information: https://stripe.com/docs/api#balance_history
func (c *BalanceClient) History() (*BalanceTransactionListResponse, error) {
  return c.HistoryWithFilters(Filters{})
}

// HistoryWithFilters takes a Filters and applies all valid filters for the action.
//
// For more information: https://stripe.com/docs/api#balance_history
func (c *BalanceClient) HistoryWithFilters(filters Filters) (*BalanceTransactionListResponse, error) {
  response := BalanceTransactionListResponse{}
  values := url.Values{}
  addFiltersToValues([]string{"count", "offset", "currency", "source", "transfer", "type"}, filters, &values)
	err := get("/balance/history", values, &response)
	return &response, err
}
{'fraction_non_alphanumeric': 0.13178869323447637, 'fraction_numerical': 0.007043558850787767, 'mean_word_length': 3.7964444444444445, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, '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': '4847574', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1579, 'n_words': 456}