feat: a lot of a lot
This commit is contained in:
28
external/marketplace/base/core.py
vendored
Normal file
28
external/marketplace/base/core.py
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
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
|
||||
Reference in New Issue
Block a user