planfix client as dependency

This commit is contained in:
Robert 2024-02-28 18:33:25 +07:00
parent 20e8558ceb
commit 674c22afad
No known key found for this signature in database
GPG Key ID: F631C7FD957D5F22
2 changed files with 11 additions and 3 deletions

View File

@ -1,11 +1,14 @@
from .planfix_client import PlanfixClientDependency
from chain_service.services.progress_action.factory import ProgressActionServiceFactory
from fastapi import Depends
from typing import Annotated
def get_progress_action_service_factory() -> ProgressActionServiceFactory:
return ProgressActionServiceFactory()
def get_progress_action_service_factory(
planfix_client: PlanfixClientDependency,
) -> ProgressActionServiceFactory:
return ProgressActionServiceFactory(planfix_client=planfix_client)
ProgressActionServiceFactoryDependency = Annotated[

View File

@ -4,9 +4,14 @@ from .base import BaseProgressActionService
from .wait_progress_action import WaitProgressActionService
from .comment_progress_action import CommentProgressActionService
from planfix_client import PlanfixClient
class ProgressActionServiceFactory:
def __init__(self, planfix_client: PlanfixClient):
self.planfix_client = planfix_client
def __call__(
self, progress_action: BaseProgressAction
) -> BaseProgressActionService:
@ -17,4 +22,4 @@ class ProgressActionServiceFactory:
return WaitProgressActionService()
case "comment":
return CommentProgressActionService()
return CommentProgressActionService(planfix_client=self.planfix_client)