Abc / utils /GetBookingsForSpecificDate.py
grayphite's picture
added modules
a7fc713
from datetime import datetime
import requests
import json
from utils.common import ACCOUNT_ID, BASE_URL, HEADER, LOCATION_ID
get_booking_for_specific_date_tool = {
"type": "function",
"function": {
"name": "GetBookingsForSpecificDate",
"description": "Fetches bookings for a specific location and date.",
"parameters": {
"type": "object",
"properties": {
"location_id": {
"type": "string",
"description": "ID of the location to fetch bookings for.",
"default": LOCATION_ID
},
"date": {
"type": "string",
"format": "date",
"description": "Date to fetch bookings for in YYYY-MM-DD format. Defaults to today's date if not "
"specified.",
"default": datetime.now().strftime('%Y-%m-%d')
}
},
"required": ["location_id", "date"]
}
}
}
def GetBookingsForSpecificDate(location_id=LOCATION_ID, date=None):
"""Fetch and print the bookings for a specific location and date."""
if date is None:
date = datetime.now().strftime('%Y-%m-%d')
url = f"{BASE_URL}location/{location_id}/bookings/{date}"
try:
response = requests.get(url, headers=HEADER)
response.raise_for_status() # Raise an HTTPError for bad responses
response_data = response.json()
formatted_response = json.dumps(response_data, indent=2)
return formatted_response
except requests.RequestException as e:
return f"Error making API request: {str(e)}"