import requests
import json

# Test updating a beach schedule
schedule_id = 1
url = f"http://localhost:8080/api/beach-schedules/{schedule_id}"

print(f"Testing PUT request to update schedule {schedule_id}")

updated_schedule = {
    "from_date": "2025-11-01",
    "to_date": "2026-01-31",
    "from_time": "10:00",
    "to_time": "19:00",
    "valid_dates": "12345",
    "min_hours": 3,
    "currency_id": 2,  # USD
    "price": 20.00,
    "price_vip": 35.00,
    "can_refund": True,
    "refund_before_hours": 48,
    "extras": "Umbrella +10$",
    "extras_vip": "Premium Umbrella +20$"
}

try:
    response = requests.put(url, json=updated_schedule)
    print(f"Status Code: {response.status_code}")
    print(f"Response: {response.text}")
except Exception as e:
    print(f"Error: {e}")

# Test getting the updated schedule
print(f"\nTesting GET request to verify update")

beach_id = "39ede4e0-7304-4999-be4e-d48d869a7a88"
get_url = f"http://localhost:8080/api/beach-schedules/{beach_id}"

try:
    response = requests.get(get_url)
    print(f"Status Code: {response.status_code}")
    schedules = response.json()
    if schedules:
        schedule = schedules[0]
        print(f"Updated Schedule:")
        print(f"  - From Date: {schedule.get('from_date')}")
        print(f"  - To Date: {schedule.get('to_date')}")
        print(f"  - Price: {schedule.get('price')}")
        print(f"  - VIP Price: {schedule.get('price_vip')}")
        print(f"  - Currency Symbol: {schedule.get('currency_symbol')}")
        print(f"  - Min Hours: {schedule.get('min_hours')}")
        print(f"  - Refund Hours: {schedule.get('refund_before_hours')}")
    else:
        print("No schedules found.")
except Exception as e:
    print(f"Error: {e}")

# Test deleting the schedule
print(f"\nTesting DELETE request to delete schedule {schedule_id}")

try:
    response = requests.delete(f"http://localhost:8080/api/beach-schedules/delete/{schedule_id}")
    print(f"Status Code: {response.status_code}")
    print(f"Response: {response.text}")
except Exception as e:
    print(f"Error: {e}")