feat: implement backend API clients for multi-marketplace integration and frontend service layer
This commit is contained in:
29
backend/flowwow_api/services/orders.py
Normal file
29
backend/flowwow_api/services/orders.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from typing import Dict, Any
|
||||
from ..client import FlowwowClient
|
||||
|
||||
class OrdersService:
|
||||
"""Service to handle Flowwow Orders."""
|
||||
|
||||
def __init__(self, client: FlowwowClient):
|
||||
self.client = client
|
||||
|
||||
def get_new_orders(self, limit: int = 50) -> Dict[str, Any]:
|
||||
"""
|
||||
Get list of new, unprocessed orders.
|
||||
Endpoint: /orders/new
|
||||
"""
|
||||
return self.client.get("/orders/new", params={"limit": limit})
|
||||
|
||||
def accept_order(self, order_id: str) -> Dict[str, Any]:
|
||||
"""
|
||||
Accept an order for processing.
|
||||
Endpoint: /orders/{order_id}/accept
|
||||
"""
|
||||
return self.client.post(f"/orders/{order_id}/accept")
|
||||
|
||||
def upload_photo(self, order_id: str, image_url: str) -> Dict[str, Any]:
|
||||
"""
|
||||
Upload a photo of the completed order before shipping.
|
||||
Endpoint: /orders/{order_id}/photo
|
||||
"""
|
||||
return self.client.post(f"/orders/{order_id}/photo", data={"image_url": image_url})
|
||||
30
backend/flowwow_api/services/products.py
Normal file
30
backend/flowwow_api/services/products.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from typing import Dict, Any, List
|
||||
from ..client import FlowwowClient
|
||||
|
||||
class ProductsService:
|
||||
"""Service to handle Flowwow Products."""
|
||||
|
||||
def __init__(self, client: FlowwowClient):
|
||||
self.client = client
|
||||
|
||||
def get_list(self, limit: int = 100, offset: int = 0) -> Dict[str, Any]:
|
||||
"""
|
||||
Get list of products.
|
||||
Endpoint: /products
|
||||
"""
|
||||
params = {"limit": limit, "offset": offset}
|
||||
return self.client.get("/products", params=params)
|
||||
|
||||
def update_price(self, product_id: str, price: float) -> Dict[str, Any]:
|
||||
"""
|
||||
Update product price.
|
||||
Endpoint: /products/{product_id}/price
|
||||
"""
|
||||
return self.client.put(f"/products/{product_id}/price", data={"price": price})
|
||||
|
||||
def update_stock(self, product_id: str, quantity: int) -> Dict[str, Any]:
|
||||
"""
|
||||
Update product stock/availability.
|
||||
Endpoint: /products/{product_id}/stock
|
||||
"""
|
||||
return self.client.put(f"/products/{product_id}/stock", data={"quantity": quantity})
|
||||
Reference in New Issue
Block a user