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

Docstrings for most methods #17

Merged
merged 1 commit into from
Aug 15, 2022
Merged
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
85 changes: 85 additions & 0 deletions spond/spond.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ async def login(self):
self.auth = result['auth']

async def getGroups(self):
"""
Get all groups.
Subject to authenticated user's access.

Returns
-------
list of dict
Groups; each group is a dict.
"""
if not self.cookie:
await self.login()
url = self.apiurl + "groups/"
Expand All @@ -43,6 +52,20 @@ async def getGroups(self):
return self.groups

async def getGroup(self, uid):
"""
Get a group by unique ID.
Subject to authenticated user's access.

Parameters
----------
uid : str
UID of the group.

Returns
-------
dict
Details of the group.
"""
if not self.cookie:
await self.login()
if not self.groups:
Expand All @@ -52,6 +75,21 @@ async def getGroup(self, uid):
return group

async def getPerson(self, user):
"""
Get a member or guardian by matching various identifiers.
Subject to authenticated user's access.

Parameters
----------
user : str
Identifier to match against member/guardian's id, email, full name, or
profile id.

Returns
-------
dict
Member or guardian's details.
"""
if not self.cookie:
await self.login()
if not self.groups:
Expand Down Expand Up @@ -85,6 +123,22 @@ async def sendMessage(self, recipient, text):
return await r.json()

async def getEvents(self, from_date = None):
"""
Get up to 100 events up to present.
Subject to authenticated user's access.
Excludes cancelled events.

Parameters
----------
from_date : datetime, optional
Only return events which finish after this value.
If omitted, the last 14 days.

Returns
-------
list of dict
Events; each event is a dict.
"""
if not self.cookie:
await self.login()
if not from_date:
Expand All @@ -95,6 +149,23 @@ async def getEvents(self, from_date = None):
return self.events

async def getEventsBetween(self, from_date, to_date):
"""
Get up to 100 events between two datetimes.
Subject to authenticated user's access.
Excludes cancelled events.

Parameters
----------
from_date : datetime
Only return events which finish after this value.
to_date : datetime
Only return events which finish before this value.

Returns
-------
list of dict
Events; each event is a dict.
"""
if not self.cookie:
await self.login()
url = self.apiurl + "sponds/?max=100&minEndTimestamp={}&maxEndTimestamp={}&order=asc&scheduled=true".format(from_date.strftime("%Y-%m-%dT00:00:00.000Z"), to_date.strftime("%Y-%m-%dT00:00:00.000Z"))
Expand All @@ -103,6 +174,20 @@ async def getEventsBetween(self, from_date, to_date):
return self.events

async def getEvent(self, uid):
"""
Get an event by unique ID.
Subject to authenticated user's access.

Parameters
----------
uid : str
UID of the event.

Returns
-------
dict
Details of the event.
"""
if not self.cookie:
await self.login()
if not self.events:
Expand Down