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
47 48 49 |
# File 'lib/sportradar/api/odds/competition.rb', line 47 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 43 44 45 |
# File 'lib/sportradar/api/odds/competition.rb', line 30 def get_player_props data = fetch_player_props prop_data = if data["competition_sport_events_players_props"].size == 10 arr = data["competition_sport_events_players_props"] data = fetch_player_props(start: 10) arr += data["competition_sport_events_players_props"] if data["competition_sport_events_players_props"].size == 10 data = fetch_player_props(start: 20) arr += data["competition_sport_events_players_props"] end else data["competition_sport_events_players_props"] end create_data(@sport_events_hash, prop_data, klass: SportEvent, api: api) data end |
#path_base ⇒ Object
url path helpers
52 53 54 |
# File 'lib/sportradar/api/odds/competition.rb', line 52 def path_base "competitions/#{id}" end |
#path_player_props ⇒ Object
56 57 58 |
# File 'lib/sportradar/api/odds/competition.rb', line 56 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 |