Skip to content

Commit

Permalink
update queries and custom classes to return flattened objects without…
Browse files Browse the repository at this point in the history
… unnecessary single-key dict access, fix type hints to support flattened return values, and update docs, tests, and quickstart
  • Loading branch information
uberfastman committed Sep 14, 2023
1 parent fda0b16 commit 83a3f5f
Show file tree
Hide file tree
Showing 6 changed files with 923 additions and 906 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ In order to use YFPY with private fantasy leagues, you must set up an app on you

* See the documentation on the [`yfpy.query.YahooFantasySportsQuery`](https://yfpy.uberfastman.com/_autosummary/yfpy.query.YahooFantasySportsQuery.html#yfpy.query.YahooFantasySportsQuery) class for example usage of all available queries.
* See [`quickstart/quickstart.py`](https://github.com/uberfastman/yfpy/blob/main/quickstart/quickstart.py) for example usage output.
* Uncomment/comment out whichever configuration values with which you wish to experiment.
* Uncomment/comment out whichever configuration values in their respective functions with which you wish to experiment.
* Uncomment/comment out whichever query lines in the `RUN QUERIES` section you wish to run.
* Uncomment/comment out whichever query lines in the `CHECK FOR MISSING DATA FIELDS` section you wish to check for any new/missing data fields returned by the Yahoo Sports Fantasy Football API.

Expand All @@ -130,6 +130,7 @@ YFPY has a collection of fully functional code snippets that can be run using [p
* Before running any integration tests, make a copy of [`auth/EXAMPLE.env`](https://github.com/uberfastman/yfpy/blob/main/auth/EXAMPLE.env) in the [`auth/`](https://github.com/uberfastman/yfpy/blob/main/auth/) directory and rename it to `.env`.
* Copy your Yahoo `Client ID` and `Client Secret` into the environment variables in `.env` so that pytest can use them when hitting the Yahoo Fantasy Sports API.
* If this is the first time running pytest with your Yahoo API credentials, you ***MUST*** allow interactive prompts within pytest by using the `-s` flag.
* The fixture values in [`test/integration/conftest.py`](https://github.com/uberfastman/yfpy/blob/main/test/integration/conftest.py) are defined in [`quickstart/quickstart.py`](https://github.com/uberfastman/yfpy/blob/main/quickstart/quickstart.py), and can be changed for testing by uncommenting/commenting out the values inside each respective function.

#### Running

Expand Down
223 changes: 176 additions & 47 deletions quickstart/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,74 +41,203 @@
# VARIABLE SETUP # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #


# set desired season year
season = 2021
# season = 2012
def get_season():
# season = 2012
# season = 2013
# season = 2014
# season = 2015
# season = 2016
# season = 2017
# season = 2018
# season = 2019
# season = 2020
# season = 2021
# season = 2022
season = 2023
return season


season = get_season()


# set desired week
chosen_week = 1
def get_chosen_week():
chosen_week = 1
return chosen_week


chosen_week = get_chosen_week()


# set desired date
chosen_date = "2013-04-15" # NHL - 2013 (for 2012)
# chosen_date = "2013-04-16" # NHL - 2013
# chosen_date = "2021-10-25" # NHL - 2021
# chosen_date = "2021-04-01" # MLB - 2021
# chosen_date = "2022-04-10" # MLB - 2022
def get_chosen_date():
# HOCKEY
# chosen_date = "2013-04-15" # NHL - 2013 (for 2012 season)
chosen_date = "2021-10-25" # NHL - 2021

# BASEBALL
# chosen_date = "2021-04-01" # MLB - 2021
# chosen_date = "2022-04-10" # MLB - 2022

return chosen_date


chosen_date = get_chosen_date()


# set desired Yahoo Fantasy Sports game code
game_code = "nfl" # NFL
# game_code = "nhl" # NHL
# game_code = "mlb" # MLB
def get_game_code():
# FOOTBALL
game_code = "nfl" # NFL

# HOCKEY
# game_code = "nhl" # NHL

# BASEBALL
# game_code = "mlb" # MLB

return game_code


game_code = get_game_code()


# set desired Yahoo Fantasy Sports game ID (see the get_all_yahoo_fantasy_game_keys query to retrieve values)
# game_id = 331 # NFL - 2014
# game_id = 348 # NFL - 2015 (testing for league with divisions)
# game_id = 390 # NFL - 2019
# game_id = 399 # NFL - 2020
game_id = 406 # NFL - 2021
# game_id = 303 # NHL - 2012
# game_id = 411 # NHL - 2021
# game_id = 404 # MLB - 2021
# game_id = 412 # MLB - 2022
def get_game_id():
# FOOTBALL
# game_id = 331 # NFL - 2014
# game_id = 348 # NFL - 2015 (divisions)
# game_id = 359 # NFL - 2016
# game_id = 371 # NFL - 2017
# game_id = 380 # NFL - 2018
# game_id = 390 # NFL - 2019
# game_id = 399 # NFL - 2020
# game_id = 406 # NFL - 2021
# game_id = 414 # NFL - 2022 (divisions)
game_id = 423 # NFL - 2023

# HOCKEY
# game_id = 303 # NHL - 2012
# game_id = 411 # NHL - 2021

# BASEBALL
# game_id = 404 # MLB - 2021
# game_id = 412 # MLB - 2022

return game_id


game_id = get_game_id()


# set desired Yahoo Fantasy Sports game key (see the get_all_yahoo_fantasy_game_keys query to retrieve values)
# game_key = "331" # NFL - 2014
# game_key = "348" # NFL - 2015 (testing for league with divisions)
# game_key = "390" # NFL - 2019
# game_key = "399" # NFL - 2020
game_key = "406" # NFL - 2021
# game_key = "303" # NHL - 2012
# game_key = "411" # NHL - 2021
# game_key = "404" # MLB - 2021
# game_key = "412" # MLB - 2022
def get_game_key():
# FOOTBALL
# game_key = "331" # NFL - 2014
# game_key = "348" # NFL - 2015 (divisions)
# game_key = "359" # NFL - 2016
# game_key = "371" # NFL - 2017
# game_key = "380" # NFL - 2018
# game_key = "390" # NFL - 2019
# game_key = "399" # NFL - 2020
# game_key = "406" # NFL - 2021
# game_key = "414" # NFL - 2022 (divisions)
game_key = "423" # NFL - 2023

# HOCKEY
# game_key = "303" # NHL - 2012
# game_key = "411" # NHL - 2021

# BASEBALL
# game_key = "404" # MLB - 2021
# game_key = "412" # MLB - 2022

return game_key


game_key = get_game_key()


# set desired league ID (see README.md for finding value)
# league_id = "907359" # NFL - 2015 (testing for league with divisions)
# league_id = "79230" # NFL - 2019
# league_id = "655434" # NFL - 2020
league_id = "413954" # NFL - 2021
# league_id = "69624" # NHL - 2012
# league_id = "101592" # NHL - 2021
# league_id = "40134" # MLB - 2021
def get_league_id():
# FOOTBALL
# league_id = "907359" # NFL - 2015 (divisions)
# league_id = "79230" # NFL - 2019
# league_id = "655434" # NFL - 2020
# league_id = "413954" # NFL - 2021
# league_id = "791337" # NFL - 2022 (divisions)
league_id = "321958" # NFL - 2023

# HOCKEY
# league_id = "69624" # NHL - 2012
# league_id = "101592" # NHL - 2021

# BASEBALL
# league_id = "40134" # MLB - 2021

return league_id


league_id = get_league_id()


# set desired team ID within desired league
team_id = 1 # NFL
# team_id = 2 # NHL (2012)
def get_team_id():
# FOOTBALL
team_id = 1 # NFL

# HOCKEY
# team_id = 2 # NHL (2012)

return team_id


team_id = get_team_id()


# set desired team name within desired league
team_name = "Legion" # NFL
# team_name = "The Bateleurs" # NHL (2012)
def get_team_name():
# FOOTBALL
team_name = "Legion" # NFL

# HOCKEY
# team_name = "The Bateleurs" # NHL (2012)

return team_name


team_name = get_team_name()


# set desired team ID within desired league
player_id = 7200 # NFL: Aaron Rodgers - 2020/2021
# player_id = 4588 # NHL: Braden Holtby - 2012
# player_id = 8205 # NHL: Jeffrey Viel - 2021
# player_id = 3637 # NHL: Alex Ovechkin - 2021
# player_id = 9897 # MLB: Tim Anderson - 2021/2022
def get_player_id():
# FOOTBALL
player_id = 30123 # NFL: Patrick Mahomes - 2020/2021/2023

# HOCKEY
# player_id = 4588 # NHL: Braden Holtby - 2012
# player_id = 8205 # NHL: Jeffrey Viel - 2021
# player_id = 3637 # NHL: Alex Ovechkin - 2021

# BASEBALL
# player_id = 9897 # MLB: Tim Anderson - 2021/2022

return player_id


player_id = get_player_id()


# set the maximum number players you wish the get_league_players query to retrieve
league_player_limit = 101
# league_player_limit = 2610
def get_league_player_limit():
league_player_limit = 101

return league_player_limit


league_player_limit = get_league_player_limit()

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# QUERY SETUP # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Expand Down
Loading

0 comments on commit 83a3f5f

Please sign in to comment.