123
This commit is contained in:
@@ -7,7 +7,7 @@ from aiohttp import ClientResponse
|
||||
from database import Marketplace
|
||||
|
||||
|
||||
class BaseJsonMarketplace(ABC):
|
||||
class BaseMarketplaceApi(ABC):
|
||||
@abstractmethod
|
||||
def __init__(self, marketplace: Marketplace):
|
||||
pass
|
||||
@@ -20,18 +20,17 @@ class BaseJsonMarketplace(ABC):
|
||||
def get_headers(self):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@property
|
||||
@abstractmethod
|
||||
def api_url(self):
|
||||
pass
|
||||
|
||||
async def _method(self, http_method: Literal['POST', 'GET', 'PATCH', 'PUT', 'DELETE'],
|
||||
method: str,
|
||||
data: dict) -> ClientResponse:
|
||||
async with aiohttp.ClientSession as session:
|
||||
async with session.request(http_method,
|
||||
f'{self.api_url}{method}',
|
||||
json=data,
|
||||
headers=self.get_headers()
|
||||
) as response:
|
||||
return response
|
||||
async with aiohttp.ClientSession() as session:
|
||||
return await session.request(http_method,
|
||||
f'{self.api_url}{method}',
|
||||
json=data,
|
||||
headers=self.get_headers()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user