create services
This commit is contained in:
parent
30ed2ef72c
commit
41b22d049e
3 changed files with 50 additions and 0 deletions
0
src/synclean/service/__init__.py
Normal file
0
src/synclean/service/__init__.py
Normal file
50
src/synclean/service/room_service.py
Normal file
50
src/synclean/service/room_service.py
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
from typing import Optional, List
|
||||||
|
|
||||||
|
from synclean.api.rooms import RoomAPI
|
||||||
|
from synclean.models.enums import RoomOrderBy, Direction
|
||||||
|
from synclean.models.pagination import RoomPaginationParams
|
||||||
|
from synclean.models.room import Room
|
||||||
|
|
||||||
|
|
||||||
|
class RoomService:
|
||||||
|
def __init__(self, room_api: RoomAPI):
|
||||||
|
self.room_api = room_api
|
||||||
|
|
||||||
|
def get_room_list(
|
||||||
|
self,
|
||||||
|
limit: int,
|
||||||
|
offset: int,
|
||||||
|
search: Optional[str],
|
||||||
|
order_by: str,
|
||||||
|
direction: str
|
||||||
|
) -> List[Room] | None:
|
||||||
|
order_by_enum = RoomOrderBy(order_by)
|
||||||
|
direction_enum = Direction(direction)
|
||||||
|
|
||||||
|
pagination_params = RoomPaginationParams(limit, offset, order_by_enum, direction_enum, search)
|
||||||
|
|
||||||
|
rooms = self.room_api.get_rooms_list(pagination_params)
|
||||||
|
if rooms:
|
||||||
|
return rooms.rooms
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_room_details(self, room_id: str):
|
||||||
|
room_details = self.room_api.get_room_details(room_id)
|
||||||
|
if room_details:
|
||||||
|
print(f"Room details for room {room_id}:")
|
||||||
|
print(f"Name: {room_details.name}")
|
||||||
|
print(f"ID: {room_details.room_id}")
|
||||||
|
print(f"Avatar: {room_details.avatar}")
|
||||||
|
print(f"Joined Members: {room_details.joined_members} (local: {room_details.joined_local_members})")
|
||||||
|
print(f"Version: {room_details.version}")
|
||||||
|
print(f"Creator: {room_details.creator}")
|
||||||
|
print(f"Encryption: {room_details.encryption}")
|
||||||
|
print(f"Federatable: {room_details.federatable}")
|
||||||
|
print(f"Public: {room_details.public}")
|
||||||
|
print(f"Join Rules: {room_details.join_rules}")
|
||||||
|
print(f"Guest Access: {room_details.guest_access}")
|
||||||
|
print(f"History Visibility: {room_details.history_visibility}")
|
||||||
|
print(f"State Events: {room_details.state_events}")
|
||||||
|
print(f"Room Type: {room_details.room_type}")
|
||||||
|
return room_details
|
0
src/synclean/service/user_service.py
Normal file
0
src/synclean/service/user_service.py
Normal file
Loading…
Add table
Add a link
Reference in a new issue