josuebrunel / yahoo-fantasy-sport

Python Yahoo! Fantasy Sports
MIT License
28 stars 9 forks source link

put method to update roster #29

Open josuebrunel opened 9 years ago

josuebrunel commented 9 years ago

roster-resource

josuebrunel commented 9 years ago

Hello @unpairestgood , about the roster resource, it seems like the only sub-resource possible is the player resource. Couldn't we just remove the sub attribute from the _get_roster_plalyers_. I will try to come up with a lil bit of code tomorrow

peacing commented 9 years ago

Sounds good Josue. What you're saying makes sense and is probably a better way to do it. I know it's been a bit of slow progress lately, but as soon as I get a free afternoon I'm just gonna sit down and finish making functions for everything. I'm ready to move onto the next thing!

josuebrunel commented 8 years ago

@unpairestgood , ok. Don't worry, take all the time you need. There's no rush after all. The first release is at latest at the end of the month, and we've already covered a lot of ground though thanks to you :+1: . By the way, i will surely implement the put method, i will need you to test it. Have a good Paul, see ya

peacing commented 8 years ago

I'm about to go to sleep and am wgoing to type this quickly Josue.

  1. I wasn't able to merge the changes you made in your master branch into my forked repo. I'm not sure if this is because of the Travis changes or maybe I'm doing something wrong, but there was merge conflict. For now, I just tried to manually update my local version.
  2. For accessing Players as a sub-resource to rosters, it has to be more flexible than adding 'roster/players'. When you add ''roster/players' it defaults to metadata as the sub-resource, but you could add 'roster/players/stats' or 'roster/players/ownership', for example, when using Players as a sub-resource.

I hope to add a new commit for this tomorrow. Thanks,

josuebrunel commented 8 years ago

I wasn't able to merge the changes you made in your master branch into my forked repo. I'm not sure if this is because of the Travis changes or maybe I'm doing something wrong, but there was merge conflict. For now, I just tried to manually update my local version.

Ok i will check why there was a merge conflict. Anyway, it happens from time to time.

For accessing Players as a sub-resource to rosters, it has to be more flexible than adding 'roster/players'. When you add ''roster/players' it defaults to metadata as the sub-resource, but you could add 'roster/players/stats' or 'roster/players/ownership', for example, when using Players as a sub-resource.

Ok, got it. I will try to do something like this ( hope you're talking about this

    def get_roster_players(self, team_keys, week=None, date=None, sub=None):
        """Access roster info, with player sub option
        >>> yfs.get_roster_players(['238.l.627062'])
        """
        if sub:
             sub = 'roster/players/{0}'.format(sub)
        esle:
             sub = 'roster/players/'
        uri = self._build_uri(None, team_keys, sub=sub)
        uri = 'team/{0}'.format(uri) # Done to avoid having 'team=238.l.627062', which doesn't work for this resource

        if week: 
            uri += ';week={0}'.format(week)
        if date:
            uri += ';date={0}'.format(date)

        response = self._get(uri)
        return response 

I will keep you posted anyway.

Thanks again Paul

josuebrunel commented 8 years ago

By the way what happens when you merge it ? Don't worry, fixing merge conflict isn't that of a big deal anyway, just merge then fix the merge by going into each file where the _merge conflict_ occurred and try to adjust the changes. Git will let you know what are the lines conflicting in those files

josuebrunel commented 8 years ago

Hey @unpairestgood, could you please qualify this commit. It's about this issue. Yahoo Documentation is here. Thanks

PS: I think we're almost done, we did a good job so far. Don't hesitate to comment on my commits if something isn't very clear. Always good to have feedbacks from people :wink:

peacing commented 8 years ago

Hello @josuebrunel, thank you for setting up the integration branch for me.

To make sure we understand each other, by "qualify this commit" do you mean: pull the code from that commit to my local machine, then test to see if it works correctly?

If yes, I would like to do this correctly. I'm having a little trouble getting my forked version updated with your new code. I don't see the new integration branch in my forked repo (I thought I would).

screen shot 2015-07-18 at 5 41 51 pm

Would viewing the pull request on this compare be the right way to add your changes to my repo? Sorry I'm a little out of the flow at the moment and could use a little help to get moving again.

Thank you!

josuebrunel commented 8 years ago

Hello @unpairestgood,

To make sure we understand each other, by "qualify this commit" do you mean: pull the code from that commit to my local machine, then test to see if it works correctly?

Yes buddy !!

I'm having a little trouble getting my forked version updated with your new code. I don't see the new integration branch in my forked repo (I thought I would).

Just accept this pull request and it should work. Yeah you won't have that branch in work fork version, you still can though, by

  1. Creating an integration branch
  2. Pulling changes from my integration branch to your integration branch by creating a _pull request_

Let me know if you need anything

peacing commented 8 years ago

@josuebrunel I tested test_roster_in_json, test_roster_in_xml, test_player_in_json, and test_player_in_xml and they all passed OK :). Thank you for setting those up.

What I'd like to do now is add structure so you can pass the player codes and new positions of the players you want to swap in your lineup. If I specify my actual fantasy baseball team code ('346.l.1328.t.12') in the URL:

address = 'http://fantasysports.yahooapis.com/fantasy/v2/team/%s/roster' % team_code

I should see the changes in my actual roster (http://baseball.fantasysports.yahoo.com/b1/1328/12)

Now that I look at it, it seems like you started to build some of this functionality in roster.py.

Just so you know where I'm headed, the last step for me is to pull in stat projections for players from a SQL database. Then I'll write logic like "If player A has a higher projection than player B, put Player A in lineup and Player B to bench."

Have a great one,

josuebrunel commented 8 years ago

What I'd like to do now is add structure so you can pass the player codes and new positions of the players you want to swap in your lineup. If I specify my actual fantasy baseball team code ('346.l.1328.t.12') in the URL:

Check this method out, it's supposed to accomplish that. By the way, you can use this unfinished test

Just so you know where I'm headed, the last step for me is to pull in stat projections for players from a SQL database. Then I'll write logic like "If player A has a higher projection than player B, put Player A in lineup and Player B to bench."

I would be glad to work on that if you want, just open an issue and assign it to me . Unless you want to work on that.

See ya

peacing commented 8 years ago

@josuebrunel I tried to get the set_roster_players function to work on my actual team, hopefully you see my attempt in the latest commit that references this very issue!

But alas, it wasn't working. In the documentation the test to PUT in XML begins with:

"<?xml version="1.0"?>

In the XML and JSON functions in roster.py, it seems to be missing that first tag... maybe this is the cause of the issue?

For reference, we did get the put function to work (in XML format) in an earlier version of the wrapper. I'm going to screenshot that code which I still have in case it helps:

screen shot 2015-07-20 at 10 56 14 pm


Also thank you for offering to help with the SQL part of my project. I'm certainly going to explore it myself first, but it's very nice to know you're there to support me, truly.

Lastly, I just want to tell you I've been reading this book:(http://www.amazon.com/gp/product/149190142X?psc=1&redirect=true&ref_=oh_aui_detailpage_o09_s01)

And I think by the end it'll have improved my Python abilities quite a lot.

Best, Paul

josuebrunel commented 8 years ago

Hello @unpairestgood, Thanks for the feedback. I really hoped it would work :disappointed: . I have commented your commit