Spaces:
Sleeping
Sleeping
### api_docs_mck.py | |
import json | |
daysoff_api_docs = { | |
"base_url": "https://670dccd0073307b4ee447f2f.mockapi.io/daysoff/api/V1/booking", | |
"endpoints": { | |
"method": "POST", | |
"description": "Retrieve booking information for a given booking ID.", | |
"parameters": { | |
"booking_id": { | |
"type": "string", | |
"description": "The unique identifier of the booking to retrieve ('bestillingsnummer')" | |
} | |
}, | |
"headers": { | |
"Content-Type": "application/json" | |
}, | |
"response": { | |
"description": "A decoded JSON object containing booking details ('Informasjon om bestillingen)", | |
"content_type": "application/json", | |
"booking_info": { | |
"booking_id": "response.get('booking_id', 'N/A')", | |
"full_name": "response.get('full_name', 'N/A')", | |
"amount": "response.get('amount', 'N/A')", | |
"date": "response.get('date', 'N/A')", | |
"address": "response.get('address', 'N/A')", | |
"user_id": "response.get('user_id', 'N/A')" | |
} | |
} | |
} | |
} | |
# --json decode fu. | |
def decode_booking_info(response): | |
booking_info = { | |
"booking_id": response.get("booking_id", "N/A"), | |
"full_name": response.get("full_name", "N/A"), | |
"amount": response.get("amount", "N/A"), | |
"date": response.get("date", "N/A"), | |
"address": response.get("address", "N/A"), | |
"user_id": response.get("user_id", "N/A") | |
} | |
json_decode = ( | |
f"Booking ID: {booking_info['booking_id']}\n" | |
f"Full Name: {booking_info['full_name']}\n" | |
f"Amount: {booking_info['amount']}\n" | |
f"Date: {booking_info['date']}\n" | |
f"Address: {booking_info['address']}\n" | |
f"User ID: {booking_info['user_id']}" | |
) | |
return json_decode | |