-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.0.0 version of client
- Loading branch information
Showing
55 changed files
with
5,012 additions
and
1,361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
# command to install dependencies | ||
install: "pip install -r requirements.txt" | ||
# command to run tests | ||
- "3.6" | ||
- "3.6-dev" | ||
- "3.7-dev" | ||
install: | ||
- pip install -r requirements.txt | ||
script: | ||
- nosetests --with-coverage # Add me to run nose with coverage | ||
- pip install -e . | ||
- pytest --cov=./ | ||
after_success: | ||
- coveralls | ||
- codecov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Jae Bradley | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import requests | ||
|
||
from draft_kings import urls | ||
from draft_kings.data import Sport | ||
from draft_kings.response_translators import translate_players, translate_contests, translate_countries, \ | ||
translate_draft_group, translate_regions, translate_draftables | ||
|
||
""" | ||
The API takes a sport query parameter that's different than then sports API endpoint | ||
""" | ||
SPORT_TO_CONTESTS_QUERY_PARAMETER = { | ||
Sport.NFL: "NFL", | ||
Sport.NHL: "NHL", | ||
Sport.NBA: "NBA", | ||
Sport.CFL: "CFL", | ||
Sport.COLLEGE_FOOTBALL: "CFB", | ||
Sport.MIXED_MARTIAL_ARTS: "MMA", | ||
Sport.NASCAR: "NAS", | ||
Sport.SOCCER: "SOC", | ||
Sport.EUROLEAGUE_BASKETBALL: "EL", | ||
Sport.MLB: "MLB", | ||
Sport.TENNIS: "TEN", | ||
Sport.LEAGUE_OF_LEGENDS: "LOL", | ||
Sport.GOLF: "GOLF", | ||
Sport.COLLEGE_BASKETBALL: "CBB" | ||
} | ||
|
||
|
||
def contests(sport): | ||
response = requests.get(url=urls.CONTESTS_URL, | ||
params={'sport': SPORT_TO_CONTESTS_QUERY_PARAMETER[sport]}) | ||
|
||
response.raise_for_status() | ||
|
||
return translate_contests(response=response.json()) | ||
|
||
|
||
def available_players(draft_group_id): | ||
response = requests.get(url=urls.AVAILABLE_PLAYERS_URL, | ||
params={'draftGroupId': draft_group_id}) | ||
|
||
response.raise_for_status() | ||
|
||
return translate_players(response=response.json()) | ||
|
||
|
||
def draft_group_details(draft_group_id): | ||
response = requests.get(url=urls.draft_group_url(draft_group_id), | ||
params={'format': 'json'}) | ||
|
||
response.raise_for_status() | ||
|
||
return translate_draft_group(response.json()) | ||
|
||
|
||
def countries(): | ||
response = requests.get(url=urls.COUNTRIES_URL, | ||
params={'format': 'json'}) | ||
|
||
response.raise_for_status() | ||
|
||
return translate_countries(response.json()) | ||
|
||
|
||
def regions(country_code): | ||
response = requests.get(url=urls.regions_url(country_code), | ||
params={'format': 'json'}) | ||
|
||
response.raise_for_status() | ||
|
||
return translate_regions(response.json()) | ||
|
||
|
||
def draftables(draft_group_id): | ||
response = requests.get(url=urls.draftables_url(draft_group_id), | ||
params={'format': 'json'}) | ||
|
||
response.raise_for_status() | ||
|
||
return translate_draftables(response.json()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from enum import Enum | ||
|
||
|
||
class Sport(Enum): | ||
NFL = "NFL" | ||
NHL = "NHL" | ||
NBA = "NBA" | ||
NASCAR = "NASCAR" | ||
SOCCER = "SOCCER" | ||
GOLF = "GOLF" | ||
CFL = "CFL" | ||
COLLEGE_FOOTBALL = "COLLEGE FOOTBALL" | ||
COLLEGE_BASKETBALL = "COLLEGE BASKETBALL" | ||
MIXED_MARTIAL_ARTS = "MIXED MARTIAL ARTS" | ||
EUROLEAGUE_BASKETBALL = "EUROLEAGUE BASKETBALL" | ||
MLB = "MLB" | ||
TENNIS = "TENNIS" | ||
LEAGUE_OF_LEGENDS = "LEAGUE OF LEGENDS" | ||
ARENA_FOOTBALL_LEAGUE = "ARENA FOOTBALL LEAGUE" | ||
|
||
""" | ||
https://api.draftkings.com/sites/US-DK/sports/v1/sports?format=json | ||
""" | ||
SPORT_ID_TO_SPORT = { | ||
1: Sport.NFL, | ||
2: Sport.MLB, | ||
3: Sport.NHL, | ||
4: Sport.NBA, | ||
6: Sport.COLLEGE_BASKETBALL, | ||
5: Sport.COLLEGE_FOOTBALL, | ||
9: Sport.MIXED_MARTIAL_ARTS, | ||
10: Sport.NASCAR, | ||
11: Sport.LEAGUE_OF_LEGENDS, | ||
12: Sport.SOCCER, | ||
13: Sport.GOLF, | ||
14: Sport.CFL, | ||
15: Sport.EUROLEAGUE_BASKETBALL, | ||
16: Sport.TENNIS, | ||
17: Sport.ARENA_FOOTBALL_LEAGUE, | ||
} |
Oops, something went wrong.