Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ Get Excel attendance report for a single event, available via the web client.
### change_response()
Change a member's response for an event (e.g. accept/decline)

### update_member()
Change details about a member. First use get_groups() to get all the member details,
find the member you what to change and make the changes, then use this method to
update in Spond.

### get_members_xlsx()
Get the Excel member export that is downloadable from the Spond web page.

## Example scripts

The following scripts are included as examples. Some of the scripts might require additional packages to be installed (csv, ical etc).
Expand Down
47 changes: 47 additions & 0 deletions spond/spond.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,3 +465,50 @@ async def _get_entity(self, entity_type: str, uid: str) -> JSONDict:
return entity
errmsg = f"No {entity_type} with id='{uid}'."
raise KeyError(errmsg)

@_SpondBase.require_authentication
async def update_member(self, group_id: str, member: dict) -> JSONDict:
"""
Update member details.
Subject to authenticated user's access permissions.

Use by first getting the member data with either the get_groups()
or get_personb(), modify some value and write back with this
method.

Parameters
----------
group_id : str
Group ID of the member
member : dict
Member data to update

Returns
-------
dict
The response from the Spond server which is the Updated memberi
data on success or an error message on failure.
"""

url = f"{self.api_url}group/{group_id}/member"
data = member
r = await self.clientsession.post(url, json=data, headers=self.auth_headers)
return await r.json()

@_SpondBase.require_authentication
async def get_members_xlsx(self, group_id: str) -> bytes:
"""Get the Excel member export that is downloadable from the Spond web page.

Parameters
----------
group_id : str
Group ID of the members

Returns:
-------
bytes: XLSX binary data
"""
url = f"{self.api_url}group/{group_id}/exportMembers"
async with self.clientsession.get(url, headers=self.auth_headers) as r:
output_data = await r.read()
return output_data