fball

package module
v0.0.0-...-047aedb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EP_Timezone     = "/timezone"
	EP_Countries    = "/countries"
	EP_Season       = "/leagues/seasons"
	EP_LeagueInfo   = "/leagues"
	EP_TeamInfo     = "/teams"
	EP_TeamStats    = "/teams/statistics"
	EP_Venue        = "/venues"
	EP_Standings    = "/standings"
	EP_Round        = "/fixtures/rounds"
	EP_FixtureInfo  = "/fixtures"
	EP_Head2Head    = "/fixtures/headtohead"
	EP_FixtureStats = "/fixtures/statistics"
	EP_FixtureEvent = "/fixtures/events"
	EP_Lineup       = "/fixtures/lineups"
	EP_PlayerStats  = "/fixtures/players"
)
View Source
const NoParams = ""

Variables

View Source
var FballCacheSchema []byte

Functions

func ToURLQueryString

func ToURLQueryString(data any) string

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an api-football.com client.

func NewClient

func NewClient(key string, limit limiter, doer Doer, logger *log.Logger) *Client

NewClient creates an api-football.com client. The key is the one provided by the service when you register it. limit will rate limit any request and if no logger is provided, a default logger is used.

func (*Client) Get

func (c *Client) Get(ctx context.Context, endpoint string, queryStr string, data Response) error

Get will perform a GET request against the api-football service. The response is returned in the data out param.

type Corpus

type Corpus struct {
	// contains filtered or unexported fields
}

func NewCorpus

func NewCorpus(fballc *Client, logger *log.Logger, dbs *sql.DB) *Corpus

func (*Corpus) Country

func (c *Corpus) Country(ctx context.Context, cp CountryParams) (CountryResponse, error)

func (*Corpus) Event

func (c *Corpus) Event(ctx context.Context, params EventParams) (EventResponse, error)

func (*Corpus) FixtureInfo

func (c *Corpus) FixtureInfo(ctx context.Context, params FixtureInfoParams) (FixtureInfoResponse, error)

func (*Corpus) FixtureStats

func (c *Corpus) FixtureStats(ctx context.Context, params FixtureStatsParams) (FixtureStatsResponse, error)

func (*Corpus) Head2Head

func (c *Corpus) Head2Head(ctx context.Context, params Head2HeadParams) (Head2HeadResponse, error)

func (*Corpus) LeagueInfo

func (c *Corpus) LeagueInfo(ctx context.Context, params LeagueInfoParams) (LeagueInfoResponse, error)

func (*Corpus) Lineup

func (c *Corpus) Lineup(ctx context.Context, params LineupParams) (LineupResponse, error)

func (*Corpus) PlayerStats

func (c *Corpus) PlayerStats(ctx context.Context, params PlayerStatsParams) (PlayerStatsResponse, error)

func (*Corpus) Round

func (c *Corpus) Round(ctx context.Context, params RoundParams) (RoundResponse, error)

func (*Corpus) Season

func (c *Corpus) Season(ctx context.Context) (SeasonResponse, error)

func (*Corpus) Standings

func (c *Corpus) Standings(ctx context.Context, params StandingsParams) (StandingsResponse, error)

func (*Corpus) TeamInfo

func (c *Corpus) TeamInfo(ctx context.Context, params TeamInfoParams) (TeamInfoResponse, error)

func (*Corpus) TeamStats

func (c *Corpus) TeamStats(ctx context.Context, params TeamStatsParams) (TeamStatsResponse, error)

func (*Corpus) Timezone

func (c *Corpus) Timezone(ctx context.Context) (TimezoneResponse, error)

func (*Corpus) Venue

func (c *Corpus) Venue(ctx context.Context, params VenueParams) (VenueResponse, error)

func (*Corpus) WithStale

func (c *Corpus) WithStale(stale bool) *Corpus

type Country

type Country struct {
	Name string `json:"name"`
	Code string `json:"code"`
	Flag string `json:"flag"`
}

type CountryParams

type CountryParams struct {
	Name   string
	Code   string
	Search string
}

type CountryResponse

type CountryResponse struct {
	Country []Country `json:"response"`
	// contains filtered or unexported fields
}

func (CountryResponse) Err

func (cr CountryResponse) Err() error

func (CountryResponse) When

func (cr CountryResponse) When() int64

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

Doer is an interface for perfomring http requests.

type Event

type Event struct {
	Time struct {
		Elapsed int `json:"elapsed"`
		Extra   int `json:"extra"`
	} `json:"time"`
	Team     TeamData `json:"team"`
	Player   Player   `json:"player"`
	Assist   Player   `json:"assist"`
	Type     string   `json:"type"`
	Detail   string   `json:"detail"`
	Comments string   `json:"comments"`
}

type EventParams

type EventParams struct {
	Fixture string
	Team    string
	Player  string
	Type    string
}

type EventResponse

type EventResponse struct {
	Event []Event `json:"response"`
	// contains filtered or unexported fields
}

func (EventResponse) Err

func (cr EventResponse) Err() error

func (EventResponse) When

func (cr EventResponse) When() int64

type Fixture

type Fixture struct {
	ID        int    `json:"id"`
	Referee   string `json:"referee"`
	Timezone  string `json:"timezone"`
	Date      string `json:"date"`
	Timestamp int64  `json:"timestamp"`
	Periods   struct {
		First  int `json:"first"`
		Second int `json:"second"`
	} `json:"periods"`
	Venue  Venue `json:"venue"`
	Status struct {
		Long    string `json:"long"`
		Short   string `json:"short"`
		Elapsed int    `json:"elapsed"`
	} `json:"status"`
}

type FixtureInfoParams

type FixtureInfoParams struct {
	ID       string
	Live     string
	Date     string
	League   string
	Season   string
	Team     string
	Last     string
	Next     string
	From     string
	To       string
	Round    string
	Status   string
	Timezone string
}

type FixtureInfoResponse

type FixtureInfoResponse struct {
	FixtureInfo []Head2Head `json:"response"`
	// contains filtered or unexported fields
}

func (FixtureInfoResponse) Err

func (cr FixtureInfoResponse) Err() error

func (FixtureInfoResponse) When

func (cr FixtureInfoResponse) When() int64

type FixtureStatsParams

type FixtureStatsParams struct {
	Fixture string
	Team    string
	Type    string
}

type FixtureStatsResponse

type FixtureStatsResponse struct {
	Statistics []Statistics `json:"response"`
	// contains filtered or unexported fields
}

func (FixtureStatsResponse) Err

func (cr FixtureStatsResponse) Err() error

func (FixtureStatsResponse) When

func (cr FixtureStatsResponse) When() int64

type GameTime

type GameTime struct {
	P15  TotalPercent `json:"0-15"`
	P30  TotalPercent `json:"16-30"`
	P45  TotalPercent `json:"31-45"`
	P60  TotalPercent `json:"46-60"`
	P75  TotalPercent `json:"61-75"`
	P90  TotalPercent `json:"76-90"`
	P105 TotalPercent `json:"91-105"`
	P120 TotalPercent `json:"105-120"`
}

type H2HTeam

type H2HTeam struct {
	ID     int    `json:"id"`
	Name   string `json:"name"`
	Winner bool   `json:"winner"`
}

type Head2Head

type Head2Head struct {
	Fixture Fixture `json:"fixture"`
	League  League  `json:"league"`
	Teams   struct {
		Home H2HTeam `json:"home"`
		Away H2HTeam `json:"away"`
	} `json:"teams"`
	Goals Totals `json:"goals"`
	Score struct {
		Halftime  Totals `json:"halftime"`
		Fulltime  Totals `json:"fulltime"`
		Extratime Totals `json:"extratime"`
		Penalty   Totals `json:"penalty"`
	} `json:"score"`
}

type Head2HeadParams

type Head2HeadParams struct {
	H2H      string
	Date     string
	League   string
	Season   string
	Last     string
	Next     string
	From     string
	To       string
	Status   string
	Timezone string
}

type Head2HeadResponse

type Head2HeadResponse struct {
	Head2Head []Head2Head `json:"response"`
	// contains filtered or unexported fields
}

func (Head2HeadResponse) Err

func (cr Head2HeadResponse) Err() error

func (Head2HeadResponse) When

func (cr Head2HeadResponse) When() int64

type League

type League struct {
	ID       int         `json:"id"`
	Name     string      `json:"name"`
	Type     string      `json:"type"`
	Country  string      `json:"country"`
	Flag     string      `json:"flag"`
	Season   int         `json:"season"`
	Round    string      `json:"round"`
	Rankings [][]Ranking `json:"standings"`
}

type LeagueInfo

type LeagueInfo struct {
	League  League  `json:"league"`
	Country Country `json:"country"`
	Seasons []struct {
		Year     int    `json:"year"`
		Start    string `json:"start"`
		End      string `json:"end"`
		Current  bool   `json:"current"`
		Coverage struct {
			Fixtures struct {
				Events             bool `json:"events"`
				Lineups            bool `json:"lineups"`
				StatisticsFixtures bool `json:"statistics_fixtures"`
				StatisticsPlayers  bool `json:"statistics_players"`
			} `json:"fixtures"`
			Standings   bool `json:"standings"`
			Players     bool `json:"players"`
			TopScorers  bool `json:"top_scorers"`
			TopAssists  bool `json:"top_assists"`
			TopCards    bool `json:"top_cards"`
			Predictions bool `json:"predictions"`
			Odds        bool `json:"odds"`
		} `json:"coverage"`
	} `json:"seasons"`
}

type LeagueInfoParams

type LeagueInfoParams struct {
	ID      string
	Name    string
	Country string
	Code    string
	Season  string
	Team    string
	Type    string
	Current string
	Search  string
	Last    string
}

type LeagueInfoResponse

type LeagueInfoResponse struct {
	LeagueInfo []LeagueInfo `json:"response"`
	// contains filtered or unexported fields
}

func (LeagueInfoResponse) Err

func (cr LeagueInfoResponse) Err() error

func (LeagueInfoResponse) When

func (cr LeagueInfoResponse) When() int64

type Lineup

type Lineup struct {
	Team  TeamData `json:"team"`
	Coach struct {
		ID    int    `json:"id"`
		Name  string `json:"name"`
		Photo string `json:"photo"`
	} `json:"coach"`
	Formation string `json:"formation"`
	StartXI   []struct {
		Player Player `json:"player"`
	} `json:"startXI"`
	Substitutes []struct {
		Player Player `json:"player"`
	} `json:"substitutes"`
}

type LineupParams

type LineupParams struct {
	Fixture string
	Team    string
	Player  string
	Type    string
}

type LineupResponse

type LineupResponse struct {
	Lineup []Lineup `json:"response"`
	// contains filtered or unexported fields
}

func (LineupResponse) Err

func (cr LineupResponse) Err() error

func (LineupResponse) When

func (cr LineupResponse) When() int64

type PagingToken

type PagingToken struct {
	Current int `json:"current"`
	Total   int `json:"total"`
}

type Player

type Player struct {
	ID     int    `json:"id"`
	Name   string `json:"name"`
	Number int    `json:"number"`
	Pos    string `json:"pos"`
}

type PlayerStats

type PlayerStats struct {
	Team    TeamData `json:"team"`
	Players []struct {
		Player     Player `json:"player"`
		Statistics []struct {
			Games struct {
				Minutes    int    `json:"minutes"`
				Number     int    `json:"number"`
				Position   string `json:"position"`
				Rating     string `json:"rating"`
				Captain    bool   `json:"captain"`
				Substitute bool   `json:"substitute"`
			} `json:"games"`
			Offsides interface{} `json:"offsides"`
			Shots    struct {
				Total int `json:"total"`
				On    int `json:"on"`
			} `json:"shots"`
			Goals struct {
				Total    int `json:"total"`
				Conceded int `json:"conceded"`
				Assists  int `json:"assists"`
				Saves    int `json:"saves"`
			} `json:"goals"`
			Passes struct {
				Total    int    `json:"total"`
				Key      int    `json:"key"`
				Accuracy string `json:"accuracy"`
			} `json:"passes"`
			Tackles struct {
				Total         int `json:"total"`
				Blocks        int `json:"blocks"`
				Interceptions int `json:"interceptions"`
			} `json:"tackles"`
			Duels struct {
				Total int `json:"total"`
				Won   int `json:"won"`
			} `json:"duels"`
			Dribbles struct {
				Attempts int `json:"attempts"`
				Success  int `json:"success"`
				Past     int `json:"past"`
			} `json:"dribbles"`
			Fouls struct {
				Drawn     int `json:"drawn"`
				Committed int `json:"committed"`
			} `json:"fouls"`
			Cards struct {
				Yellow int `json:"yellow"`
				Red    int `json:"red"`
			} `json:"cards"`
			Penalty struct {
				Won      int `json:"won"`
				Commited int `json:"commited"`
				Scored   int `json:"scored"`
				Missed   int `json:"missed"`
				Saved    int `json:"saved"`
			} `json:"penalty"`
		} `json:"statistics"`
	} `json:"players"`
}

type PlayerStatsParams

type PlayerStatsParams struct {
	Fixture string
	Team    string
}

type PlayerStatsResponse

type PlayerStatsResponse struct {
	PlayerStats []PlayerStats `json:"response"`
	// contains filtered or unexported fields
}

func (PlayerStatsResponse) Err

func (cr PlayerStatsResponse) Err() error

func (PlayerStatsResponse) When

func (cr PlayerStatsResponse) When() int64

type RankTotals

type RankTotals struct {
	Played int `json:"played"`
	Win    int `json:"win"`
	Draw   int `json:"draw"`
	Lose   int `json:"lose"`
	Goals  struct {
		For     int `json:"for"`
		Against int `json:"against"`
	} `json:"goals"`
}

type Ranking

type Ranking struct {
	Rank        int        `json:"rank"`
	Team        TeamData   `json:"team"`
	Points      int        `json:"points"`
	Goalsdiff   int        `json:"goalsDiff"`
	Group       string     `json:"group"`
	Form        string     `json:"form"`
	Status      string     `json:"status"`
	Description string     `json:"description"`
	All         RankTotals `json:"all"`
	Home        RankTotals `json:"home"`
	Away        RankTotals `json:"away"`
	Update      string     `json:"update"`
}

type Response

type Response interface {
	// Err returns the error from the response, if any.
	Err() error

	// When returns the timestamp for the response.
	When() int64
	// contains filtered or unexported methods
}

Response is an interface for api-football.com responses.

type RoundParams

type RoundParams struct {
	League  string
	Season  string
	Current string
}

type RoundResponse

type RoundResponse struct {
	Rounds []string `json:"response"`
	// contains filtered or unexported fields
}

func (RoundResponse) Err

func (cr RoundResponse) Err() error

func (RoundResponse) When

func (cr RoundResponse) When() int64

type SeasonResponse

type SeasonResponse struct {
	Season []int `json:"response"`
	// contains filtered or unexported fields
}

func (SeasonResponse) Err

func (cr SeasonResponse) Err() error

func (SeasonResponse) When

func (cr SeasonResponse) When() int64

type StandingsParams

type StandingsParams struct {
	League string
	Season string
	Team   string
}

type StandingsResponse

type StandingsResponse struct {
	Standings []struct {
		League League `json:"league"`
	} `json:"response"`
	// contains filtered or unexported fields
}

func (StandingsResponse) Err

func (cr StandingsResponse) Err() error

func (StandingsResponse) When

func (cr StandingsResponse) When() int64

type Statistics

type Statistics struct {
	Team TeamData `json:"team"`
	Info []struct {
		Type  string      `json:"type"`
		Value interface{} `json:"value"`
	} `json:"statistics"`
}

type TeamData

type TeamData struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	Country  string `json:"country"`
	Founded  int    `json:"founded"`
	National bool   `json:"national"`
	Update   string
}

type TeamInfo

type TeamInfo struct {
	Team  TeamData `json:"team"`
	Venue Venue    `json:"venue"`
}

type TeamInfoParams

type TeamInfoParams struct {
	ID      string
	Name    string
	League  string
	Season  string
	Country string
	Search  string
}

type TeamInfoResponse

type TeamInfoResponse struct {
	TeamInfo []TeamInfo `json:"response"`
	// contains filtered or unexported fields
}

func (TeamInfoResponse) Err

func (cr TeamInfoResponse) Err() error

func (TeamInfoResponse) When

func (cr TeamInfoResponse) When() int64

type TeamStatsParams

type TeamStatsParams struct {
	League string
	Season string
	Team   string
	Date   string
}

type TeamStatsResponse

type TeamStatsResponse struct {
	TeamStats struct {
		League   League   `json:"league"`
		Team     TeamData `json:"team"`
		Form     string   `json:"form"`
		Fixtures struct {
			Played Totals `json:"played"`
			Wins   Totals `json:"wins"`
			Draws  Totals `json:"draws"`
			Loses  Totals `json:"loses"`
		} `json:"fixtures"`
		Goals struct {
			For struct {
				Total   Totals   `json:"total"`
				Average TotalStr `json:"average"`
				Minute  GameTime `json:"minute"`
			} `json:"for"`
			Against struct {
				Total   Totals   `json:"total"`
				Average TotalStr `json:"average"`
				Minute  GameTime `json:"minute"`
			} `json:"against"`
		} `json:"goals"`
		Biggest struct {
			Streak struct {
				Wins  int `json:"wins"`
				Draws int `json:"draws"`
				Loses int `json:"loses"`
			} `json:"streak"`
			Wins  TotalStr `json:"wins"`
			Losev TotalStr `json:"loses"`
			Goals struct {
				For     Totals `json:"for"`
				Against Totals `json:"against"`
			} `json:"goals"`
		} `json:"biggest"`
		CleanSheet    Totals `json:"clean_sheet"`
		FailedToScore Totals `json:"failed_to_score"`
		Penalty       struct {
			Scored TotalPercent `json:"scored"`
			Missed TotalPercent `json:"missed"`
			Total  int          `json:"total"`
		} `json:"penalty"`
		Lineups []struct {
			Formation string `json:"formation"`
			Played    int    `json:"played"`
		} `json:"lineups"`
		Cards struct {
			Yellow GameTime `json:"yellow"`
			Red    GameTime `json:"red"`
		} `json:"cards"`
	} `json:"response"`
	// contains filtered or unexported fields
}

func (TeamStatsResponse) Err

func (cr TeamStatsResponse) Err() error

func (TeamStatsResponse) When

func (cr TeamStatsResponse) When() int64

type TimezoneResponse

type TimezoneResponse struct {
	Timezone []string `json:"response"`
	// contains filtered or unexported fields
}

func (TimezoneResponse) Err

func (cr TimezoneResponse) Err() error

func (TimezoneResponse) When

func (cr TimezoneResponse) When() int64

type TotalPercent

type TotalPercent struct {
	Total      int    `json:"total"`
	Percentage string `json:"percentage"`
}

type TotalStr

type TotalStr struct {
	Home  string `json:"home"`
	Away  string `json:"away"`
	Total string `json:"total"`
}

type Totals

type Totals struct {
	Home  int `json:"home"`
	Away  int `json:"away"`
	Total int `json:"total"`
}

type Venue

type Venue struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	Address  string `json:"address"`
	City     string `json:"city"`
	Capacity int    `json:"capacity"`
	Surface  string `json:"surface"`
	Country  string `json:"country"`
	Image    string `json:"image"`
}

type VenueParams

type VenueParams struct {
	ID      string
	Name    string
	City    string
	Country string
	Search  string
}

type VenueResponse

type VenueResponse struct {
	Venue []Venue `json:"response"`
	// contains filtered or unexported fields
}

func (VenueResponse) Err

func (cr VenueResponse) Err() error

func (VenueResponse) When

func (cr VenueResponse) When() int64

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL