Skip to content

Commit

Permalink
Merge pull request #81 from elliot-100/80-functions-that-look-up-enti…
Browse files Browse the repository at this point in the history
…ties-by-id-should-raise-errors-if-nothing-is-matched

80 functions that look up entities by id should raise errors if nothing is matched
  • Loading branch information
elliot-100 authored Aug 3, 2023
2 parents 5db8fee + 241c213 commit dd30bac
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions spond/spond.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from datetime import datetime
from typing import List, Optional


import aiohttp


Expand Down Expand Up @@ -49,7 +48,7 @@ async def get_groups(self):
self.groups = await r.json()
return self.groups

async def get_group(self, uid):
async def get_group(self, uid) -> dict:
"""
Get a group by unique ID.
Subject to authenticated user's access.
Expand All @@ -61,8 +60,7 @@ async def get_group(self, uid):
Returns
-------
dict
Details of the group.
Details of the group.
"""
if not self.cookie:
await self.login()
Expand All @@ -71,8 +69,9 @@ async def get_group(self, uid):
for group in self.groups:
if group["id"] == uid:
return group
raise IndexError

async def get_person(self, user):
async def get_person(self, user) -> dict:
"""
Get a member or guardian by matching various identifiers.
Subject to authenticated user's access.
Expand All @@ -85,8 +84,7 @@ async def get_person(self, user):
Returns
-------
dict
Member or guardian's details.
Member or guardian's details.
"""
if not self.cookie:
await self.login()
Expand Down Expand Up @@ -114,6 +112,7 @@ async def get_person(self, user):
)
):
return guardian
raise IndexError

async def get_messages(self):
if not self.cookie:
Expand Down Expand Up @@ -267,7 +266,7 @@ async def get_events(
self.events = await r.json()
return self.events

async def get_event(self, uid):
async def get_event(self, uid) -> dict:
"""
Get an event by unique ID.
Subject to authenticated user's access.
Expand All @@ -279,8 +278,7 @@ async def get_event(self, uid):
Returns
-------
dict
Details of the event.
Details of the event.
"""
if not self.cookie:
await self.login()
Expand All @@ -289,6 +287,7 @@ async def get_event(self, uid):
for event in self.events:
if event["id"] == uid:
return event
raise IndexError

async def update_event(self, uid, updates: dict):
"""
Expand Down

0 comments on commit dd30bac

Please sign in to comment.