diff --git a/README.md b/README.md index ed4ad0b..c565bd8 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/spond/spond.py b/spond/spond.py index 5910dd4..d7c75c5 100644 --- a/spond/spond.py +++ b/spond/spond.py @@ -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