feat: added get_invites method

This commit is contained in:
Seaswimmer 2023-12-22 13:51:15 -05:00
parent 01f97d40b6
commit 63258d6dea
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

@ -224,6 +224,35 @@ class ZiplineApi:
if result.status_code == 401:
raise Forbidden(result.message)
def get_invites(self) -> list[Invite]:
"""Get a list of invites
/// admonition | Requires Authentication
type: warning
///
Raises:
Forbidden: The user is not authenticated
FeatureDisabledError: Invites are disabled on the Zipline instance
PyZiplineError: Raised if the API changes, causing a breaking change in this method
Returns:
Invite: List of invites
"""
result = self._rest_adapter.get(endpoint="user/invites")
if result.status_code == 200:
invites = []
for invite in result.data:
i = Invite(**invite)
invites.append(i)
return invites
if result.status_code == 401:
raise Forbidden(result.message)
if result.message == 'invites are disabled':
raise FeatureDisabledError(result.message)
raise PyZiplineError(f"{result.status_code}: {result.message}\n{result.data}")
def get_self(self) -> User:
"""Get the currently authenticated user