soccers_api 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 653c3a97ebad8be83e03ff34d0a15876a7d1b32713d38f1c65d3773bb2fbc3a4
4
- data.tar.gz: 947c578f8ec8f6b6d014dace3713b284c31bb4b0e401dde76a3fc5e8a7d52b0a
3
+ metadata.gz: abb131fece0e8485dc9933cdac3d07d86b1d4bcf64ce4a803107f6d6d207fd3c
4
+ data.tar.gz: 3a1bd5fac80f04b6a30256171864ff70603b2c649022a294c27fbdcd6ef045be
5
5
  SHA512:
6
- metadata.gz: 7cd429204545f58c28efbe1b8a13384f8f2ddcb6d37e8a01be69764134add14d4429bafb93c252d7483fa84a534abdbfb4ca036fb30c528d1d77f9136173f97d
7
- data.tar.gz: 7259a4918ce8e8a75dd24d807dca0fa03bb0f231ca5f3a60059789984092d37e53c7dc0a877af66c45a70394e13f0e8667a1ba17d50f50b4d9625c93b9802de2
6
+ metadata.gz: f983bcf39fd12db2e4129ea00fa2d320e98e688e1310a575f27194e83c39c13176642c6472888a0bc5c0d9472df23e72cc85a9cc48c8665d47360c1376ef4cab
7
+ data.tar.gz: ae3eb199e04e232a61440355285cbbae147b132b9b89e7e17e040582444f6aaa61c0065025d5233308ab64123e500af08c8013dcca1da61de760fa7745e94a8c
@@ -1 +1,51 @@
1
- require "soccers_api/continent"
1
+ # frozen_string_literal: true
2
+
3
+ require 'soccers_api/continent'
4
+ require 'soccers_api/configuration'
5
+ require 'rest-client'
6
+
7
+ module SoccersApi
8
+ class << self
9
+ attr_accessor :configuration
10
+ end
11
+
12
+ def self.configuration
13
+ @configuration ||= Configuration.new
14
+ end
15
+
16
+ def self.reset
17
+ @configuration = Configuration.new
18
+ end
19
+
20
+ def self.configure
21
+ yield(configuration)
22
+ end
23
+
24
+ def self.username
25
+ @configuration.username
26
+ end
27
+
28
+ def self.token
29
+ @configuration.token
30
+ end
31
+
32
+ protected
33
+
34
+ def self.api_url(api_for:, type:, id_type: nil , id: nil, id_type_two: nil, id_two: nil)
35
+ if type=='list'
36
+ url = "https://api.soccersapi.com/v2.2/#{api_for}/?user=#{
37
+ username
38
+ }&token=#{token}&t=list"
39
+ elsif id_type_two.present? && id_two.present?
40
+ url = "https://api.soccersapi.com/v2.2/#{api_for}/?user=#{
41
+ username
42
+ }&token=#{token}&t=#{type}&#{id_type}=#{id}&#{id_type_two}=#{id_two}"
43
+ else
44
+ url = "https://api.soccersapi.com/v2.2/#{api_for}/?user=#{
45
+ username
46
+ }&token=#{token}&t=#{type}&#{id_type}=#{id}"
47
+ end
48
+ response = RestClient.get url
49
+ JSON.parse(response.body)
50
+ end
51
+ end
@@ -0,0 +1,36 @@
1
+ module SoccersApi
2
+ class Betting
3
+ class << self
4
+ require 'rest-client'
5
+ BETTING = 'fixtures'.freeze
6
+
7
+ def pre_match_odds(match_id)
8
+ SoccersApi.api_url(
9
+ api_for: LEADER,
10
+ type: "match_odds",
11
+ id_type: 'match_id',
12
+ id: match_id
13
+ )
14
+ end
15
+
16
+ def match_odds_by_bookmaker(match_id)
17
+ SoccersApi.api_url(
18
+ api_for: LEADER,
19
+ type: "match_odds",
20
+ id_type: 'match_id',
21
+ id: match_id
22
+ )
23
+ end
24
+
25
+ def in_play_odds(match_id)
26
+ SoccersApi.api_url(
27
+ api_for: LEADER,
28
+ type: "match_oddsinplay",
29
+ id_type: 'match_id',
30
+ id: match_id
31
+ )
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SoccersApi
4
+ class Configuration
5
+ attr_accessor :username, :token
6
+
7
+ def initialize
8
+ @username = nil
9
+ @token = nil
10
+ end
11
+ end
12
+ end
@@ -1,13 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'json'
4
+
3
5
  module SoccersApi
4
6
  class Continent
5
- def self.continents
7
+ class << self
6
8
  require 'rest-client'
9
+ CONTINENT = 'continents'.freeze
10
+
11
+ def all
12
+ SoccersApi.api_url(
13
+ api_for: CONTINENT,
14
+ type: "list"
15
+ )
16
+ end
7
17
 
8
- url = 'https://api.soccersapi.com/v2.2/continents/?user=umarstads&token=4ec1d6a039a04165ce7ca1f2fd594fe0&t=list'
9
- response = RestClient.get url
10
- response.body
18
+ def by_id(id)
19
+ SoccersApi.api_url(
20
+ api_for: CONTINENT,
21
+ type: "info",
22
+ id_type: 'id',
23
+ id: id
24
+ )
25
+ end
11
26
  end
12
27
  end
13
28
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module SoccersApi
6
+ class Country
7
+ class << self
8
+ require 'rest-client'
9
+ COUNTRY = 'countries'.freeze
10
+
11
+ def all
12
+ countries = {}
13
+ (2).times do |no|
14
+ countries << SoccersApi.api_url(api_for: COUNTRY, type: "list")
15
+ end
16
+ countries
17
+ end
18
+
19
+ def by_id(id)
20
+ SoccersApi.api_url(
21
+ api_for: COUNTRY,
22
+ type: "info",
23
+ id_type: 'id',
24
+ id: id
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,144 @@
1
+ module SoccersApi
2
+ class Game
3
+ class << self
4
+ require 'rest-client'
5
+ GAME = 'fixtures'.freeze
6
+
7
+ def by_id(id)
8
+ SoccersApi.api_url(
9
+ api_for: GAME,
10
+ type: "info",
11
+ id_type: 'id',
12
+ id: id
13
+ )
14
+ end
15
+
16
+ def lineups(id)
17
+ SoccersApi.api_url(
18
+ api_for: GAME,
19
+ type: "match_lineups",
20
+ id_type: 'id',
21
+ id: id
22
+ )
23
+ end
24
+
25
+ def bench(id)
26
+ SoccersApi.api_url(
27
+ api_for: GAME,
28
+ type: "match_bench",
29
+ id_type: 'id',
30
+ id: id
31
+ )
32
+ end
33
+
34
+ def events(id)
35
+ SoccersApi.api_url(
36
+ api_for: GAME,
37
+ type: "match_events",
38
+ id_type: 'id',
39
+ id: id
40
+ )
41
+ end
42
+
43
+ def commentary(id)
44
+ SoccersApi.api_url(
45
+ api_for: GAME,
46
+ type: "match_comments",
47
+ id_type: 'id',
48
+ id: id
49
+ )
50
+ end
51
+
52
+ def trend_analysis(id)
53
+ SoccersApi.api_url(
54
+ api_for: GAME,
55
+ type: "match_trends",
56
+ id_type: 'id',
57
+ id: id
58
+ )
59
+ end
60
+
61
+ def by_date(date)
62
+ SoccersApi.api_url(
63
+ api_for: GAME,
64
+ type: "schedule",
65
+ id_type: 'd',
66
+ id: data.strftime("%F")
67
+ )
68
+ end
69
+
70
+ def by_date_and_country(data:, country_id:)
71
+ SoccersApi.api_url(
72
+ api_for: GAME,
73
+ type: "schedule",
74
+ id_type: 'd',
75
+ id: data.strftime("%F"),
76
+ id_type_two: 'country_id',
77
+ id_two:country_id
78
+ )
79
+ end
80
+
81
+ def by_date_and_league(data:, league_id:)
82
+ SoccersApi.api_url(
83
+ api_for: GAME,
84
+ type: "schedule",
85
+ id_type: 'd',
86
+ id: data.strftime("%F"),
87
+ id_type_two: 'league_id',
88
+ id_two:league_id
89
+ )
90
+ end
91
+
92
+ def by_date_and_season(data:, season_id:)
93
+ SoccersApi.api_url(
94
+ api_for: GAME,
95
+ type: "schedule",
96
+ id_type: 'd',
97
+ id: data.strftime("%F"),
98
+ id_type_two: 'season_id',
99
+ id_two:season_id
100
+ )
101
+ end
102
+
103
+ def by_season(season_id)
104
+ SoccersApi.api_url(
105
+ api_for: GAME,
106
+ type: "season",
107
+ id_type: 'season_id',
108
+ id: season_id
109
+ )
110
+ end
111
+
112
+ def by_season_and_team(team_id:, season_id:)
113
+ SoccersApi.api_url(
114
+ api_for: GAME,
115
+ type: "season",
116
+ id_type: 'season_id',
117
+ id: season_id,
118
+ id_type_two: 'team_id',
119
+ id_two:team_id
120
+ )
121
+ end
122
+
123
+ def by_round(round_id)
124
+ SoccersApi.api_url(
125
+ api_for: GAME,
126
+ type: "round",
127
+ id_type: 'round_id',
128
+ id: round_id
129
+ )
130
+ end
131
+
132
+ def by_round_and_team(team_id:, round_id:)
133
+ SoccersApi.api_url(
134
+ api_for: GAME,
135
+ type: "round",
136
+ id_type: 'round_id',
137
+ id: round_id,
138
+ id_type_two: 'team_id',
139
+ id_two:team_id
140
+ )
141
+ end
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,35 @@
1
+ module SoccersApi
2
+ class Leader
3
+ class << self
4
+ require 'rest-client'
5
+ LEADER = 'leaders'.freeze
6
+
7
+ def topcards(season_id)
8
+ SoccersApi.api_url(
9
+ api_for: LEADER,
10
+ type: "topcards",
11
+ id_type: 'season_id',
12
+ id: season_id
13
+ )
14
+ end
15
+
16
+ def topscorers(season_id)
17
+ SoccersApi.api_url(
18
+ api_for: LEADER,
19
+ type: "topscorers",
20
+ id_type: 'season_id',
21
+ id: season_id
22
+ )
23
+ end
24
+
25
+ def topassists(season_id)
26
+ SoccersApi.api_url(
27
+ api_for: LEADER,
28
+ type: "topassists",
29
+ id_type: 'season_id',
30
+ id: season_id
31
+ )
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,39 @@
1
+ module SoccersApi
2
+ class League
3
+ class << self
4
+ require 'rest-client'
5
+ LEAGUE = 'leagues'.freeze
6
+
7
+ def all
8
+ SoccersApi.api_url(api_for: LEAGUE, type: "list")
9
+ end
10
+
11
+ def by_id(id)
12
+ SoccersApi.api_url(
13
+ api_for: LEAGUE,
14
+ type: "info",
15
+ id_type: 'id',
16
+ id: id
17
+ )
18
+ end
19
+
20
+ def by_country(country_id)
21
+ SoccersApi.api_url(
22
+ api_for: LEAGUE,
23
+ type: "list",
24
+ id_type: 'country_id',
25
+ id: country_id
26
+ )
27
+ end
28
+
29
+ def standings(season_id)
30
+ SoccersApi.api_url(
31
+ api_for: LEAGUE,
32
+ type: "standings",
33
+ id_type: 'season_id',
34
+ id: season_id
35
+ )
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,50 @@
1
+ module SoccersApi
2
+ class LiveScore
3
+ class << self
4
+ require 'rest-client'
5
+ LIVE_SCORE = 'livescores'.freeze
6
+
7
+ def today
8
+ SoccersApi.api_url(
9
+ api_for: LIVE_SCORE,
10
+ type: "today"
11
+ )
12
+ end
13
+
14
+ def tomorrow
15
+ SoccersApi.api_url(
16
+ api_for: LIVE_SCORE,
17
+ type: "tomorrow"
18
+ )
19
+ end
20
+
21
+ def yesterday
22
+ SoccersApi.api_url(
23
+ api_for: LIVE_SCORE,
24
+ type: "yesterday"
25
+ )
26
+ end
27
+
28
+ def not_started
29
+ SoccersApi.api_url(
30
+ api_for: LIVE_SCORE,
31
+ type: "notstarted"
32
+ )
33
+ end
34
+
35
+ def live
36
+ SoccersApi.api_url(
37
+ api_for: LIVE_SCORE,
38
+ type: "live"
39
+ )
40
+ end
41
+
42
+ def ended
43
+ SoccersApi.api_url(
44
+ api_for: LIVE_SCORE,
45
+ type: "ended"
46
+ )
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,26 @@
1
+ module SoccersApi
2
+ class Player
3
+ class << self
4
+ require 'rest-client'
5
+ PLAYER = 'players'.freeze
6
+
7
+ def by_id(id)
8
+ SoccersApi.api_url(
9
+ api_for: PLAYER,
10
+ type: "info",
11
+ id_type: 'id',
12
+ id: id
13
+ )
14
+ end
15
+
16
+ def by_country(country_id)
17
+ SoccersApi.api_url(
18
+ api_for: PLAYER,
19
+ type: "info",
20
+ id_type: 'country_id',
21
+ id: country_id
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module SoccersApi
2
+ class Round
3
+ class << self
4
+ require 'rest-client'
5
+ ROUND = 'rounds'.freeze
6
+
7
+ def by_id(id)
8
+ SoccersApi.api_url(
9
+ api_for: ROUND,
10
+ type: "info",
11
+ id_type: 'id',
12
+ id: id
13
+ )
14
+ end
15
+
16
+ def by_season(season_id)
17
+ SoccersApi.api_url(
18
+ api_for: ROUND,
19
+ type: "byseason",
20
+ id_type: 'season_id',
21
+ id: season_id
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,17 @@
1
+ module SoccersApi
2
+ class Season
3
+ class << self
4
+ require 'rest-client'
5
+ SEASON = 'seasons'.freeze
6
+
7
+ def by_id(id)
8
+ SoccersApi.api_url(
9
+ api_for: SEASON,
10
+ type: "info",
11
+ id_type: 'id',
12
+ id: id
13
+ )
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,53 @@
1
+ module SoccersApi
2
+ class Stats
3
+ class << self
4
+ require 'rest-client'
5
+ STATS = 'stats'.freeze
6
+
7
+ def by_match(match_id)
8
+ SoccersApi.api_url(
9
+ api_for: STATS,
10
+ type: "match",
11
+ id_type: 'match_id',
12
+ id: match_id
13
+ )
14
+ end
15
+
16
+ def by_league(league_id)
17
+ SoccersApi.api_url(
18
+ api_for: STATS,
19
+ type: "league",
20
+ id_type: 'league_id',
21
+ id: league_id
22
+ )
23
+ end
24
+
25
+ def by_season(season_id)
26
+ SoccersApi.api_url(
27
+ api_for: STATS,
28
+ type: "season",
29
+ id_type: 'season_id',
30
+ id: season_id
31
+ )
32
+ end
33
+
34
+ def by_team(team_id)
35
+ SoccersApi.api_url(
36
+ api_for: STATS,
37
+ type: "team",
38
+ id_type: 'team_id',
39
+ id: team_id
40
+ )
41
+ end
42
+
43
+ def by_player(player_id)
44
+ SoccersApi.api_url(
45
+ api_for: STATS,
46
+ type: "player",
47
+ id_type: 'player_id',
48
+ id: player_id
49
+ )
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,37 @@
1
+ module SoccersApi
2
+ class League
3
+ class << self
4
+ require 'rest-client'
5
+ TEAM = 'teams'.freeze
6
+
7
+ def by_id(id)
8
+ SoccersApi.api_url(
9
+ api_for: TEAM,
10
+ type: "info",
11
+ id_type: 'id',
12
+ id: id
13
+ )
14
+ end
15
+
16
+ def by_country(country_id)
17
+ SoccersApi.api_url(
18
+ api_for: TEAM,
19
+ type: "list",
20
+ id_type: 'country_id',
21
+ id: country_id
22
+ )
23
+ end
24
+
25
+ def by_season(season_id)
26
+ SoccersApi.api_url(
27
+ api_for: TEAM,
28
+ type: "byseason",
29
+ id_type: 'season_id',
30
+ id: season_id
31
+ )
32
+ end
33
+
34
+ # todo: create remaining methods
35
+ end
36
+ end
37
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SoccersApi
4
- VERSION = '1.0.5'
4
+ VERSION = '1.0.6'
5
5
  end
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soccers_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - umar482
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-15 00:00:00.000000000 Z
11
+ date: 2020-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,12 +85,26 @@ files:
85
85
  - bin/console
86
86
  - bin/setup
87
87
  - lib/soccers_api.rb
88
+ - lib/soccers_api/betting.rb
89
+ - lib/soccers_api/configuration.rb
88
90
  - lib/soccers_api/continent.rb
91
+ - lib/soccers_api/country.rb
92
+ - lib/soccers_api/game.rb
93
+ - lib/soccers_api/leader.rb
94
+ - lib/soccers_api/league.rb
95
+ - lib/soccers_api/live_score.rb
96
+ - lib/soccers_api/player.rb
97
+ - lib/soccers_api/round.rb
98
+ - lib/soccers_api/season.rb
99
+ - lib/soccers_api/stats.rb
100
+ - lib/soccers_api/team.rb
89
101
  - lib/soccers_api/version.rb
90
102
  - soccers_api-0.1.0.gem
91
103
  - soccers_api-1.0.1.gem
92
104
  - soccers_api-1.0.2.gem
93
105
  - soccers_api-1.0.3.gem
106
+ - soccers_api-1.0.4.gem
107
+ - soccers_api-1.0.5.gem
94
108
  - soccers_api.gemspec
95
109
  homepage: https://github.com/umar482/soccers_api
96
110
  licenses: