Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Update: General Endpoints #1

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ client = DataGolfClient(api_key="YOUR_API_KEY", verbose=True)
# Player List
players = client.general.player_list()

# Tour Schedule
# Current Season Tour Schedule
# Can use optinal parameter 'tour' to filter by tour: pga, euro, kft, alt, liv
tour_schedule = client.general.tour_schedule()
tour_schedule = client.general.tour_schedule(tour="pga")
tour_schedule = client.general.tour_schedule(tour="liv")
```
16 changes: 14 additions & 2 deletions data_golf/api/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@ def player_list(self, format: str = "json") -> List[dict]:
"""
return self.client.get(resource="/get-player-list", format=format)

def tour_schedule(self, format: str = "json") -> List[dict]:
def tour_schedule(self, tour: str = "all", format: str = "json") -> dict:
"""

:param tour: str optional defaults to 'all', the tour you want the schedule for. values: all, pga, euro, kft, alt, liv
:param format:
:return:
"""
return self.client.get(resource="/get-schedule", format=format)
return self.client.get(resource=f"/get-schedule?tour={tour}", format=format)

def field_updates(self, tour: str = None, format: str = "json") -> List[dict]:
"""
Up-to-the-minute field updates on WDs, Monday Qualifiers, tee times, and fantasy salaries for PGA Tour,
European Tour, and Korn Ferry Tour events. Includes data golf IDs and tour-specific IDs for
each player in the field.
:return:
"""
q = f"?tour={tour}" if tour else ""
return self.client.get(resource=f"/field-updates{q}", format=format)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "data_golf"
version = "0.2.0"
version = "0.2.1"
description = "API Wrapper for Data golf endpoints"
authors = ["Corey Schaf <cschaf@gmail.com>"]
readme = "README.md"
Expand Down
32 changes: 31 additions & 1 deletion tests/api/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,35 @@ def test_tour_schedule(d_m, dg_client):
d_m.assert_called_once()
assert (
d_m.call_args[1]["url"]
== "https://feeds.datagolf.com/get-schedule?key=test_key&file_format=json"
== "https://feeds.datagolf.com/get-schedule?tour=all&key=test_key&file_format=json"
)


@mock.patch("httpx.Client.get")
def test_tour_schedule_for_tour(d_m, dg_client):
dg_client.general.tour_schedule(tour="kft")
d_m.assert_called_once()
assert (
d_m.call_args[1]["url"]
== "https://feeds.datagolf.com/get-schedule?tour=kft&key=test_key&file_format=json"
)


@mock.patch("httpx.Client.get")
def test_field_updates(d_m, dg_client):
dg_client.general.field_updates()
d_m.assert_called_once()
assert (
d_m.call_args[1]["url"]
== "https://feeds.datagolf.com/field-updates?key=test_key&file_format=json"
)


@mock.patch("httpx.Client.get")
def test_field_updates_with_tour_euro(d_m, dg_client):
dg_client.general.field_updates(tour="euro")
d_m.assert_called_once()
assert (
d_m.call_args[1]["url"]
== "https://feeds.datagolf.com/field-updates?tour=euro&key=test_key&file_format=json"
)
Loading