Class: Sportradar::Api::Odds::Competition
- Defined in:
- lib/sportradar/api/odds/competition.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#gender ⇒ Object
Returns the value of attribute gender.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #fetch_player_props(params = {}) ⇒ Object
- #get_player_props ⇒ Object
-
#initialize(data, **opts) ⇒ Competition
constructor
A new instance of Competition.
-
#path_base ⇒ Object
url path helpers.
- #path_player_props ⇒ Object
- #sport_events ⇒ Object
- #update(data, **opts) ⇒ Object
Methods inherited from Data
#all_attributes, #attributes, #create_data, #parse_into_array, #parse_into_array_with_options, #parse_out_hashes, #structure_links, #update_data
Constructor Details
#initialize(data, **opts) ⇒ Competition
Returns a new instance of Competition.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sportradar/api/odds/competition.rb', line 8 def initialize(data, **opts) @response = data @api = opts[:api] @id = data['id'] @name = data['name'] @gender = data['gender'] @has_markets = data['markets'] # boolean @has_futures = data['futures'] # boolean @has_player_props = data['player_props'] # boolean @sport_events_hash = {} end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
5 6 7 |
# File 'lib/sportradar/api/odds/competition.rb', line 5 def api @api end |
#gender ⇒ Object
Returns the value of attribute gender.
5 6 7 |
# File 'lib/sportradar/api/odds/competition.rb', line 5 def gender @gender end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/sportradar/api/odds/competition.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/sportradar/api/odds/competition.rb', line 5 def name @name end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/sportradar/api/odds/competition.rb', line 5 def response @response end |
Instance Method Details
#fetch_player_props(params = {}) ⇒ Object
44 45 46 |
# File 'lib/sportradar/api/odds/competition.rb', line 44 def fetch_player_props(params = {}) api.get_data(path_player_props, params) end |
#get_player_props ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sportradar/api/odds/competition.rb', line 30 def get_player_props prop_data = fetch_player_props.fetch('competition_sport_events_players_props', []) if prop_data.size == 10 new_data = prop_data while new_data.size == 10 new_data = fetch_player_props(start: prop_data.size).fetch('competition_sport_events_players_props', []) prop_data += new_data end end data = {'competition_sport_events_players_props' => prop_data } create_data(@sport_events_hash, prop_data, klass: SportEvent, api: api) data end |
#path_base ⇒ Object
url path helpers
49 50 51 |
# File 'lib/sportradar/api/odds/competition.rb', line 49 def path_base "competitions/#{id}" end |
#path_player_props ⇒ Object
53 54 55 |
# File 'lib/sportradar/api/odds/competition.rb', line 53 def path_player_props "#{path_base}/players_props" end |
#sport_events ⇒ Object
26 27 28 |
# File 'lib/sportradar/api/odds/competition.rb', line 26 def sport_events @sport_events_hash.values end |
#update(data, **opts) ⇒ Object
22 23 24 |
# File 'lib/sportradar/api/odds/competition.rb', line 22 def update(data, **opts) end |