whatadewitt / yahoo-fantasy-sports-api

NodeJS wrapper for the Yahoo! Fantasy Sports API
https://yahoo-fantasy-node-docs.vercel.app/
MIT License
206 stars 54 forks source link

Roster player mappings missing #3

Closed ryus08 closed 8 years ago

ryus08 commented 8 years ago

First, love the wrapper. Real sleek. Way to hide that nasty model they expose.

When I got the roster players resource, I noticed that it was missing a few things I expected, namely:

Looks like when the library flattens the sub-objects under player, it misses those first three fields. Additionally, it only takes the first property on each sub-object (so something like image_url is missed).

So, player looks like this out of yahoo's endpoint:

"player": [
  [{
      "player_key": "357.p.8578"
    }, {
      "player_id": "8578"
    }, {
      "name": {
        "full": "Buster Posey",
        "first": "Buster",
        "last": "Posey",
        "ascii_first": "Buster",
        "ascii_last": "Posey"
      }
    },
  ...
       {
      "headshot": {
        "url": "http://l.yimg.com/iu/api/res/1.2/gfBnDzOC0vzY92FGzMlqrA--/YXBwaWQ9c2hhcmVkO2NoPTIzMzY7Y3I9MTtjdz0xNzkwO2R4PTg1NztkeT0wO2ZpPXVsY3JvcDtoPTYwO3E9MTAwO3c9NDY-/https://s.yimg.com/xe/i/us/sp/v/mlb_cutout/players_l/20160401/8578.png",
        "size": "small"
      },
      "image_url": "http://l.yimg.com/iu/api/res/1.2/gfBnDzOC0vzY92FGzMlqrA--/YXBwaWQ9c2hhcmVkO2NoPTIzMzY7Y3I9MTtjdz0xNzkwO2R4PTg1NztkeT0wO2ZpPXVsY3JvcDtoPTYwO3E9MTAwO3c9NDY-/https://s.yimg.com/xe/i/us/sp/v/mlb_cutout/players_l/20160401/8578.png"
    },
  ...
       {
      "has_player_notes": 1
    },
    []
  ], {
    "selected_position": [{
      "coverage_type": "date",
      "date": "2016-04-10"
    }, {
      "position": "C"
    }]
  }, {
    "starting_status": [{
      "coverage_type": "date",
      "date": "2016-04-10"
    }, {
      "is_starting": 1
    }]
  }, {
    "is_editable": 1
  }
]

So the player object is an array, and only the objects in its first index are flattened into the result, missing selected_position, starting_status, and is_editable. And notice that image_url is the second property in a flattenned object, so it is missed.

I forked your repo and I believe have a fix for the first issue, second issue, and better mapping for selected_position, starting_status, and is_editable.

Any interest in me filing a PR to your repo?

whatadewitt commented 8 years ago

Hey @ryus08,

That would be great! I'm pretty slammed at work this week, but I would love a PR to fix these issues! I'll try to get to it in the free time I can find!

Thanks!!

--d

ryus08 commented 8 years ago

Cool, I'll file it tomorrow.

One last thing, I'd gladly add a test, but I don't see them anywhere. I do see some Downloading your npm package.

If you point me to them, I'll add one.

No rush.

On Apr 12, 2016, at 7:34 AM, Luke DeWitt notifications@github.com wrote:

Hey @ryus08,

That would be great! I'm pretty slammed at work this week, but I would love a PR to fix these issues! I'll try to get to it in the free time I can find!

Thanks!!

--d

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

whatadewitt commented 8 years ago

I'm actually working on these in the little free time that I have right now. For now, don't worry about it (awful to say, I know)

ryus08 commented 8 years ago

Ha, no judgement. If you want a hand, let me know.

On Apr 12, 2016, at 1:19 PM, Luke DeWitt notifications@github.com wrote:

I'm actually working on these in the little free time that I have right now. For now, don't worry about it (awful to say, I know)

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub