from typing import Any from dirty_equals import DirtyEquals from dmp.adapters.tiktok.models import AdAccount from dmp.tiktok.models import TikTokAdAccount class IsUserAdAccount(DirtyEquals[AdAccount]): def __init__(self, api_ad_account: AdAccount): self.api_ad_account = api_ad_account super().__init__() def equals(self, other: Any) -> bool: if not isinstance(other, TikTokAdAccount): return False business_center_id = None business_center_name = None if self.api_ad_account: business_center_id = self.api_ad_account.owner_bc_id business_center_name = self.api_ad_account.company return ( self.api_ad_account.advertiser_id == other.external_id and self.api_ad_account.name == other.name and business_center_id == other.business_center_id and business_center_name == other.business_center_name )