40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
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})
|