Skip to content

Commit 8b5406f

Browse files
authored
Feature Update: General Endpoints (#1)
Fixes tour-schedule to allow for parameter 'tour'. Adds Field Updates endpoint
1 parent 758e955 commit 8b5406f

4 files changed

Lines changed: 50 additions & 5 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ client = DataGolfClient(api_key="YOUR_API_KEY", verbose=True)
4040
# Player List
4141
players = client.general.player_list()
4242

43-
# Tour Schedule
43+
# Current Season Tour Schedule
44+
# Can use optinal parameter 'tour' to filter by tour: pga, euro, kft, alt, liv
4445
tour_schedule = client.general.tour_schedule()
46+
tour_schedule = client.general.tour_schedule(tour="pga")
47+
tour_schedule = client.general.tour_schedule(tour="liv")
4548
```

data_golf/api/general.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,21 @@ def player_list(self, format: str = "json") -> List[dict]:
1212
"""
1313
return self.client.get(resource="/get-player-list", format=format)
1414

15-
def tour_schedule(self, format: str = "json") -> List[dict]:
15+
def tour_schedule(self, tour: str = "all", format: str = "json") -> dict:
1616
"""
1717
18+
:param tour: str optional defaults to 'all', the tour you want the schedule for. values: all, pga, euro, kft, alt, liv
19+
:param format:
1820
:return:
1921
"""
20-
return self.client.get(resource="/get-schedule", format=format)
22+
return self.client.get(resource=f"/get-schedule?tour={tour}", format=format)
23+
24+
def field_updates(self, tour: str = None, format: str = "json") -> List[dict]:
25+
"""
26+
Up-to-the-minute field updates on WDs, Monday Qualifiers, tee times, and fantasy salaries for PGA Tour,
27+
European Tour, and Korn Ferry Tour events. Includes data golf IDs and tour-specific IDs for
28+
each player in the field.
29+
:return:
30+
"""
31+
q = f"?tour={tour}" if tour else ""
32+
return self.client.get(resource=f"/field-updates{q}", format=format)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "data_golf"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
description = "API Wrapper for Data golf endpoints"
55
authors = ["Corey Schaf <cschaf@gmail.com>"]
66
readme = "README.md"

tests/api/test_general.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,35 @@ def test_tour_schedule(d_m, dg_client):
4242
d_m.assert_called_once()
4343
assert (
4444
d_m.call_args[1]["url"]
45-
== "https://feeds.datagolf.com/get-schedule?key=test_key&file_format=json"
45+
== "https://feeds.datagolf.com/get-schedule?tour=all&key=test_key&file_format=json"
46+
)
47+
48+
49+
@mock.patch("httpx.Client.get")
50+
def test_tour_schedule_for_tour(d_m, dg_client):
51+
dg_client.general.tour_schedule(tour="kft")
52+
d_m.assert_called_once()
53+
assert (
54+
d_m.call_args[1]["url"]
55+
== "https://feeds.datagolf.com/get-schedule?tour=kft&key=test_key&file_format=json"
56+
)
57+
58+
59+
@mock.patch("httpx.Client.get")
60+
def test_field_updates(d_m, dg_client):
61+
dg_client.general.field_updates()
62+
d_m.assert_called_once()
63+
assert (
64+
d_m.call_args[1]["url"]
65+
== "https://feeds.datagolf.com/field-updates?key=test_key&file_format=json"
66+
)
67+
68+
69+
@mock.patch("httpx.Client.get")
70+
def test_field_updates_with_tour_euro(d_m, dg_client):
71+
dg_client.general.field_updates(tour="euro")
72+
d_m.assert_called_once()
73+
assert (
74+
d_m.call_args[1]["url"]
75+
== "https://feeds.datagolf.com/field-updates?tour=euro&key=test_key&file_format=json"
4676
)

0 commit comments

Comments
 (0)