rewritten crap
This commit is contained in:
@@ -8,13 +8,14 @@ from database import Marketplace
|
||||
|
||||
class BaseMarketplaceApi(ABC):
|
||||
session: ClientSession
|
||||
is_valid: bool
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self, marketplace: Marketplace):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def update_stocks(self, data: Union[list, dict]):
|
||||
async def update_stocks(self, data: Union[list, dict]) -> ClientResponse:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@@ -26,15 +27,15 @@ class BaseMarketplaceApi(ABC):
|
||||
def api_url(self):
|
||||
pass
|
||||
|
||||
def init_session(self):
|
||||
self.session = ClientSession()
|
||||
|
||||
async def _method(self, http_method: Literal['POST', 'GET', 'PATCH', 'PUT', 'DELETE'],
|
||||
method: str,
|
||||
data: dict) -> ClientResponse:
|
||||
return await self.session.request(
|
||||
self.session = ClientSession()
|
||||
response = await self.session.request(
|
||||
http_method,
|
||||
f'{self.api_url}{method}',
|
||||
json=data,
|
||||
headers=self.get_headers()
|
||||
)
|
||||
await self.session.close()
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user