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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 086e7858c3f23fa867c96f5f3a016b58491a3d4c
4
- data.tar.gz: 24a1e38531cce70b3d60dae0a440a9d13b1511fa
3
+ metadata.gz: 8aecf6e5a4e046e48a38fd04e4882d425364afba
4
+ data.tar.gz: 4a04847ed7c908fc3fde9099416dc192ea2c569f
5
5
  SHA512:
6
- metadata.gz: 93648e66c26bc4633fb02919b87c585a334df9b69939fec975aef15e3ebca62ca965d444fb245d9c104c409707e275e274feeae70b62794e1b50112fa2d52104
7
- data.tar.gz: f87012b60c24c49d166adeafa51c2e3cb1db8d1b97ad023e036ff27287d3c2e3fe3cb7202428255ecd79a0b7255f2702b44cc760f2790cff2de69f071c754500
6
+ metadata.gz: c0c422899928dd5df18788d37c00cd7cc1c54962a5f1bb65647ad4ecf98420445b8fe3f664f3eb516be3e60b59b9a00ce5bd41c321bed3657e6d738bdcd40514
7
+ data.tar.gz: ea221e7f902b8f13a017058e1574cc380d4bb85b7a7dc8d7101c45e77a8301a79f896d03598c3e9d483841c38c709b43bc199b99eba0dc706aaa74485dd64e74
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sportradar-api (0.1.7)
4
+ sportradar-api (0.1.8)
5
5
  activesupport
6
6
  httparty (>= 0.13.3)
7
7
 
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
- "/soccer-#{access_level}#{version}/#{league}/#{path}"
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
- @first_half_score = data["scoring"]["half"].find {|x| x["number"] == "1"}["points"] if data["scoring"]
40
- @second_half_score = data["scoring"]["half"].find {|x| x["number"] == "2"}["points"] if data["scoring"]
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
@@ -1,5 +1,5 @@
1
1
  module Sportradar
2
2
  module Api
3
- VERSION = "0.1.7"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportradar-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Eggett