Skip to content

Commit

Permalink
Add endpoints to get a bit more information about groups
Browse files Browse the repository at this point in the history
  • Loading branch information
brodokk committed Oct 16, 2024
1 parent db850b1 commit 51913c1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
6 changes: 6 additions & 0 deletions resonitepy/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,12 @@ class ResoniteGroup:
name: str
isMigrated: bool

@dataclass
class ResoniteGroupMember:
id: str
isMigrated: bool
ownerId: str

@dataclass
class ResoniteSessionUser:
""" Data class representing a Resonite session user.
Expand Down
27 changes: 26 additions & 1 deletion resonitepy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
Platform,
ResoniteUserMembership,
ResoniteGroup,
ResoniteGroupMember,
)
from .utils import getOwnerType

Expand Down Expand Up @@ -450,11 +451,35 @@ def getGroup(self, groupId: str) -> ResoniteGroup:
groupId (str): The group name starting with G-
Returns:
ResoniteGroup: An object with the group information
ResoniteGroup: An object with the group information.
"""
response = self.request('get', f'/groups/{groupId}')
return to_class(ResoniteGroup, response, DACITE_CONFIG)

def getGroupMembers(self, groupId: str) -> List[ResoniteGroupMember]:
""" Retrieve members from a group.
Args:
groupId (str): The group name starting with G-
Returns:
List[ResoniteGroupMember]: A list with the group members.
"""
response = self.request('get', f'/groups/{groupId}/members')
return [to_class(ResoniteGroupMember, group_member, DACITE_CONFIG) for group_member in response]

def getGroupMember(self, groupId: str, userId: str) -> ResoniteGroupMember:
""" Retrieve a member from a group.
Args:
groupId (str): The group name starting with G-
userId (str): The username starting with U-
Returns:
ResoniteGroupMember: An object with the member information.
"""
response = self.request('get', f'/groups/{groupId}/members/{userId}')
return to_class(ResoniteGroupMember, response, DACITE_CONFIG)

def getSessions(
self,
compatibilityHash: str = None,
Expand Down
2 changes: 2 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
owner_path_user = client.getOwnerPath(client.userId)
owner_path_group = client.getOwnerPath(user_groups[0].id)
group = client.getGroup(user_groups[0].id)
group_members = client.getGroupMembers(user_groups[0].id)
group_member = client.getGroupMember(user_groups[0].id, group_members[0].id)

# TODO: VERY IMPORTANT I NEED TO CONTINUE THIS AND PATCH MORE STUFF IF NEEDED BEFORE DOING A RELEASE!
platform = client.platform()

0 comments on commit 51913c1

Please sign in to comment.