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,33 @@
from typing import Dict, Any, List
from ..client import OzonClient
class FBSService:
"""Service to handle FBS (Fulfillment by Seller) operations."""
def __init__(self, client: OzonClient):
self.client = client
def get_unfulfilled_list(self, dir: str = "ASC", filter_params: Dict[str, Any] = None, limit: int = 100, offset: int = 0) -> Dict[str, Any]:
"""
Get a list of new/unfulfilled FBS orders.
Endpoint: /v3/posting/fbs/unfulfilled/list
"""
payload = {
"dir": dir,
"filter": filter_params or {},
"limit": limit,
"offset": offset,
"with": {
"analytics_data": True,
"barcodes": True,
"financial_data": True
}
}
return self.client.post("/v3/posting/fbs/unfulfilled/list", data=payload)
def ship_packages(self, packages: List[Dict[str, Any]]) -> Dict[str, Any]:
"""
Ship unfulfilled orders.
Endpoint: /v3/posting/fbs/ship
"""
return self.client.post("/v3/posting/fbs/ship", data={"packages": packages})

View File

@@ -0,0 +1,42 @@
from typing import Dict, Any, List
from ..client import OzonClient
class ProductsService:
"""Service to handle product-related operations."""
def __init__(self, client: OzonClient):
self.client = client
def get_list(self, filter_params: Dict[str, Any] = None, last_id: str = "", limit: int = 100) -> Dict[str, Any]:
"""
Get a list of products.
Endpoint: /v2/product/list
"""
payload = {
"filter": filter_params or {},
"last_id": last_id,
"limit": limit
}
return self.client.post("/v2/product/list", data=payload)
def get_info(self, offer_id: str = None, product_id: int = None, sku: int = None) -> Dict[str, Any]:
"""
Get product info by offer_id, product_id or sku.
Endpoint: /v2/product/info
"""
payload = {}
if offer_id:
payload["offer_id"] = offer_id
if product_id:
payload["product_id"] = product_id
if sku:
payload["sku"] = sku
return self.client.post("/v2/product/info", data=payload)
def import_products(self, items: List[Dict[str, Any]]) -> Dict[str, Any]:
"""
Create or update products.
Endpoint: /v2/product/import
"""
return self.client.post("/v2/product/import", data={"items": items})