Closed MrMicrowaveOven closed 3 years ago
You are right, the MLB parts do need some more documentation. I added some info to the README in the baseball directory, hopefully that will help get you started. To address the two specific uses you mentioned:
mlb = Sportradar::Api::Baseball::Mlb::Hierarchy.new
res = mlb.get_schedule # => res is the raw response from Sportradar. `mlb` now has season schedule
mlb.games.count # => 2430
game = mlb.games.sample # => Sportradar::Api::Baseball::Game
data = game.get_pbp # => data is the response data from Sportradar. `game` has inning/half inning/atbats now
game.innings.count # => 10 (Sportradar has an inning 0, corresponding to starting lineups)
game.half_innings.count # => 20
game.at_bats # => at bats for the game
To instantiate a game directly (without going through the schedule):
game = Sportradar::Api::Baseball::Game.new('id' => "fe9f37fd-6848-4a32-a999-9655044b7319")
game.get_pbp
Unfortunately, we haven't really gotten around the documenting everything in the gem. We started developing it for internal use, but felt it would be better to keep it as open source. We would absolutely welcome any PRs and other feedback you might have, as we have been looking to add test and doc coverage.
Lastly, many of the baseball classes had code snippets at the end of the file (after the __END__
. These were mostly added during development to help move rapidly. They might be helpful to explore various ways of retrieving data and interacting with the data. They aren't meant as documentation but they may be useful to you.
I stumbled upon this gem while attempting to make a fun little app that uses the SportRadar API. This seems like a very convenient way to call the API through Rails.
However, the MLB portion isn't really documented, and I'm sorta shooting in the dark as far as how to call different things.
I would love to update your documentation so that users of the gem can put it to good use, but I need something to start with. I called the gem with
Sportradar::Api::Baseball::Mlb.new(event_id: "4ae1fd7c-c7f8-4c51-92b6-94af55a66b24").fetch
, and got something, so I know I'm close. I only really need to call the full League Schedule and the Play-By-Play, and would be happy to add the docs as I go along. Any information you can give me would speed things up drastically.Other than that, it looks like this gem will save me a great deal of time. Thanks!