from typing import Optional from fastapi import Depends from .oauth import OAuthService from .youtube import YoutubeService from .redis import RedisOAuthStorage, RedisYouTubeStorage, get_oauth_storage, get_youtube_storage class GoogleService: '''Google 통합 관리 서비스''' def __init__(self, oauth_storage: RedisOAuthStorage, youtube_storage: RedisYouTubeStorage): self.oauth = OAuthService(oauth_storage) self.youtube = YoutubeService(youtube_storage, oauth_storage) async def login_url(self, return_url: str): '''Google OAuth 로그인 URL 생성''' return await self.oauth.login_url(return_url) async def callback(self, state: str, code: str): '''Google OAuth 콜백 처리''' return await self.oauth.callback(state, code) async def get_token_info(self, temp_token_id: str): '''임시 토큰 ID로 토큰 정보 조회''' return await self.oauth.get_token_by_temp_id(temp_token_id) async def get_all_youtube_channel_info(self, access_token: str, refresh_token: Optional[str] = None): '''YouTube 모든 채널 정보 조회''' return await self.youtube.get_all_channel_info(access_token, refresh_token) # GoogleService 의존성 주입 async def get_google_service( oauth_storage: RedisOAuthStorage = Depends(get_oauth_storage), youtube_storage: RedisYouTubeStorage = Depends(get_youtube_storage) ) -> GoogleService: return GoogleService(oauth_storage, youtube_storage)