import functools

from snek.service.channel import ChannelService
from snek.service.channel_member import ChannelMemberService
from snek.service.channel_message import ChannelMessageService
from snek.service.chat import ChatService
from snek.service.notification import NotificationService
from snek.service.socket import SocketService
from snek.service.user import UserService
from snek.service.util import UtilService
from snek.service.drive import DriveService
from snek.service.drive_item import DriveItemService
from snek.system.object import Object


@functools.cache
def get_services(app):
    return Object(
        **{
            "user": UserService(app=app),
            "channel_member": ChannelMemberService(app=app),
            "channel": ChannelService(app=app),
            "channel_message": ChannelMessageService(app=app),
            "chat": ChatService(app=app),
            "socket": SocketService(app=app),
            "notification": NotificationService(app=app),
            "util": UtilService(app=app),
            "drive": DriveService(app=app),
            "drive_item": DriveItemService(app=app)
        }
    )


def get_service(name, app=None):
    return get_services(app=app)[name]
