Closed EmilMaric closed 8 years ago
Hello @EmilMaric . You did a very good job. I honestly like your design. Indeed it's way more straightforward. I just added you as collaborator so you can be lil bit free.
@EmilMaric I think it's great you're taking on this project. I feel bad for abandoning it without fully completing it. I look forward to seeing what you do!
So I just finished my exams, and I've been working on this project since then. This pull request does not need to be merged in, I just wanted to show you my progress so far (also ignore my terrible commit messages, I was playing around with some stuff).
I thought long and hard about the overall design of this API. I went with a complete redesign because I think it's more modular and will help us scale easier when we start adding in more resources/collections like
League
andTeam
. I hope the code is clean enough and the comments thorough enough for you to understand my thought process.I'll try to explain some of the basic parts of my design and implementation. I've only implemented functionality for the
Game
resource andGames
collection for now. To start off, I'll go through how to use the redesigned API. The first part is very similar to what you already have:All I'm doing here is creating the
oauth
object and passing it to the main API handlerYahooFantasySports
.As you can see, it's pretty straightforward to use. You can also get fantasy games by their integer
game_key
. For example,yfs.games(353)
will give you the same result asyfs.games('nba')
.I also thought about adding support for querying for multiple fantasy games. I'll explain this next:
So, the most important part to take away from this is that passing in a single key to
yfs.games(...)
will give you aGame
resource object, while passing in more than one key toyfs.games(...)
will give you aGames
collection object which contains multipleGame
resource objects. Again, you can mix-and-match with string or integergame_keys
. Soyfs.games('nba', 348)
oryfs.games(358, 348)
would give you the same thing asyfs.games('nba', 'mlb')
.That's the gist of what I have so far. Let me know if you have any questions, or any criticisms of this approach. I'd love to hear what you have to say!