football-butler 1.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/lib/football/butler/api.rb +14 -17
  3. data/lib/football/butler/api_football/base_api_football.rb +17 -0
  4. data/lib/football/butler/api_football/coachs.rb +46 -0
  5. data/lib/football/butler/api_football/countries.rb +39 -0
  6. data/lib/football/butler/api_football/fixtures.rb +80 -0
  7. data/lib/football/butler/api_football/head_to_head.rb +56 -0
  8. data/lib/football/butler/api_football/injuries.rb +62 -0
  9. data/lib/football/butler/api_football/leagues.rb +101 -0
  10. data/lib/football/butler/api_football/lineups.rb +39 -0
  11. data/lib/football/butler/api_football/odds.rb +55 -0
  12. data/lib/football/butler/api_football/players.rb +47 -0
  13. data/lib/football/butler/api_football/predictions.rb +27 -0
  14. data/lib/football/butler/api_football/sidelineds.rb +37 -0
  15. data/lib/football/butler/api_football/standings.rb +35 -0
  16. data/lib/football/butler/api_football/statistics.rb +22 -0
  17. data/lib/football/butler/api_football/teams.rb +66 -0
  18. data/lib/football/butler/api_football/timezones.rb +21 -0
  19. data/lib/football/butler/api_football/top_scorers.rb +22 -0
  20. data/lib/football/butler/api_football/transfers.rb +36 -0
  21. data/lib/football/butler/api_football/trophies.rb +37 -0
  22. data/lib/football/butler/api_football/venues.rb +66 -0
  23. data/lib/football/butler/apifootball/base_apifootball.rb +17 -0
  24. data/lib/football/butler/apifootball/competitions.rb +30 -0
  25. data/lib/football/butler/apifootball/countries.rb +20 -0
  26. data/lib/football/butler/apifootball/events.rb +61 -0
  27. data/lib/football/butler/apifootball/head_to_head.rb +30 -0
  28. data/lib/football/butler/apifootball/lineups.rb +22 -0
  29. data/lib/football/butler/apifootball/odds.rb +25 -0
  30. data/lib/football/butler/apifootball/players.rb +27 -0
  31. data/lib/football/butler/apifootball/predictions.rb +28 -0
  32. data/lib/football/butler/apifootball/standings.rb +23 -0
  33. data/lib/football/butler/apifootball/statistics.rb +22 -0
  34. data/lib/football/butler/apifootball/teams.rb +29 -0
  35. data/lib/football/butler/apifootball/top_scorers.rb +22 -0
  36. data/lib/football/butler/areas.rb +23 -23
  37. data/lib/football/butler/base.rb +45 -18
  38. data/lib/football/butler/coachs.rb +26 -0
  39. data/lib/football/butler/competitions.rb +53 -44
  40. data/lib/football/butler/configuration.rb +275 -14
  41. data/lib/football/butler/countries.rb +11 -0
  42. data/lib/football/butler/events.rb +11 -0
  43. data/lib/football/butler/fixtures.rb +11 -0
  44. data/lib/football/butler/football_data/areas.rb +40 -0
  45. data/lib/football/butler/football_data/competitions.rb +72 -0
  46. data/lib/football/butler/football_data/head_to_head.rb +27 -0
  47. data/lib/football/butler/football_data/lineups.rb +32 -0
  48. data/lib/football/butler/football_data/matches.rb +110 -0
  49. data/lib/football/butler/football_data/odds.rb +27 -0
  50. data/lib/football/butler/football_data/players.rb +20 -0
  51. data/lib/football/butler/football_data/scorers.rb +23 -0
  52. data/lib/football/butler/football_data/standings.rb +47 -0
  53. data/lib/football/butler/football_data/teams.rb +39 -0
  54. data/lib/football/butler/head_to_head.rb +28 -0
  55. data/lib/football/butler/injuries.rb +31 -0
  56. data/lib/football/butler/leagues.rb +11 -0
  57. data/lib/football/butler/lineups.rb +18 -0
  58. data/lib/football/butler/matches.rb +48 -83
  59. data/lib/football/butler/odds.rb +18 -0
  60. data/lib/football/butler/players.rb +26 -0
  61. data/lib/football/butler/predictions.rb +17 -0
  62. data/lib/football/butler/scorers.rb +22 -0
  63. data/lib/football/butler/sidelineds.rb +20 -0
  64. data/lib/football/butler/standings.rb +30 -0
  65. data/lib/football/butler/statistics.rb +17 -0
  66. data/lib/football/butler/teams.rb +23 -23
  67. data/lib/football/butler/tier.rb +26 -11
  68. data/lib/football/butler/timezones.rb +16 -0
  69. data/lib/football/butler/top_scorers.rb +11 -0
  70. data/lib/football/butler/transfers.rb +21 -0
  71. data/lib/football/butler/trophies.rb +21 -0
  72. data/lib/football/butler/venues.rb +34 -0
  73. data/lib/football/butler/version.rb +8 -2
  74. data/lib/football/butler.rb +20 -0
  75. metadata +71 -7
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+ require 'football/butler/api_football/base_api_football'
3
+
4
+ module Football
5
+ module Butler
6
+ module ApiFootball
7
+ class Venues < BaseApiFootball
8
+ PATH = :venues
9
+
10
+ class << self
11
+ ## VENUES
12
+ #
13
+ # id
14
+ # integer
15
+ # The id of the venue
16
+ #
17
+ # name
18
+ # string
19
+ # The name of the venue
20
+ #
21
+ # city
22
+ # string
23
+ # The city of the venue
24
+ #
25
+ # country
26
+ # string
27
+ # The country name of the venue
28
+ #
29
+ # search
30
+ # string >= 3 characters
31
+ # The name, city or the country of the venue
32
+ #
33
+ # /venues?city={city}
34
+ def by_city(city:, result:, filters:)
35
+ filters.merge!({city: city})
36
+ Api.get(path: PATH, result: result, filters: filters)
37
+ end
38
+
39
+ # /venues?country={country}
40
+ def by_country(country:, result:, filters:)
41
+ filters.merge!({country: country})
42
+ Api.get(path: PATH, result: result, filters: filters)
43
+ end
44
+
45
+ # /venues?name={name}
46
+ def by_name(name:, result:, filters:)
47
+ filters.merge!({name: name})
48
+ Api.get(path: PATH, result: result, filters: filters)
49
+ end
50
+
51
+ # /venues?id={id}
52
+ def by_id(id:, result:, filters:)
53
+ filters.merge!({id: id})
54
+ Api.get(path: PATH, result: result, filters: filters)
55
+ end
56
+
57
+ # /venues?search={search}
58
+ def search(search:, result:, filters:)
59
+ filters.merge!({search: search})
60
+ Api.get(path: PATH, result: result, filters: filters)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Football
4
+ module Butler
5
+ module Apifootball
6
+ class BaseApifootball < Base
7
+
8
+ class << self
9
+ def build_path(action)
10
+ "action=#{action}"
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ require 'football/butler/apifootball/base_apifootball'
3
+
4
+ module Football
5
+ module Butler
6
+ module Apifootball
7
+ class Competitions < BaseApifootball
8
+ PATH = :get_leagues
9
+
10
+ class << self
11
+ ## COMPETITION
12
+ # action=get_leagues&country_id={id}
13
+ def by_country(id:, result:)
14
+ filters = { country_id: id }
15
+ Api.get(path: build_path(PATH), filters: filters, result: result)
16
+ end
17
+
18
+ ## COMPETITIONS
19
+ #
20
+ # country_id Country ID - if set only leagues from specific country will be returned (Optional)
21
+ #
22
+ # action=get_league
23
+ def all(result:, filters:)
24
+ Api.get(path: build_path(PATH), result: result, filters: filters)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ require 'football/butler/apifootball/base_apifootball'
3
+
4
+ module Football
5
+ module Butler
6
+ module Apifootball
7
+ class Countries < BaseApifootball
8
+ PATH = :get_countries
9
+
10
+ class << self
11
+ ## COUNTRIES
12
+ # action=get_leagues
13
+ def all(result:)
14
+ Api.get(path: build_path(PATH), result: result)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+ require 'football/butler/apifootball/base_apifootball'
3
+
4
+ module Football
5
+ module Butler
6
+ module Apifootball
7
+ class Events < BaseApifootball
8
+ PATH = :get_events
9
+
10
+ class << self
11
+ ## EVENT
12
+ # action=get_events?match_id={id}
13
+ def by_id(id:)
14
+ filters = { match_id: id }
15
+ Api.get(path: build_path(PATH), result: :parsed_response, filters: filters)
16
+ end
17
+
18
+ ## EVENTS
19
+ #
20
+ # timezone Default timezone: Europe/Berlin.
21
+ # With this filter you can set the timezone where you want to receive the data.
22
+ # Timezone is in TZ format (exemple: America/New_York). (Optional)
23
+ # from Start date (yyyy-mm-dd)
24
+ # to Stop date (yyyy-mm-dd)
25
+ # country_id Country ID if set only leagues from specific country will be returned (Optional)
26
+ # league_id League ID if set events from specific league will be returned (Optional)
27
+ # match_id Match ID if set only details from specific match will be returned (Optional)
28
+ # team_id Team ID if set only details from specific team will be returned (Optional)
29
+ #
30
+ # action=get_events&...<AT LEAST ONE PARAMETER IS REQUIRED!>
31
+ # "error": 201, "message": "Required parameters missing"
32
+ def all(result:, filters:)
33
+ Api.get(path: build_path(PATH), result: result, filters: filters)
34
+ end
35
+
36
+ ## by COMPETITION
37
+ # action=get_events?league_id={id}
38
+ def by_competition(id:, result:, filters:)
39
+ filters.merge!({ league_id: id })
40
+ Api.get(path: build_path(PATH), filters: filters, result: result)
41
+ end
42
+
43
+ # action=get_events?league_id={id}&from={year}-01-01&{year}-12-31
44
+ def by_competition_and_year(id:, year:, result:, filters:)
45
+ from = "#{year}-01-01"
46
+ to = "#{year}-12-31"
47
+ filters.merge!({ league_id: id, from: from, to: to })
48
+ Api.get(path: build_path(PATH), filters: filters, result: result)
49
+ end
50
+
51
+ ## by TEAM
52
+ # action=get_events?team_id={id}
53
+ def by_team(id:, result:, filters:)
54
+ filters.merge!({ team_id: id })
55
+ Api.get(path: build_path(PATH), result: result, filters: filters)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ require 'football/butler/apifootball/base_apifootball'
3
+
4
+ module Football
5
+ module Butler
6
+ module Apifootball
7
+ class HeadToHead < BaseApifootball
8
+ PATH = :get_H2H
9
+
10
+ class << self
11
+ ## HEAD TO HEAD
12
+ #
13
+ # timezone Default timezone: Europe/Berlin. With this filter you can set the timezone
14
+ # where you want to receive the data. Timezone is in TZ format (exemple: America/New_York).
15
+ # (Optional)
16
+ # firstTeam First team name
17
+ # secondTeam Second team name
18
+ # firstTeamId First team Id
19
+ # secondTeamId Second team Id
20
+ #
21
+ # action=get_H2H&firstTeamId={team_id}&secondTeamId={second_team_id}
22
+ def by_teams(team_id:, second_team_id:, filters:, result:)
23
+ filters.merge!(firstTeamId: team_id, secondTeamId: second_team_id)
24
+ Api.get(path: build_path(PATH), filters: filters, result: result)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ require 'football/butler/apifootball/base_apifootball'
3
+
4
+ module Football
5
+ module Butler
6
+ module Apifootball
7
+ class Lineups < BaseApifootball
8
+ PATH = :get_lineups
9
+
10
+ class << self
11
+ ## LINEUPS
12
+ #
13
+ # action=get_lineups&match_id={id}
14
+ def by_match(id:)
15
+ filters = { match_id: id }
16
+ Api.get(path: build_path(PATH), filters: filters, result: :parsed_response)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ require 'football/butler/apifootball/base_apifootball'
3
+
4
+ module Football
5
+ module Butler
6
+ module Apifootball
7
+ class Odds < BaseApifootball
8
+ PATH = :get_odds
9
+
10
+ class << self
11
+ ## ODDS
12
+ #
13
+ # from Start date (yyyy-mm-dd)
14
+ # to Stop date (yyyy-mm-dd)
15
+ #
16
+ # action=get_odds&match_id={id}&from={from}&to={to}
17
+ def by_match(id:, from:, to:, result:)
18
+ filters = { match_id: id, from: from, to: to }
19
+ Api.get(path: build_path(PATH), filters: filters, result: result)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+ require 'football/butler/apifootball/base_apifootball'
3
+
4
+ module Football
5
+ module Butler
6
+ module Apifootball
7
+ class Players < BaseApifootball
8
+ PATH = :get_players
9
+
10
+ class << self
11
+ ## PLAYER
12
+ # action=get_players?player_id={id}
13
+ def by_id(id:)
14
+ filters = { player_id: id }
15
+ Api.get(path: build_path(PATH), filters: filters, result: :parsed_response)
16
+ end
17
+
18
+ # action=get_players?name={name}
19
+ def by_name(name:, result:)
20
+ filters = { player_name: name }
21
+ Api.get(path: build_path(PATH), filters: filters, result: result)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+ require 'football/butler/apifootball/base_apifootball'
3
+
4
+ module Football
5
+ module Butler
6
+ module Apifootball
7
+ class Predictions < BaseApifootball
8
+ PATH = :get_predictions
9
+
10
+ class << self
11
+ ## PREDICTIONS
12
+ #
13
+ # from Start date (yyyy-mm-dd)
14
+ # to Stop date (yyyy-mm-dd)
15
+ # country_id Country ID - if set only leagues from specific country will be returned (Optional)
16
+ # league_id League ID - if set events from specific league will be returned (Optional)
17
+ # match_id Match ID - if set only details from specific match will be returned (Optional)
18
+ #
19
+ # get_predictions&match_id={id}
20
+ def by_match(id:, filters:, result:)
21
+ filters.merge!(match_id: id)
22
+ Api.get(path: build_path(PATH), filters: filters, result: result)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ require 'football/butler/apifootball/base_apifootball'
3
+
4
+ module Football
5
+ module Butler
6
+ module Apifootball
7
+ class Standings < BaseApifootball
8
+ PATH = :get_standings
9
+
10
+ class << self
11
+ ## STANDINGS / League
12
+ #
13
+ # action=get_standings&league_id={id}
14
+ def by_competition(id:, result: , filters:)
15
+ filters.merge!({ league_id: id })
16
+ Api.get(path: build_path(PATH), result: result, filters: filters)
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ require 'football/butler/apifootball/base_apifootball'
3
+
4
+ module Football
5
+ module Butler
6
+ module Apifootball
7
+ class Statistics < BaseApifootball
8
+ PATH = :get_statistics
9
+
10
+ class << self
11
+ ## STATISTICS
12
+ #
13
+ # action=get_statistics&match_id={id}
14
+ def by_match(id:, result:)
15
+ filters = { match_id: id }
16
+ Api.get(path: build_path(PATH), filters: filters, result: result)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+ require 'football/butler/apifootball/base_apifootball'
3
+
4
+ module Football
5
+ module Butler
6
+ module Apifootball
7
+ class Teams < BaseApifootball
8
+ PATH = :get_teams
9
+
10
+ class << self
11
+ ## TEAM
12
+ # action=get_teams&team_id={id}
13
+ def by_id(id:)
14
+ filters = { team_id: id }
15
+ Api.get(path: build_path(PATH), filters: filters, result: :parsed_response)
16
+ end
17
+
18
+ ## COMPETITION
19
+ # action=get_teams&league_id={id}
20
+ def by_competition(id:, result:, filters:)
21
+ filters.merge!({ league_id: id })
22
+ Api.get(path: build_path(PATH), result: result, filters: filters)
23
+ end
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ require 'football/butler/apifootball/base_apifootball'
3
+
4
+ module Football
5
+ module Butler
6
+ module Apifootball
7
+ class TopScorers < BaseApifootball
8
+ PATH = :get_topscorers
9
+
10
+ class << self
11
+ ## TOP SCORER
12
+ #
13
+ # action=get_topscorers?league_id={id}
14
+ def by_competition(id:, result:, filters:)
15
+ filters.merge!({ league_id: id })
16
+ Api.get(path: build_path(PATH), filters: filters, result: result)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end