feat: a lot of a lot

This commit is contained in:
2024-09-01 01:05:11 +03:00
parent 867dfbe597
commit 4ae03284a3
43 changed files with 700 additions and 13 deletions

1
external/marketplace/base/__init__.py vendored Normal file
View File

@@ -0,0 +1 @@
from .core import BaseMarketplaceApi

28
external/marketplace/base/core.py vendored Normal file
View 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