api

package
v0.0.0-...-0464d78 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrToBytes

func ErrToBytes(obj interface{}) (int, []byte, error)

func IsStatusCodeError

func IsStatusCodeError(target error) bool

func ToBytes

func ToBytes(obj interface{}) ([]byte, error)

Types

type AdvancedSuggestsInterface

type AdvancedSuggestsInterface interface {
	Offset() uint16
	Limit() uint16

	/*
		returns ((s.offset + s.limit) < uint16(s.Count))

		To see how much more exists: (uint16(s.Count) - (s.offset + s.limit))
	*/
	HasMore() bool
}

type CoacheSuggests

type CoacheSuggests struct {
	Count   int `json:"count"`
	Results []struct {
		ID       string `json:"id"`
		Fullname string `json:"fullname"`
		Person   struct {
			// Fullname string `json:"fullname"`
			// ID       string `json:"id"`
			Image string `json:"image"`
		} `json:"person"`
	} `json:"results"`
	// contains filtered or unexported fields
}

func (CoacheSuggests) HasMore

func (s CoacheSuggests) HasMore() bool

func (CoacheSuggests) Limit

func (s CoacheSuggests) Limit() uint16

func (CoacheSuggests) Offset

func (s CoacheSuggests) Offset() uint16

type CompetitionMatches

type CompetitionMatches []struct {
	ID    string `json:"id"`
	Title string `json:"title"`
	// Slug  string `json:"slug"`
	// Logo       string `json:"logo"`
	// Thumbnail  string `json:"thumbnail"`
	// SeoSlug    string `json:"seo_slug"`
	// IsInFilter bool   `json:"is_in_filter"`
	Matches []MatchBase `json:"matches"`
}

type CompetitionSuggests

type CompetitionSuggests struct {
	Count   int `json:"count"`
	Results []struct {
		ID        string `json:"id"`
		Title     string `json:"title"`
		Slug      string `json:"slug"`
		Logo      string `json:"logo"`
		Thumbnail string `json:"thumbnail"`
		SeoSlug   string `json:"seo_slug"`
	} `json:"results"`
	// contains filtered or unexported fields
}

func (CompetitionSuggests) HasMore

func (s CompetitionSuggests) HasMore() bool

func (CompetitionSuggests) Limit

func (s CompetitionSuggests) Limit() uint16

func (CompetitionSuggests) Offset

func (s CompetitionSuggests) Offset() uint16

type CompetitionWeeks

type CompetitionWeeks struct {
	ID          string `json:"id"`
	Competition string `json:"competition"`
	// StartTime   interface{} `json:"start_time"`
	// SeoSlug string `json:"seo_slug"`
	Slug string `json:"slug"`
	// EndTime     int         `json:"end_time"`
	CurrentWeek struct {
		WeekNumber uint32 `json:"week_number"`
	} `json:"current_week"`

	Weeks []struct {
		WeekNumber uint32 `json:"week_number"`
	} `json:"weeks"`
}

type CompetitionsList

type CompetitionsList []struct {
	ID      string `json:"id"`
	Title   string `json:"title"`
	Status  string `json:"status"`
	Type    string `json:"type"`
	Current struct {
		ID    string `json:"id"`
		Title string `json:"title"`
		Slug  string `json:"slug"`
		Logo  string `json:"logo"`
		// Thumbnail string `json:"thumbnail"`
		SeoSlug string `json:"seo_slug"`
	} `json:"current"`
}

type MatchBase

type MatchBase struct {
	ID            string `json:"id"`
	HomeTeam      *Team  `json:"home_team"`
	AwayTeam      *Team  `json:"away_team"`
	HomeScore     int    `json:"home_score"`
	AwayScore     int    `json:"away_score"`
	StatusDetails struct {
		StatusID   int    `json:"status_id"`
		Title      string `json:"title"`
		StatusType string `json:"status_type"`
	} `json:"status_details"`
	HoldsAt   int `json:"holds_at"`
	StartedAt int `json:"started_at"`
	// IsActive         bool        `json:"is_active"`
	// IsPostponed      bool        `json:"is_postponed"`
	BroadcastChannel string `json:"broadcast_channel"`
	IsFinished       bool   `json:"is_finished"`
	Competition      struct {
		ID    string `json:"id"`
		Title string `json:"title"`
	} `json:"competition"`
	WeekNumber int `json:"week_number"`
	Minute     int `json:"minute"`
	// Slug       string `json:"slug"`
	Stadium          *Stadium `json:"stadium"`
	HomePenaltyScore int      `json:"home_penalty_score"`
	AwayPenaltyScore int      `json:"away_penalty_score"`
	// Spectators       int `json:"spectators"`
	HasStanding bool `json:"has_standing"`
	// HasStats                bool          `json:"has_stats"`
	// HasLineups              bool          `json:"has_lineups"`
	CompetitionTrendStageID string `json:"competition_trend_stage_id"`
}

type MatchInfo

type MatchInfo struct {
	ID string `json:"id"`

	HomeTeam *Team `json:"home_team"`
	AwayTeam *Team `json:"away_team"`

	HomeScore int `json:"home_score"`
	AwayScore int `json:"away_score"`

	HoldsAt int `json:"holds_at"`
	// IsPostponed bool   `json:"is_postponed"`
	IsFinished bool `json:"is_finished"`
	Status     struct {
		StatusID   int    `json:"status_id"`
		Title      string `json:"title"`
		StatusType string `json:"status_type"`
	} `json:"status"`

	Minute int `json:"minute"`

	HomePenaltyScore int `json:"home_penalty_score"`
	AwayPenaltyScore int `json:"away_penalty_score"`

	ToBeDecided bool `json:"to_be_decided"`

	BroadcastChannel string `json:"broadcast_channel"`

	CompetitionTrendStage struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"competition_trend_stage"`

	CompetitionTrend struct {
		ID    string `json:"id"`
		Title string `json:"title"`
		Slug  string `json:"slug"`
	} `json:"competition_trend"`

	Stadium *Stadium `json:"stadium"`

	HeaderEvents []struct {
		ID     string `json:"id"`
		Player struct {
			ID string `json:"id"`
			// Slug     string `json:"slug"`
			Fullname string `json:"fullname"`
			// Image    string `json:"image"`
			// Position struct {
			// 	Key   string `json:"key"`
			// 	Value string `json:"value"`
			// } `json:"position"`
			KitNumber int `json:"kit_number"`
		} `json:"player"`

		Team      *Team `json:"team"`
		EventType struct {
			ShortForm string `json:"short_form"`
			Title     string `json:"title"`
		} `json:"event_type"`

		Minute     int `json:"minute"`
		MinutePlus int `json:"minute_plus"`
	} `json:"header_events"`
}

type PlayerSuggests

type PlayerSuggests struct {
	Count   int `json:"count"`
	Results []struct {
		ID string `json:"id"`
		// Slug     string `json:"slug"`
		Fullname string `json:"fullname"`
		Image    string `json:"image"`
		// Position struct {
		// 	Key   string `json:"key"`
		// 	Value string `json:"value"`
		// } `json:"position"`
		KitNumber int `json:"kit_number"`
	} `json:"results"`
	// contains filtered or unexported fields
}

func (PlayerSuggests) HasMore

func (s PlayerSuggests) HasMore() bool

func (PlayerSuggests) Limit

func (s PlayerSuggests) Limit() uint16

func (PlayerSuggests) Offset

func (s PlayerSuggests) Offset() uint16

type RequestConfig

type RequestConfig struct {
	Method, URI, Accept, Referer string

	CloseConnection bool
}

type Session

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

func NewSession

func NewSession(logger *logging.FileLogger, readTimeout, writeTimeout time.Duration) *Session

func (*Session) AdvancedSearch

func (cli *Session) AdvancedSearch(q string, filter uint8, offset, limit uint16) (AdvancedSuggestsInterface, error)

Searches with result filtering

Parameters:

  • q: Query ( assert len(q) > 3 )
  • filter: Search for what? teams:0, players:1, coaches:2, or competitions:3
  • offset: result offset
  • limit: result limit ( default 10 )

func (*Session) GetCompetitionStandingTable

func (cli *Session) GetCompetitionStandingTable(current_id string) (StandingTable, error)

Returns standing table of a competition.

Parameters:

  • current_id: competition current id.

func (*Session) GetCompetitionWeeks

func (cli *Session) GetCompetitionWeeks(current_id string) (*CompetitionWeeks, error)

Returns competition weeks.

Parameters:

  • current_id: competition current id.

func (*Session) GetCompetitionsList

func (cli *Session) GetCompetitionsList(c_type string) (CompetitionsList, error)

Returns the competitions that are supported.

Parameters:

  • c_type: competition type, (C)lub competitions or (N)ational competitions ( can be zero ).

func (*Session) GetMatchInfo

func (cli *Session) GetMatchInfo(match_id string) (*MatchInfo, error)

Returns the match information.

Parameters:

  • match_id: the match id.

func (*Session) GetMatchesByDate

func (cli *Session) GetMatchesByDate(days int, slugs ...string) (CompetitionMatches, error)

Returns the matches of that date.

Parameters:

  • days: days after today ( can be zero or negative ).
  • slugs: the slugs of competitions that matches you want.

func (*Session) GetMatchesByWeekNumber

func (cli *Session) GetMatchesByWeekNumber(current_id string, week_number uint32) ([]MatchBase, error)

Returns the matches of that week.

Parameters:

  • week_number: week number.
  • current_id: competition current id.

func (*Session) GetTransfers

func (cli *Session) GetTransfers(season_id string) (Transfers, error)

Returns the transfers of a season.

Parameters:

  • season_id: season id.

func (*Session) GetTransfersRegions

func (cli *Session) GetTransfersRegions() (*TransfersRegions, error)

Returns the regions that have transfer.

func (*Session) Request

func (s *Session) Request(r RequestConfig, f func(*fasthttp.Response) error) error

func (*Session) RequestJSON

func (s *Session) RequestJSON(req RequestConfig, obj interface{}) error

func (*Session) Search

func (cli *Session) Search(q string, s_type uint8) (*Suggests, error)

Searches the query.

Parameters:

  • q: query ( must be len(q) > 3).
  • s_type: search type - Full-Search:1 or Simple-Search:0

- Simple search: coaches, players, teams. - Full search: coaches, players, teams, competitions, news.

type Stadium

type Stadium struct {
	Name    string `json:"name"`
	Country struct {
		Name string `json:"name"`
	} `json:"country"`
	City string `json:"city"`
	// Latitude  float64     `json:"latitude"`
	// Longitude float64     `json:"longitude"`
	Capacity int `json:"capacity"`
}

type StandingTable

type StandingTable []struct {
	Team struct {
		// ID    string `json:"id"`
		// Slug  string `json:"slug"`
		Title string `json:"title"`
		// Logo       string `json:"logo"`
		// Thumbnail  string `json:"thumbnail"`
		// IsActive   bool   `json:"is_active"`
		// FullTitle  string `json:"full_title"`
		// IsNational bool   `json:"is_national"`
		// Country struct {
		// 	Name string `json:"name"`
		// } `json:"country"`
		ToBeDecided bool `json:"to_be_decided"`
	} `json:"team"`
	// Form []struct {
	// 	State   string `json:"state"`
	// 	MatchID string `json:"match_id"`
	// 	Title   string `json:"title"`
	// } `json:"form"`
	Rank           int `json:"rank"`
	Score          int `json:"score"`
	PlayedMatches  int `json:"played_matches"`
	WonMatches     int `json:"won_matches"`
	LostMatches    int `json:"lost_matches"`
	ScoredGoals    int `json:"scored_goals"`
	ConcededGoals  int `json:"conceded_goals"`
	RedCards       int `json:"red_cards"`
	YellowCards    int `json:"yellow_cards"`
	GoalDifference int `json:"goal_difference"`
	TotalCards     int `json:"total_cards"`
	RankChange     int `json:"rank_change"`
}

type StatusCodeError

type StatusCodeError struct {
	Msg  string `json:"message"`
	Code int    `json:"code"`
}

func (*StatusCodeError) Error

func (e *StatusCodeError) Error() string

func (*StatusCodeError) MarshalJSON

func (e *StatusCodeError) MarshalJSON() ([]byte, error)

type Suggests

type Suggests struct {
	Teams   TeamSuggests   `json:"teams"`
	Players PlayerSuggests `json:"players"`
	Coaches CoacheSuggests `json:"coaches"`
}

type Team

type Team struct {
	ID    string `json:"id"`
	Slug  string `json:"slug"`
	Title string `json:"title"`
	// Thumbnail  string `json:"thumbnail"`
	// IsActive   bool   `json:"is_active"`
	// FullTitle  string `json:"full_title"`
	// IsNational bool   `json:"is_national"`
	Country *struct {
		Name string `json:"name"`
	} `json:"country"`
	ToBeDecided bool `json:"to_be_decided"`
}

type TeamSuggests

type TeamSuggests struct {
	Count   int    `json:"count"`
	Results []Team `json:"results"`
	// contains filtered or unexported fields
}

func (TeamSuggests) HasMore

func (s TeamSuggests) HasMore() bool

func (TeamSuggests) Limit

func (s TeamSuggests) Limit() uint16

func (TeamSuggests) Offset

func (s TeamSuggests) Offset() uint16

type Transfers

type Transfers []struct {
	ID string `json:"id"`
	// Slug       string `json:"slug"`
	Title string `json:"title"`
	Logo  string `json:"logo"`
	// Thumbnail  string `json:"thumbnail"`
	// IsActive   bool   `json:"is_active"`
	// FullTitle  string `json:"full_title"`
	// IsNational bool   `json:"is_national"`
	Country struct {
		Name string `json:"name"`
	} `json:"country"`
	ToBeDecided bool `json:"to_be_decided"`
	// Order       int  `json:"order"`
	InTransfers []struct {
		TransferSeason string `json:"transfer_season"`
		Player         struct {
			ID       string `json:"id"`
			Slug     string `json:"slug"`
			Fullname string `json:"fullname"`
			// Image    string `json:"image"`
			// Position struct {
			// 	Key   string `json:"key"`
			// 	Value string `json:"value"`
			// } `json:"position"`
			KitNumber int `json:"kit_number"`
		} `json:"player"`
		FromTeam       Team `json:"from_team"`
		TransferTime   int  `json:"transfer_time"`
		TransferStatus struct {
			StatusID int    `json:"status_id"`
			Name     string `json:"name"`
		} `json:"transfer_status"`
		IsImportant bool `json:"is_important"`
	} `json:"in_transfers"`
	OutTransfers []struct {
		TransferSeason string `json:"transfer_season"`
		Player         struct {
			ID       string `json:"id"`
			Slug     string `json:"slug"`
			Fullname string `json:"fullname"`
			// Image    string `json:"image"`
			// Position struct {
			// 	Key   string `json:"key"`
			// 	Value string `json:"value"`
			// } `json:"position"`
			KitNumber int `json:"kit_number"`
		} `json:"player"`
		ToTeam         *Team `json:"to_team"`
		TransferTime   int   `json:"transfer_time"`
		TransferStatus struct {
			StatusID int    `json:"status_id"`
			Name     string `json:"name"`
		} `json:"transfer_status"`
		IsImportant bool `json:"is_important"`
	} `json:"out_transfers"`
}

type TransfersRegions

type TransfersRegions struct {
	Count   int `json:"count"`
	Results []struct {
		Name string `json:"name"`
		// Order   int    `json:"order"`
		Seasons []struct {
			ID   string `json:"id"`
			Name string `json:"name"`
		} `json:"seasons"`
	} `json:"results"`
}

Jump to

Keyboard shortcuts

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