Skip to content

Commit

Permalink
Add status endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ianpittwood committed Jan 16, 2024
1 parent a9ca0ec commit 09a082a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api_sports_io_nfl/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class ApiNfl:
ENDPOINTS = {
"status": "/status",
"timezone": "/timezone",
"seasons": "/seasons",
"leagues": "/leagues",
Expand Down Expand Up @@ -110,6 +111,12 @@ def get(self, url, params=None, headers=None):
raise exceptions.ApiError(response=resp)
return resp

def status(self):
"""Call the status endpoint."""
url = urljoin(self.protocol + self.api_host, self.ENDPOINTS["status"])
resp = self.get(url)
return resp.json()["response"]

def timezone(self):
"""Call the timezone endpoint.
Expand Down
9 changes: 9 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ def setUp(self) -> None:
self.api = ApiNfl(api_key)


class TestStatus(TestEndpoints):
def test_status(self):
resp = self.api.status()
self.assertIsInstance(resp, dict)
self.assertIn("account", resp)
self.assertIn("subscription", resp)
self.assertIn("requests", resp)


class TestTimezone(TestEndpoints):
def test_timezone(self):
resp = self.api.timezone()
Expand Down

0 comments on commit 09a082a

Please sign in to comment.