Class: ApiSports::Client
- Inherits:
-
Object
- Object
- ApiSports::Client
- Defined in:
- lib/api_sports/client.rb
Constant Summary collapse
- BASE_URL =
"https://v3.football.api-sports.io/"
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #connection ⇒ Object
- #countries ⇒ Object
- #fixtures ⇒ Object
-
#initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #leagues ⇒ Object
- #odds ⇒ Object
- #predictions ⇒ Object
- #seasons ⇒ Object
- #standings ⇒ Object
- #teams ⇒ Object
- #timezones ⇒ Object
- #venues ⇒ Object
Constructor Details
#initialize(api_key:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 |
# File 'lib/api_sports/client.rb', line 9 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
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
7 8 9 |
# File 'lib/api_sports/client.rb', line 7 def adapter @adapter end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/api_sports/client.rb', line 7 def api_key @api_key end |
Instance Method Details
#connection ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/api_sports/client.rb', line 57 def connection @connection ||= Faraday.new(BASE_URL) do |conn| conn.headers = { "x-apisports-key": api_key } conn.response :json, content_type: "application/json" conn.adapter adapter, @stubs end end |
#countries ⇒ Object
17 18 19 |
# File 'lib/api_sports/client.rb', line 17 def countries CountriesResource.new(self) end |
#fixtures ⇒ Object
45 46 47 |
# File 'lib/api_sports/client.rb', line 45 def fixtures FixturesResource.new(self) end |
#leagues ⇒ Object
25 26 27 |
# File 'lib/api_sports/client.rb', line 25 def leagues LeaguesResource.new(self) end |
#odds ⇒ Object
53 54 55 |
# File 'lib/api_sports/client.rb', line 53 def odds OddsResource.new(self) end |
#predictions ⇒ Object
49 50 51 |
# File 'lib/api_sports/client.rb', line 49 def predictions PredictionsResource.new(self) end |
#seasons ⇒ Object
29 30 31 |
# File 'lib/api_sports/client.rb', line 29 def seasons SeasonsResource.new(self) end |
#standings ⇒ Object
41 42 43 |
# File 'lib/api_sports/client.rb', line 41 def standings StandingsResource.new(self) end |
#teams ⇒ Object
33 34 35 |
# File 'lib/api_sports/client.rb', line 33 def teams TeamsResource.new(self) end |
#timezones ⇒ Object
21 22 23 |
# File 'lib/api_sports/client.rb', line 21 def timezones TimezonesResource.new(self) end |
#venues ⇒ Object
37 38 39 |
# File 'lib/api_sports/client.rb', line 37 def venues VenuesResource.new(self) end |