sportradar-api 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +12 -0
- data/lib/sportradar/api/soccer.rb +12 -3
- data/lib/sportradar/api/soccer/team.rb +12 -2
- data/lib/sportradar/api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8aecf6e5a4e046e48a38fd04e4882d425364afba
|
4
|
+
data.tar.gz: 4a04847ed7c908fc3fde9099416dc192ea2c569f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0c422899928dd5df18788d37c00cd7cc1c54962a5f1bb65647ad4ecf98420445b8fe3f664f3eb516be3e60b59b9a00ce5bd41c321bed3657e6d738bdcd40514
|
7
|
+
data.tar.gz: ea221e7f902b8f13a017058e1574cc380d4bb85b7a7dc8d7101c45e77a8301a79f896d03598c3e9d483841c38c709b43bc199b99eba0dc706aaa74485dd64e74
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -70,6 +70,18 @@ Manage your ruby environment through `.ruby-version` and `.ruby-gemset` files.
|
|
70
70
|
Create `.env` for environment variables. Follow the `.env.sample` for guidance.
|
71
71
|
|
72
72
|
|
73
|
+
## Simulation Games
|
74
|
+
|
75
|
+
http://developer.sportradar.us/page/Live_Game_Simulation
|
76
|
+
|
77
|
+
Soccer
|
78
|
+
|
79
|
+
```
|
80
|
+
sim = Sportradar::Api::Soccer.new('na', 't', true)
|
81
|
+
summary = sim.match_summary(sim.simulation_match)
|
82
|
+
boxscore = sim.match_boxscore(sim.simulation_match)
|
83
|
+
```
|
84
|
+
|
73
85
|
## Development
|
74
86
|
|
75
87
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -1,12 +1,13 @@
|
|
1
1
|
module Sportradar
|
2
2
|
module Api
|
3
3
|
class Soccer < Request
|
4
|
-
attr_accessor :league, :access_level
|
5
|
-
def initialize(league = "na", access_level = "t")
|
4
|
+
attr_accessor :league, :access_level, :simulation
|
5
|
+
def initialize(league = "na", access_level = "t", simulation = false)
|
6
6
|
raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? access_level
|
7
7
|
raise Sportradar::Api::Error::InvalidLeague unless allowed_leagues.include? league
|
8
8
|
@league = league
|
9
9
|
@access_level = access_level
|
10
|
+
@simulation = simulation
|
10
11
|
end
|
11
12
|
|
12
13
|
def schedule
|
@@ -70,10 +71,18 @@ module Sportradar
|
|
70
71
|
Sportradar::Api::Soccer::Standing.new response["standings"] if response.success? && response["standings"]
|
71
72
|
end
|
72
73
|
|
74
|
+
def simulation_match
|
75
|
+
"22653ed5-0b2c-4e30-b10c-c6d51619b52b"
|
76
|
+
end
|
77
|
+
|
73
78
|
private
|
74
79
|
|
75
80
|
def request_url(path)
|
76
|
-
|
81
|
+
if simulation
|
82
|
+
"/soccer-sim2/wc/#{path}"
|
83
|
+
else
|
84
|
+
"/soccer-#{access_level}#{version}/#{league}/#{path}"
|
85
|
+
end
|
77
86
|
end
|
78
87
|
|
79
88
|
def api_key
|
@@ -36,8 +36,8 @@ module Sportradar
|
|
36
36
|
@away = OpenStruct.new data["away"] if data["away"]
|
37
37
|
|
38
38
|
@scoring = OpenStruct.new data["scoring"] if data["scoring"]
|
39
|
-
|
40
|
-
|
39
|
+
parse_scoring if scoring
|
40
|
+
|
41
41
|
@statistics = OpenStruct.new data["statistics"] if data["statistics"]
|
42
42
|
@players = data["players"]["player"].map {|player| Sportradar::Api::Soccer::Player.new player } if data["players"]
|
43
43
|
|
@@ -47,6 +47,16 @@ module Sportradar
|
|
47
47
|
|
48
48
|
alias_method :roster, :players
|
49
49
|
|
50
|
+
private
|
51
|
+
|
52
|
+
def parse_scoring
|
53
|
+
if scoring.half.is_a?(Array)
|
54
|
+
@first_half_score = scoring.half.find {|x| x["number"] == "1"}["points"]
|
55
|
+
@second_half_score = scoring.half.find {|x| x["number"] == "2"}["points"]
|
56
|
+
elsif scoring.half.is_a?(Hash)
|
57
|
+
@first_half_score = scoring.half["points"]
|
58
|
+
end
|
59
|
+
end
|
50
60
|
end
|
51
61
|
end
|
52
62
|
end
|