feat: implement backend API clients for multi-marketplace integration and frontend service layer
This commit is contained in:
52
backend/mm_api/services/orders.py
Normal file
52
backend/mm_api/services/orders.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from typing import Dict, Any, List
|
||||
from ..client import MMClient
|
||||
|
||||
class OrdersService:
|
||||
"""Service to handle Magnit Market Orders (FBS)."""
|
||||
|
||||
def __init__(self, client: MMClient):
|
||||
self.client = client
|
||||
|
||||
def get_unprocessed_list(self, dir: str = "ASC", page_size: int = 100, page_token: str = None, **filters) -> Dict[str, Any]:
|
||||
"""
|
||||
Get list of unprocessed assembly tasks.
|
||||
Endpoint: /api/seller/v1/orders/list/unprocessed
|
||||
"""
|
||||
payload = {
|
||||
"dir": dir,
|
||||
"page_size": page_size
|
||||
}
|
||||
if page_token:
|
||||
payload["page_token"] = page_token
|
||||
|
||||
# Add any extra filters like created_at, cutoff_time, etc.
|
||||
payload.update(filters)
|
||||
|
||||
return self.client.post("/api/seller/v1/orders/list/unprocessed", data=payload)
|
||||
|
||||
def get_list(self, dir: str = "ASC", page_size: int = 100, page_token: str = None, **filters) -> Dict[str, Any]:
|
||||
"""
|
||||
Get list of orders by parameters.
|
||||
Endpoint: /api/seller/v1/orders/list
|
||||
"""
|
||||
payload = {
|
||||
"dir": dir,
|
||||
"page_size": page_size
|
||||
}
|
||||
if page_token:
|
||||
payload["page_token"] = page_token
|
||||
|
||||
payload.update(filters)
|
||||
|
||||
return self.client.post("/api/seller/v1/orders/list", data=payload)
|
||||
|
||||
def cancel_items(self, order_id: str, items: List[Dict[str, int]]) -> Dict[str, Any]:
|
||||
"""
|
||||
Cancel specific items in an order.
|
||||
Endpoint: /api/seller/v1/orders/cancel-items
|
||||
"""
|
||||
payload = {
|
||||
"order_id": order_id,
|
||||
"items": items
|
||||
}
|
||||
return self.client.post("/api/seller/v1/orders/cancel-items", data=payload)
|
||||
Reference in New Issue
Block a user