beneggett / sportradar-api

19 stars 13 forks source link

Soccer Extended API. Match sport_event_context #37

Open sramsden opened 11 months ago

sramsden commented 11 months ago

Hi @beneggett Very much enjoying your gem, thankyou!

I am just wondering about the sport_event_context in the current Soccer Extended API Currently I am not able to access the round data from the match because it's tucked away in the sport_event_context. So I was wondering if I were to provide you with a PR to do something like ..

image

.. you would accept it or would you only accept it if was more explicit eg,

image

.. or can I already access the round details and I just don't see how? I know I can if I eg,

match = Sportradar::Api::Soccer::Match.new({ 'id' => 'sr:sport_event:36886649' })
match.get_summary 

but if I'm retrieving matches via eg,

season = Sportradar::Api::Soccer::Season.new({ 'id' => 'sr:season:99573'})
season.get_schedule
season.matches.each do |match|

the match instance does not seem to have anything round related? I can see tournament_round but that is not applicable here (perhaps old API field). Obviously I could just fork your gem, but I'd rather contribute if it's an option.

Any feedback appreciated.

Thanks.

beneggett commented 11 months ago

Hi @sramsden,

What does sport_event_context look like? Is it a hash or nested hash? I'm good with the approach of your first one. Just add an attr_reader at the top of the file for it. You could also consider casting it into an openstruct like we do with @weather_data.

In the initialize method we are assigning values directly as attributes, in the update method we are casting them into other data types or manipulating them (time, etc)

Thanks for your contributions!

sramsden commented 11 months ago

It's a nested hash. Currently I'm only interested in the round number but I imagine the stage info will be of interest also.

image
sramsden commented 11 months ago

Okay, I have tested locally the option above of adding the @round_number It works as expected. I can push a branch for a PR if you allow it... or you could just add it .. there really isn't a lot to it ..

image