sorare/football/game.go

87 lines
2.3 KiB
Go

package football
import (
"time"
"git.lehouerou.net/laurent/sorare/graphql"
"git.lehouerou.net/laurent/sorare/types"
)
type GameWithFormation struct {
Game
AwayFormation struct {
Bench []struct {
Slug string `graphql:"slug"`
} `graphql:"bench"`
StartingLineup [][]struct {
Slug string `graphql:"slug"`
} `graphql:"startingLineup"`
} `graphql:"awayFormation"`
HomeFormation struct {
Bench []struct {
Slug string `graphql:"slug"`
} `graphql:"bench"`
StartingLineup [][]struct {
Slug string `graphql:"slug"`
} `graphql:"startingLineup"`
} `graphql:"homeFormation"`
}
type Game struct {
Id graphql.Id `graphql:"id"`
AwayGoals int `graphql:"awayGoals"`
AwayTeam struct {
TypeName string `graphql:"__typename"`
Team struct {
Slug string `graphql:"slug"`
} `graphql:"... on TeamInterface"`
} `graphql:"awayTeam"`
Competition struct {
Slug string `graphql:"slug"`
} `graphql:"competition"`
CoverageStatus string `graphql:"coverageStatus"`
Date time.Time `graphql:"date"`
ExtraTimeScoreAway int `graphql:"extraTimeScoreAway"`
ExtraTimeScoreHome int `graphql:"extraTimeScoreHome"`
HomeGoals int `graphql:"homeGoals"`
HomeTeam struct {
TypeName string `graphql:"__typename"`
Team struct {
Slug string `graphql:"slug"`
} `graphql:"... on TeamInterface"`
} `graphql:"homeTeam"`
LowCoverage bool `graphql:"lowCoverage"`
Minute int `graphql:"minute"`
PenaltyScoreAway int `graphql:"penaltyScoreAway"`
PenaltyScoreHome int `graphql:"penaltyScoreHome"`
PeriodType string `graphql:"periodType"`
Scored bool `graphql:"scored"`
So5Fixture struct {
Slug string `graphql:"slug"`
} `graphql:"so5Fixture"`
Status string `graphql:"status"`
Winner struct {
TypeName string `graphql:"__typename"`
Team struct {
Slug string `graphql:"slug"`
} `graphql:"... on TeamInterface"`
} `graphql:"winner"`
}
type ClubGamesParams struct {
StartDate types.ISO8601DateTime `graphql:"startDate"`
EndDate types.ISO8601DateTime `graphql:"endDate"`
}
func (f *Football) NewClubGamesQuery(
clubSlug string,
) *graphql.PaginatedQuery[Game, ClubGamesParams] {
return graphql.NewPaginatedQuery[Game, ClubGamesParams](
f.c,
"games",
[]string{"football", "club(slug:$slug)"},
).WithQueryParam("slug", clubSlug)
}