Skip to content

Commit

Permalink
Feat: Add admin class & list applications admin function (#54)
Browse files Browse the repository at this point in the history
* Add admin class & list applications admin function

* Update admin.py
  • Loading branch information
Demigodrick authored Jul 15, 2023
1 parent 8304e8d commit e8d28a3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pythorhead/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from typing import Any, List, Literal, Optional
from pythorhead.requestor import Request, Requestor

class Admin:
def __init__(self, _requestor: Requestor):
self._requestor = _requestor

def list_applications(
self,
limit: Optional[int] = None,
page: Optional[int] = None,
unread_only: Optional[str] = None,
) -> Optional[dict]:
"""
Pull applications from site. Note user must be admin.
Args:
limit (Optional[int], optional): Defaults to None.
page (Optional[int], optional): Defaults to None.
undread_only (Optional[str], optional): Must be "true" or "false". Defaults to false
Returns:
dict: list applications
"""
params: dict[str, Any] = {key: value for key, value in locals().items() if value is not None and key != "self"}
return self._requestor.api(Request.GET, "/admin/registration_application/list", params=params)
2 changes: 2 additions & 0 deletions pythorhead/lemmy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pythorhead.site import Site
from pythorhead.types import FeatureType, ListingType, SortType
from pythorhead.user import User
from pythorhead.admin import Admin


class Lemmy:
Expand All @@ -28,6 +29,7 @@ def __init__(self, api_base_url: str) -> None:
self.private_message = PrivateMessage(self._requestor)
self.image = Image(self._requestor)
self.mention = Mention(self._requestor)
self.admin = Admin(self._requestor)

@property
def nodeinfo(self):
Expand Down

0 comments on commit e8d28a3

Please sign in to comment.