Class: Sportradar::Api::Odds::Competition

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/odds/competition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#apiObject

Returns the value of attribute api.



5
6
7
# File 'lib/sportradar/api/odds/competition.rb', line 5

def api
  @api
end

#genderObject

Returns the value of attribute gender.



5
6
7
# File 'lib/sportradar/api/odds/competition.rb', line 5

def gender
  @gender
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/sportradar/api/odds/competition.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/sportradar/api/odds/competition.rb', line 5

def name
  @name
end

#responseObject

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_propsObject



36
37
38
# File 'lib/sportradar/api/odds/competition.rb', line 36

def fetch_player_props
  api.get_data(path_player_props)
end

#get_player_propsObject



30
31
32
33
34
# File 'lib/sportradar/api/odds/competition.rb', line 30

def get_player_props
  data = fetch_player_props
  create_data(@sport_events_hash, data["competition_sport_events_players_props"], klass: SportEvent, api: api)
  data
end

#path_baseObject

url path helpers



41
42
43
# File 'lib/sportradar/api/odds/competition.rb', line 41

def path_base
  "competitions/#{id}"
end

#path_player_propsObject



45
46
47
# File 'lib/sportradar/api/odds/competition.rb', line 45

def path_player_props
  "#{path_base}/players_props"
end

#sport_eventsObject



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