Class: SportsApi::Football::Client

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

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

BASE_URL =
'https://v3.football.api-sports.io/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client

Returns a new instance of Client.



13
14
15
16
17
18
19
# File 'lib/sports_api/football/client.rb', line 13

def initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil)
  @api_key = api_key
  @adapter = adapter

  # Test stubs for requests
  @stubs = stubs
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



11
12
13
# File 'lib/sports_api/football/client.rb', line 11

def adapter
  @adapter
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



11
12
13
# File 'lib/sports_api/football/client.rb', line 11

def api_key
  @api_key
end

Instance Method Details

#coachesObject



21
22
23
# File 'lib/sports_api/football/client.rb', line 21

def coaches
  CoachResource.new(self)
end

#connectionObject



165
166
167
168
169
170
171
172
# File 'lib/sports_api/football/client.rb', line 165

def connection
  @connection ||= Faraday.new do |conn|
    conn.url_prefix = BASE_URL
    conn.request :json
    conn.response :json, content_type: 'application/json'
    conn.adapter adapter, @stubs
  end
end

#countriesObject



25
26
27
# File 'lib/sports_api/football/client.rb', line 25

def countries
  CountryResource.new(self)
end

#fixture_eventsObject



45
46
47
# File 'lib/sports_api/football/client.rb', line 45

def fixture_events
  FixtureEventResource.new(self)
end

#fixture_head_to_headObject



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

def fixture_head_to_head
  FixtureHeadToHeadResource.new(self)
end

#fixture_lineupsObject



49
50
51
# File 'lib/sports_api/football/client.rb', line 49

def fixture_lineups
  FixtureLineupResource.new(self)
end

#fixture_player_statisticsObject



53
54
55
# File 'lib/sports_api/football/client.rb', line 53

def fixture_player_statistics
  FixturePlayerStatisticResource.new(self)
end

#fixture_roundsObject



33
34
35
# File 'lib/sports_api/football/client.rb', line 33

def fixture_rounds
  FixtureRoundResource.new(self)
end

#fixture_statisticsObject



41
42
43
# File 'lib/sports_api/football/client.rb', line 41

def fixture_statistics
  FixtureStatisticResource.new(self)
end

#fixturesObject



29
30
31
# File 'lib/sports_api/football/client.rb', line 29

def fixtures
  FixtureResource.new(self)
end

#injuriesObject



57
58
59
# File 'lib/sports_api/football/client.rb', line 57

def injuries
  InjuryResource.new(self)
end

#inspectObject



174
175
176
# File 'lib/sports_api/football/client.rb', line 174

def inspect
  '#<SportsApi::Football::Client>'
end

#league_seasonsObject



65
66
67
# File 'lib/sports_api/football/client.rb', line 65

def league_seasons
  LeagueSeasonResource.new(self)
end

#leaguesObject



61
62
63
# File 'lib/sports_api/football/client.rb', line 61

def leagues
  LeagueResource.new(self)
end

#oddsObject



69
70
71
# File 'lib/sports_api/football/client.rb', line 69

def odds
  OddsResource.new(self)
end

#odds_betsObject



73
74
75
# File 'lib/sports_api/football/client.rb', line 73

def odds_bets
  OddsBetResource.new(self)
end

#odds_bookmakersObject



77
78
79
# File 'lib/sports_api/football/client.rb', line 77

def odds_bookmakers
  OddsBookmakerResource.new(self)
end

#odds_live_betsObject



85
86
87
# File 'lib/sports_api/football/client.rb', line 85

def odds_live_bets
  OddsLiveBetResource.new(self)
end

#odds_livesObject



81
82
83
# File 'lib/sports_api/football/client.rb', line 81

def odds_lives
  OddsLiveResource.new(self)
end

#odds_mappingsObject



89
90
91
# File 'lib/sports_api/football/client.rb', line 89

def odds_mappings
  OddsMappingResource.new(self)
end

#player_seasonsObject



113
114
115
# File 'lib/sports_api/football/client.rb', line 113

def player_seasons
  PlayerSeasonResource.new(self)
end

#player_squadsObject



117
118
119
# File 'lib/sports_api/football/client.rb', line 117

def player_squads
  PlayerSquadResource.new(self)
end

#player_top_assistsObject



97
98
99
# File 'lib/sports_api/football/client.rb', line 97

def player_top_assists
  PlayerTopAssistResource.new(self)
end

#player_top_red_cardsObject



105
106
107
# File 'lib/sports_api/football/client.rb', line 105

def player_top_red_cards
  PlayerTopRedCardResource.new(self)
end

#player_top_scorersObject



101
102
103
# File 'lib/sports_api/football/client.rb', line 101

def player_top_scorers
  PlayerTopScorerResource.new(self)
end

#player_top_yellow_cardsObject



109
110
111
# File 'lib/sports_api/football/client.rb', line 109

def player_top_yellow_cards
  PlayerTopYellowCardResource.new(self)
end

#playersObject



93
94
95
# File 'lib/sports_api/football/client.rb', line 93

def players
  PlayerResource.new(self)
end

#predictionsObject



121
122
123
# File 'lib/sports_api/football/client.rb', line 121

def predictions
  PredictionResource.new(self)
end

#sidelinedObject



125
126
127
# File 'lib/sports_api/football/client.rb', line 125

def sidelined
  SidelinedResource.new(self)
end

#standingsObject



129
130
131
# File 'lib/sports_api/football/client.rb', line 129

def standings
  StandingResource.new(self)
end

#team_countriesObject



137
138
139
# File 'lib/sports_api/football/client.rb', line 137

def team_countries
  TeamCountryResource.new(self)
end

#team_seasonsObject



141
142
143
# File 'lib/sports_api/football/client.rb', line 141

def team_seasons
  TeamSeasonResource.new(self)
end

#team_statisticsObject



145
146
147
# File 'lib/sports_api/football/client.rb', line 145

def team_statistics
  TeamStatisticResource.new(self)
end

#teamsObject



133
134
135
# File 'lib/sports_api/football/client.rb', line 133

def teams
  TeamResource.new(self)
end

#timezonesObject



149
150
151
# File 'lib/sports_api/football/client.rb', line 149

def timezones
  TimezoneResource.new(self)
end

#transfersObject



153
154
155
# File 'lib/sports_api/football/client.rb', line 153

def transfers
  TransferResource.new(self)
end

#trophiesObject



157
158
159
# File 'lib/sports_api/football/client.rb', line 157

def trophies
  TrophyResource.new(self)
end

#venuesObject



161
162
163
# File 'lib/sports_api/football/client.rb', line 161

def venues
  VenueResource.new(self)
end