MukeshKapoor25 commited on
Commit
31bb69e
·
1 Parent(s): 274a33b

fix(appointment): make order_id optional with default None

Browse files

Add logging to list_customer_appointments endpoint for debugging

app/models/appointment.py CHANGED
@@ -165,7 +165,7 @@ class AppointmentResponse(BaseModel):
165
  payment_status: str
166
  payment_id: Optional[str] # ✅ Included payment_id
167
  cleared_amount: float
168
- order_id: Optional[str] # ✅ Included order
169
  cancel_reason: Optional[str] # ✅ Included cancel_reason
170
 
171
 
 
165
  payment_status: str
166
  payment_id: Optional[str] # ✅ Included payment_id
167
  cleared_amount: float
168
+ order_id: Optional[str] = None # ✅ Included order as optional with default
169
  cancel_reason: Optional[str] # ✅ Included cancel_reason
170
 
171
 
app/routers/appointment.py CHANGED
@@ -156,7 +156,13 @@ async def list_customer_appointments(
156
  current_user: dict = Depends(get_current_user)
157
  ):
158
  # Extract customer_id from current_user token
 
 
 
159
  customer_id = current_user.get("sub")
 
 
 
160
  if not customer_id:
161
  raise HTTPException(status_code=401, detail="Invalid token: missing customer ID")
162
 
 
156
  current_user: dict = Depends(get_current_user)
157
  ):
158
  # Extract customer_id from current_user token
159
+
160
+ logger.info(f"Request received for list_customer_appointments with limit={limit}, offset={offset}, status={status}")
161
+
162
  customer_id = current_user.get("sub")
163
+
164
+ logger.info(f"Fetching appointments for customer: {customer_id} with limit={limit}, offset={offset}, status={status}")
165
+
166
  if not customer_id:
167
  raise HTTPException(status_code=401, detail="Invalid token: missing customer ID")
168
 
app/services/appointment.py CHANGED
@@ -372,6 +372,7 @@ async def get_appointments_by_customer_id(
372
  payment_status=appointment.get("payment_status", "Pending"),
373
  payment_id=str(appointment.get("payment_id", "")) if appointment.get("payment_id") else None,
374
  cleared_amount=float(appointment.get("cleared_amount", 0.0)),
 
375
  cancel_reason=appointment.get("cancel_reason", ""),
376
  )
377
  for appointment in appointments
 
372
  payment_status=appointment.get("payment_status", "Pending"),
373
  payment_id=str(appointment.get("payment_id", "")) if appointment.get("payment_id") else None,
374
  cleared_amount=float(appointment.get("cleared_amount", 0.0)),
375
+ order_id=str(appointment.get("order_id", "")) if appointment.get("order_id") else None,
376
  cancel_reason=appointment.get("cancel_reason", ""),
377
  )
378
  for appointment in appointments