File size: 1,044 Bytes
9b74d99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from typing import List
from httpx import AsyncClient
from pydantic import BaseModel
from datetime import datetime
from ..core.config import settings

class OrderSchema(BaseModel):
    id: str
    branch_id: str
    customer_id: str
    items: List[dict]
    total_amount: float
    status: str
    created_at: datetime
    updated_at: datetime | None

async def get_orders(branch_id: str) -> List[OrderSchema]:
    """

    Fetch orders from the POS system for a specific branch

    

    Args:

        branch_id: The ID of the branch to fetch orders for

        

    Returns:

        List[OrderSchema]: A list of orders from the POS system

    """
    async with AsyncClient() as client:
        response = await client.get(
            f"{settings.POS_API_URL}/internal/orders",
            params={"branch_id": branch_id},
            headers={"Authorization": f"Bearer {settings.SERVICE_TOKEN}"}
        )
        response.raise_for_status()
        return [OrderSchema(**order) for order in response.json()]