feat: added get_invites method
This commit is contained in:
parent
01f97d40b6
commit
63258d6dea
1 changed files with 29 additions and 0 deletions
|
@ -224,6 +224,35 @@ class ZiplineApi:
|
||||||
if result.status_code == 401:
|
if result.status_code == 401:
|
||||||
raise Forbidden(result.message)
|
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:
|
def get_self(self) -> User:
|
||||||
"""Get the currently authenticated user
|
"""Get the currently authenticated user
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue