from dishka import BaseScope, Provider, Scope, provide

from template_project.adapters.oauth.yandex import YandexOAuthClient as YandexOAuthClientImpl
from template_project.application.common.oauth.yandex import OAuthClient as YandexOAuthClient
from template_project.web_api.configuration import YandexOAuthConfiguration


class OAuthClientProvider(Provider):
    scope: BaseScope | None = Scope.REQUEST

    @provide(scope=Scope.REQUEST)
    async def yandex_oauth_client(self, configuration: YandexOAuthConfiguration) -> YandexOAuthClient:
        return YandexOAuthClientImpl(
            client_id=configuration.client_id,
            client_secret=configuration.client_secret,
        )
