Class: Fotmob::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fotmob/client.rb

Overview

Main client for interacting with the FotMob API

Constant Summary collapse

BASE_URL =
"http://www.fotmob.com/api"
DEFAULT_TIMEOUT =

seconds

10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(timeout: DEFAULT_TIMEOUT) ⇒ Client

Initialize a new FotMob API client

Parameters:

  • timeout (Integer) (defaults to: DEFAULT_TIMEOUT)

    Request timeout in seconds (default: 10)



19
20
21
# File 'lib/fotmob/client.rb', line 19

def initialize(timeout: DEFAULT_TIMEOUT)
  @timeout = timeout
end

Instance Attribute Details

#timeoutObject (readonly)

Returns the value of attribute timeout.



14
15
16
# File 'lib/fotmob/client.rb', line 14

def timeout
  @timeout
end

Instance Method Details

#get_league(league_id) ⇒ Hash

Get league/competition data

Parameters:

  • league_id (String)

    The league ID

Returns:

  • (Hash)

    League data with symbolized keys

Raises:



28
29
30
# File 'lib/fotmob/client.rb', line 28

def get_league(league_id)
  get("/leagues", id: league_id)
end

#get_match_details(match_id) ⇒ Hash

Get detailed information about a specific match

Parameters:

  • match_id (String)

    The match ID

Returns:

  • (Hash)

    Match details with symbolized keys

Raises:



46
47
48
# File 'lib/fotmob/client.rb', line 46

def get_match_details(match_id)
  get("/matchDetails", matchId: match_id)
end

#get_matches(date) ⇒ Hash

Get matches for a specific date

Parameters:

  • date (String)

    Date in YYYYMMDD format (e.g., “20221030”)

Returns:

  • (Hash)

    Match data with symbolized keys

Raises:



37
38
39
# File 'lib/fotmob/client.rb', line 37

def get_matches(date)
  get("/matches", date: date)
end

#get_player(player_id) ⇒ Hash

Get player data and statistics

Parameters:

  • player_id (String)

    The player ID

Returns:

  • (Hash)

    Player data with symbolized keys

Raises:



55
56
57
# File 'lib/fotmob/client.rb', line 55

def get_player(player_id)
  get("/playerData", id: player_id)
end

#get_team(team_id) ⇒ Hash

Get team data and statistics

Parameters:

  • team_id (String)

    The team ID

Returns:

  • (Hash)

    Team data with symbolized keys

Raises:



64
65
66
# File 'lib/fotmob/client.rb', line 64

def get_team(team_id)
  get("/teams", id: team_id)
end