feat: implement backend API clients for multi-marketplace integration and frontend service layer
This commit is contained in:
39
backend/wb_api/services/marketplace.py
Normal file
39
backend/wb_api/services/marketplace.py
Normal 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})
|
||||
Reference in New Issue
Block a user