feat: implement backend API clients for multi-marketplace integration and frontend service layer

This commit is contained in:
2026-05-12 13:16:14 +03:00
parent 6974af486a
commit ee39a3d83b
65 changed files with 2501 additions and 33 deletions

View File

@@ -0,0 +1,39 @@
from typing import Dict, Any, List
from ..client import WBClient
class ContentService:
"""Service to handle WB product cards (Content API)."""
def __init__(self, client: WBClient):
self.client = client
self.base_url = WBClient.CONTENT_API
def get_cards_list(self, limit: int = 100, updated_at: str = "", last_id: str = "") -> Dict[str, Any]:
"""
Get list of nomenclatures (product cards).
Endpoint: /content/v2/get/cards/list
"""
payload = {
"settings": {
"cursor": {
"limit": limit
},
"filter": {
"withPhoto": -1
}
}
}
if updated_at:
payload["settings"]["cursor"]["updatedAt"] = updated_at
if last_id:
payload["settings"]["cursor"]["nmID"] = int(last_id)
return self.client.post(self.base_url, "/content/v2/get/cards/list", data=payload)
def create_cards(self, cards: List[Dict[str, Any]]) -> Dict[str, Any]:
"""
Create product cards.
Endpoint: /content/v2/cards/upload
"""
return self.client.post(self.base_url, "/content/v2/cards/upload", data=cards)

View File

@@ -0,0 +1,39 @@
from typing import Dict, Any, List
from ..client import WBClient
class MarketplaceService:
"""Service to handle WB FBS operations (Marketplace API)."""
def __init__(self, client: WBClient):
self.client = client
self.base_url = WBClient.MARKETPLACE_API
def get_new_orders(self) -> Dict[str, Any]:
"""
Get new orders (FBS).
Endpoint: /api/v3/orders/new
"""
return self.client.get(self.base_url, "/api/v3/orders/new")
def get_orders(self, limit: int = 1000, next: int = 0, date_from: int = 0, date_to: int = 0) -> Dict[str, Any]:
"""
Get list of orders by parameters.
Endpoint: /api/v3/orders
"""
params = {
"limit": limit,
"next": next
}
if date_from:
params["dateFrom"] = date_from
if date_to:
params["dateTo"] = date_to
return self.client.get(self.base_url, "/api/v3/orders", params=params)
def put_orders_status(self, orders: List[Dict[str, Any]]) -> Dict[str, Any]:
"""
Change status of orders (e.g. to assembly).
Endpoint: /api/v3/orders/status
"""
return self.client.post(self.base_url, "/api/v3/orders/status", data={"orders": orders})