from .clients.atlas_client import AtlasClient from .clients.decibel_client import DecibelClient from .clients.client_factory import ApiClientFactory from .schemas import Event, DetailType from .utils import sync class AtlasApiService: atlas_client: AtlasClient = ApiClientFactory.atlas_client() @sync async def get_access_token(self) -> str: token_schema = await self.atlas_client.get_authorization_token() return token_schema.access_token class DecibelApiService: decibel_client: DecibelClient def __init__(self, access_token): self.decibel_client = ApiClientFactory.decibel_client(access_token) @sync async def event_processing(self, event: Event) -> None: for record in event.records: if record.detail_type in [DetailType.ACCOUNT_CREATE.value, DetailType.ACCOUNT_UPDATE.value]: await self.decibel_client.create_or_update_user(record.account_id) if record.detail_type == DetailType.ACCOUNT_DELETE: await self.decibel_client.delete_user(record.account_id)