from abc import ABC, abstractmethod import aiohttp from models import Marketplace class BaseMarketplaceApi(ABC): marketplace: Marketplace @abstractmethod def __init__(self, marketplace: Marketplace): pass async def _method(self, http_method, method, **kwargs): async with aiohttp.ClientSession(headers=self.get_headers) as session: async with session.request(http_method, self.base_url + method, **kwargs) as response: return await response.json() @property @abstractmethod def get_headers(self) -> dict: pass @property @abstractmethod def base_url(self) -> str: pass