Skip to content

Commit

Permalink
Merge pull request #178 from dave-hilo/feature/seasons-new-url
Browse files Browse the repository at this point in the history
Update seasons url
  • Loading branch information
ic-dev21 authored Feb 6, 2024
2 parents b1cd4a3 + 9f9c277 commit 3620772
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pyhilo/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ANDROID_CLIENT_HOSTNAME,
ANDROID_CLIENT_POST,
API_AUTOMATION_ENDPOINT,
API_CHALLENGE_ENDPOINT,
API_EVENTS_ENDPOINT,
API_GD_SERVICE_ENDPOINT,
API_HOSTNAME,
Expand Down Expand Up @@ -379,6 +380,7 @@ def _get_url(
gd: bool = False,
drms: bool = False,
events: bool = False,
challenge: bool = False,
) -> str:
"""Generate a path to the requested endpoint.
Expand All @@ -390,6 +392,8 @@ def _get_url(
:type gd: bool, optional
:param drms: Whether or not we should prepend the path with DRMS path, defaults to False
:type drms: bool, optional
:param challenge: Whether or not we should prepend the path with challenge path, defaults to False
:type challenge: bool, optional
:return: Path to the requested endpoint
:rtype: str
"""
Expand All @@ -400,6 +404,8 @@ def _get_url(
base += "/DRMS"
if events:
base = API_EVENTS_ENDPOINT + API_NOTIFICATIONS_ENDPOINT
if challenge:
base = API_CHALLENGE_ENDPOINT
url = base + "/Locations/" + str(location_id)
if endpoint:
url += "/" + str(endpoint)
Expand Down Expand Up @@ -740,7 +746,7 @@ async def get_gd_events(

async def get_seasons(self, location_id: int) -> dict[str, Any]:
"""This will return the rewards and current season total
https://apim.hiloenergie.com/Automation/v1/api/DRMS/Locations/XXXX/Seasons
https://api.hiloenergie.com/challenge/v1/api/Locations/XXXX/Seasons
[
{
"season": 2021,
Expand All @@ -757,7 +763,7 @@ async def get_seasons(self, location_id: int) -> dict[str, Any]:
}
]
"""
url = self._get_url("Seasons", location_id, drms=True)
url = self._get_url("Seasons", location_id, challenge=True)
return cast(dict[str, Any], await self.async_request("get", url))

async def get_gateway(self, location_id: int) -> dict[str, Any]:
Expand Down
1 change: 1 addition & 0 deletions pyhilo/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
API_HOSTNAME: Final = "api.hiloenergie.com"
API_END: Final = "v1/api"
API_AUTOMATION_ENDPOINT: Final = f"/Automation/{API_END}"
API_CHALLENGE_ENDPOINT: Final = f"/challenge/{API_END}"
API_GD_SERVICE_ENDPOINT: Final = f"/GDService/{API_END}"
API_NOTIFICATIONS_ENDPOINT: Final = "/Notifications"
API_EVENTS_ENDPOINT: Final = "/Notifications"
Expand Down

0 comments on commit 3620772

Please sign in to comment.