#!/bin/bash

# ThrillWiki API Endpoint Testing Script - Raw Output Only
# Base URL: http://127.0.0.1:8000

BASE_URL="http://127.0.0.1:8000"

echo "=== HOME PAGE ==="
curl -s "$BASE_URL/"

echo -e "\n=== HEALTH CHECKS ==="
curl -s "$BASE_URL/health/"
curl -s "$BASE_URL/api/v1/health/"
curl -s "$BASE_URL/api/v1/health/simple/"
curl -s "$BASE_URL/api/v1/health/performance/"

echo -e "\n=== API DOCUMENTATION ==="
curl -s "$BASE_URL/api/schema/"
curl -s "$BASE_URL/api/docs/"
curl -s "$BASE_URL/api/redoc/"

echo -e "\n=== AUTHENTICATION ==="
curl -s "$BASE_URL/api/v1/auth/status/"
curl -s -X POST -H "Content-Type: application/json" -d '{"username":"test","password":"test"}' "$BASE_URL/api/v1/auth/login/"
curl -s -X POST -H "Content-Type: application/json" -d '{"username":"test","email":"test@example.com","password":"test123"}' "$BASE_URL/api/v1/auth/signup/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/auth/logout/"
curl -s "$BASE_URL/api/v1/auth/user/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/auth/token/refresh/"
curl -s -X POST -H "Content-Type: application/json" -d '{"email":"test@example.com"}' "$BASE_URL/api/v1/auth/password/reset/"
curl -s -X POST -H "Content-Type: application/json" -d '{"old_password":"old","new_password":"new"}' "$BASE_URL/api/v1/auth/password/change/"

echo -e "\n=== SOCIAL AUTHENTICATION ==="
curl -s "$BASE_URL/api/v1/auth/social/providers/"
curl -s "$BASE_URL/api/v1/auth/social/providers/available/"
curl -s "$BASE_URL/api/v1/auth/social/connected/"
curl -s "$BASE_URL/api/v1/auth/social/status/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/auth/social/connect/google/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/auth/social/disconnect/google/"

echo -e "\n=== EMAIL VERIFICATION ==="
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/auth/resend-verification/"
curl -s "$BASE_URL/api/v1/auth/verify-email/sample-token/"

echo -e "\n=== PARKS API ==="
curl -s "$BASE_URL/api/v1/parks/"
curl -s -X POST -H "Content-Type: application/json" -d '{"name":"Test Park","location":"Test Location"}' "$BASE_URL/api/v1/parks/"
curl -s "$BASE_URL/api/v1/parks/hybrid/"
curl -s "$BASE_URL/api/v1/parks/hybrid/filter-metadata/"
curl -s "$BASE_URL/api/v1/parks/filter-options/"
curl -s "$BASE_URL/api/v1/parks/search/companies/"
curl -s "$BASE_URL/api/v1/parks/search-suggestions/"
curl -s "$BASE_URL/api/v1/parks/1/"
curl -s "$BASE_URL/api/v1/parks/sample-park/"
curl -s "$BASE_URL/api/v1/parks/1/image-settings/"

echo -e "\n=== PARK PHOTOS ==="
curl -s "$BASE_URL/api/v1/parks/1/photos/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/parks/1/photos/"
curl -s "$BASE_URL/api/v1/parks/1/photos/1/"

echo -e "\n=== RIDES API ==="
curl -s "$BASE_URL/api/v1/rides/"
curl -s -X POST -H "Content-Type: application/json" -d '{"name":"Test Ride","park":1}' "$BASE_URL/api/v1/rides/"
curl -s "$BASE_URL/api/v1/rides/hybrid/"
curl -s "$BASE_URL/api/v1/rides/hybrid/filter-metadata/"
curl -s "$BASE_URL/api/v1/rides/filter-options/"
curl -s "$BASE_URL/api/v1/rides/search/companies/"
curl -s "$BASE_URL/api/v1/rides/search/ride-models/"
curl -s "$BASE_URL/api/v1/rides/search-suggestions/"
curl -s "$BASE_URL/api/v1/rides/1/"
curl -s "$BASE_URL/api/v1/rides/1/image-settings/"

echo -e "\n=== RIDE PHOTOS ==="
curl -s "$BASE_URL/api/v1/rides/1/photos/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/rides/1/photos/"
curl -s "$BASE_URL/api/v1/rides/1/photos/1/"

echo -e "\n=== RIDE MANUFACTURERS & MODELS ==="
curl -s "$BASE_URL/api/v1/rides/manufacturers/sample-manufacturer/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/rides/manufacturers/sample-manufacturer/"
curl -s "$BASE_URL/api/v1/rides/manufacturers/sample-manufacturer/search/"
curl -s "$BASE_URL/api/v1/rides/manufacturers/sample-manufacturer/filter-options/"
curl -s "$BASE_URL/api/v1/rides/manufacturers/sample-manufacturer/stats/"
curl -s "$BASE_URL/api/v1/rides/manufacturers/sample-manufacturer/sample-model/"

echo -e "\n=== RIDE MODEL VARIANTS & SPECS ==="
curl -s "$BASE_URL/api/v1/rides/manufacturers/sample-manufacturer/sample-model/variants/"
curl -s "$BASE_URL/api/v1/rides/manufacturers/sample-manufacturer/sample-model/variants/1/"
curl -s "$BASE_URL/api/v1/rides/manufacturers/sample-manufacturer/sample-model/technical-specs/"
curl -s "$BASE_URL/api/v1/rides/manufacturers/sample-manufacturer/sample-model/technical-specs/1/"
curl -s "$BASE_URL/api/v1/rides/manufacturers/sample-manufacturer/sample-model/photos/"
curl -s "$BASE_URL/api/v1/rides/manufacturers/sample-manufacturer/sample-model/photos/1/"

echo -e "\n=== RANKINGS API ==="
curl -s "$BASE_URL/api/v1/rankings/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/rankings/calculate/"

echo -e "\n=== TRENDING & NEW CONTENT ==="
curl -s "$BASE_URL/api/v1/trending/"
curl -s "$BASE_URL/api/v1/new-content/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/trending/calculate/"

echo -e "\n=== STATISTICS ==="
curl -s "$BASE_URL/api/v1/stats/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/stats/recalculate/"

echo -e "\n=== REVIEWS ==="
curl -s "$BASE_URL/api/v1/reviews/latest/"

echo -e "\n=== ACCOUNT MANAGEMENT ==="
curl -s "$BASE_URL/api/v1/accounts/profile/"
curl -s -X PUT -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/profile/update/"
curl -s "$BASE_URL/api/v1/accounts/profile/account/"
curl -s -X PUT -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/profile/account/"

echo -e "\n=== USER PREFERENCES ==="
curl -s "$BASE_URL/api/v1/accounts/preferences/"
curl -s -X PUT -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/preferences/update/"
curl -s -X PUT -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/preferences/theme/"

echo -e "\n=== NOTIFICATION SETTINGS ==="
curl -s "$BASE_URL/api/v1/accounts/settings/notifications/"
curl -s -X PUT -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/settings/notifications/update/"

echo -e "\n=== PRIVACY SETTINGS ==="
curl -s "$BASE_URL/api/v1/accounts/settings/privacy/"
curl -s -X PUT -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/settings/privacy/update/"

echo -e "\n=== SECURITY SETTINGS ==="
curl -s "$BASE_URL/api/v1/accounts/settings/security/"
curl -s -X PUT -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/settings/security/update/"

echo -e "\n=== USER STATISTICS & TOP LISTS ==="
curl -s "$BASE_URL/api/v1/accounts/statistics/"
curl -s "$BASE_URL/api/v1/accounts/top-lists/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/top-lists/create/"
curl -s -X PUT -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/top-lists/1/"
curl -s -X DELETE "$BASE_URL/api/v1/accounts/top-lists/1/"

echo -e "\n=== NOTIFICATIONS ==="
curl -s "$BASE_URL/api/v1/accounts/notifications/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/notifications/mark-read/"
curl -s "$BASE_URL/api/v1/accounts/notification-preferences/"
curl -s -X PUT -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/notification-preferences/update/"

echo -e "\n=== AVATAR MANAGEMENT ==="
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/profile/avatar/upload/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/profile/avatar/save/"
curl -s -X DELETE "$BASE_URL/api/v1/accounts/profile/avatar/delete/"

echo -e "\n=== ACCOUNT DELETION ==="
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/delete-account/request/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/delete-account/verify/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/accounts/delete-account/cancel/"
curl -s "$BASE_URL/api/v1/accounts/users/sample-id/deletion-check/"
curl -s -X DELETE "$BASE_URL/api/v1/accounts/users/sample-id/delete/"

echo -e "\n=== HISTORY ==="
curl -s "$BASE_URL/api/v1/history/timeline/"
curl -s "$BASE_URL/api/v1/history/parks/sample-park/"
curl -s "$BASE_URL/api/v1/history/parks/sample-park/detail/"
curl -s "$BASE_URL/api/v1/history/parks/sample-park/rides/sample-ride/"
curl -s "$BASE_URL/api/v1/history/parks/sample-park/rides/sample-ride/detail/"

echo -e "\n=== EMAIL ==="
curl -s -X POST -H "Content-Type: application/json" -d '{"to":"test@example.com","subject":"Test","message":"Test message"}' "$BASE_URL/api/v1/email/send/"

echo -e "\n=== CORE SEARCH & ENTITIES ==="
curl -s "$BASE_URL/api/v1/core/entities/search/"
curl -s "$BASE_URL/api/v1/core/entities/not-found/"
curl -s "$BASE_URL/api/v1/core/entities/suggestions/"

echo -e "\n=== MAPS ==="
curl -s "$BASE_URL/api/v1/maps/locations/"
curl -s "$BASE_URL/api/v1/maps/locations/park/1/"
curl -s "$BASE_URL/api/v1/maps/search/"
curl -s "$BASE_URL/api/v1/maps/bounds/"
curl -s "$BASE_URL/api/v1/maps/stats/"
curl -s "$BASE_URL/api/v1/maps/cache/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/maps/cache/invalidate/"

echo -e "\n=== MODERATION ==="
curl -s "$BASE_URL/api/v1/moderation/reports/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/moderation/reports/"
curl -s "$BASE_URL/api/v1/moderation/reports/1/"
curl -s "$BASE_URL/api/v1/moderation/reports/stats/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/moderation/reports/1/assign/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/moderation/reports/1/resolve/"

echo -e "\n=== MODERATION QUEUE ==="
curl -s "$BASE_URL/api/v1/moderation/queue/"
curl -s "$BASE_URL/api/v1/moderation/queue/1/"
curl -s "$BASE_URL/api/v1/moderation/queue/my_queue/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/moderation/queue/1/assign/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/moderation/queue/1/unassign/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/moderation/queue/1/complete/"

echo -e "\n=== MODERATION ACTIONS ==="
curl -s "$BASE_URL/api/v1/moderation/actions/"
curl -s "$BASE_URL/api/v1/moderation/actions/active/"
curl -s "$BASE_URL/api/v1/moderation/actions/expired/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/moderation/actions/1/deactivate/"

echo -e "\n=== BULK OPERATIONS ==="
curl -s "$BASE_URL/api/v1/moderation/bulk-operations/"
curl -s "$BASE_URL/api/v1/moderation/bulk-operations/running/"
curl -s "$BASE_URL/api/v1/moderation/bulk-operations/1/"
curl -s "$BASE_URL/api/v1/moderation/bulk-operations/1/logs/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/moderation/bulk-operations/1/cancel/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/moderation/bulk-operations/1/retry/"

echo -e "\n=== USER MODERATION ==="
curl -s "$BASE_URL/api/v1/moderation/users/1/"
curl -s -X POST -H "Content-Type: application/json" "$BASE_URL/api/v1/moderation/users/1/moderate/"
curl -s "$BASE_URL/api/v1/moderation/users/search/"
curl -s "$BASE_URL/api/v1/moderation/users/stats/"

echo -e "\n=== CLOUDFLARE IMAGES ==="
curl -s "$BASE_URL/api/v1/cloudflare-images/"

echo -e "\n=== ENVIRONMENT & SETTINGS ==="
curl -s "$BASE_URL/env-settings/"

echo -e "\n=== STATIC PAGES ==="
curl -s "$BASE_URL/terms/"
curl -s "$BASE_URL/privacy/"

echo -e "\n=== Testing completed ==="