Compare commits

...

2 Commits

Author SHA1 Message Date
7e721aa7cf Merge pull request 'refactor(api): replace hardcoded URLs with dynamic URL generation' (#9) from feature/meetings into main
Reviewed-on: https://gitea.blackbusinesslabs.com/ATTUNE-HEART-THERAPY/alternative-backend-service/pulls/9
2025-11-23 12:21:27 +00:00
4acd78988e refactor(api): replace hardcoded URLs with dynamic URL generation
Replace hardcoded localhost URLs (http://127.0.0.1:8000) in API root
endpoint documentation with request.build_absolute_uri() calls. This
makes the API documentation URLs environment-agnostic and ensures they
reflect the actual domain/host being used to access the API, improving
portability across development, staging, and production environments.
2025-11-23 12:20:05 +00:00

View File

@ -105,7 +105,7 @@ def api_root(request, format=None):
"endpoints": { "endpoints": {
"admin_availability": { "admin_availability": {
"description": "Get or update admin weekly availability (Admin only)", "description": "Get or update admin weekly availability (Admin only)",
"url": "http://127.0.0.1:8000/api/meetings/admin/availability/", "url": request.build_absolute_uri("/api/meetings/admin/availability/"),
"methods": ["GET", "PUT", "PATCH"], "methods": ["GET", "PUT", "PATCH"],
"authentication": "Required (Staff users only)", "authentication": "Required (Staff users only)",
"response_fields": { "response_fields": {
@ -118,14 +118,14 @@ def api_root(request, format=None):
}, },
"available_dates": { "available_dates": {
"description": "Get available appointment dates for the next 30 days (Public)", "description": "Get available appointment dates for the next 30 days (Public)",
"url": "http://127.0.0.1:8000/api/meetings/appointments/available-dates/", "url": request.build_absolute_uri("/api/meetings/appointments/available-dates/"),
"methods": ["GET"], "methods": ["GET"],
"authentication": "None required", "authentication": "None required",
"response": "List of available dates in YYYY-MM-DD format" "response": "List of available dates in YYYY-MM-DD format"
}, },
"create_appointment": { "create_appointment": {
"description": "Create a new appointment request (Public)", "description": "Create a new appointment request (Public)",
"url": "http://127.0.0.1:8000/api/meetings/appointments/create/", "url": request.build_absolute_uri("/api/meetings/appointments/create/"),
"methods": ["POST"], "methods": ["POST"],
"authentication": "None required", "authentication": "None required",
"required_fields": [ "required_fields": [
@ -146,7 +146,7 @@ def api_root(request, format=None):
}, },
"list_appointments": { "list_appointments": {
"description": "List appointment requests (Admin sees all, users see their own)", "description": "List appointment requests (Admin sees all, users see their own)",
"url": "http://127.0.0.1:8000/api/meetings/appointments/", "url": request.build_absolute_uri("/api/meetings/appointments/"),
"methods": ["GET"], "methods": ["GET"],
"authentication": "Required", "authentication": "Required",
"query_parameters": { "query_parameters": {
@ -162,7 +162,7 @@ def api_root(request, format=None):
}, },
"appointment_detail": { "appointment_detail": {
"description": "Get detailed information about a specific appointment", "description": "Get detailed information about a specific appointment",
"url": "http://127.0.0.1:8000/api/meetings/appointments/<uuid:pk>/", "url": request.build_absolute_uri("/api/meetings/appointments/<uuid:pk>/"),
"methods": ["GET"], "methods": ["GET"],
"authentication": "Required", "authentication": "Required",
"url_parameter": "pk (UUID of the appointment)", "url_parameter": "pk (UUID of the appointment)",
@ -170,14 +170,14 @@ def api_root(request, format=None):
}, },
"user_appointments": { "user_appointments": {
"description": "Get appointments for the authenticated user", "description": "Get appointments for the authenticated user",
"url": "http://127.0.0.1:8000/api/meetings/user/appointments/", "url": request.build_absolute_uri("/api/meetings/user/appointments/"),
"methods": ["GET"], "methods": ["GET"],
"authentication": "Required", "authentication": "Required",
"response": "List of user's appointment requests with Jitsi meeting details" "response": "List of user's appointment requests with Jitsi meeting details"
}, },
"schedule_appointment": { "schedule_appointment": {
"description": "Schedule an appointment and automatically create Jitsi meeting (Admin only)", "description": "Schedule an appointment and automatically create Jitsi meeting (Admin only)",
"url": "http://127.0.0.1:8000/api/meetings/appointments/<uuid:pk>/schedule/", "url": request.build_absolute_uri("/api/meetings/appointments/<uuid:pk>/schedule/"),
"methods": ["POST"], "methods": ["POST"],
"authentication": "Required (Staff users only)", "authentication": "Required (Staff users only)",
"required_fields": ["scheduled_datetime"], "required_fields": ["scheduled_datetime"],
@ -202,7 +202,7 @@ def api_root(request, format=None):
}, },
"reject_appointment": { "reject_appointment": {
"description": "Reject an appointment request (Admin only)", "description": "Reject an appointment request (Admin only)",
"url": "http://127.0.0.1:8000/api/meetings/appointments/<uuid:pk>/reject/", "url": request.build_absolute_uri("/api/meetings/appointments/<uuid:pk>/reject/"),
"methods": ["POST"], "methods": ["POST"],
"authentication": "Required (Staff users only)", "authentication": "Required (Staff users only)",
"optional_fields": ["rejection_reason"], "optional_fields": ["rejection_reason"],
@ -219,7 +219,7 @@ def api_root(request, format=None):
}, },
"jitsi_meeting_info": { "jitsi_meeting_info": {
"description": "Get Jitsi meeting information for a scheduled appointment", "description": "Get Jitsi meeting information for a scheduled appointment",
"url": "http://127.0.0.1:8000/api/meetings/appointments/<uuid:pk>/jitsi-meeting/", "url": request.build_absolute_uri("/api/meetings/appointments/<uuid:pk>/jitsi-meeting/"),
"methods": ["GET"], "methods": ["GET"],
"authentication": "Required", "authentication": "Required",
"prerequisites": "Appointment must be in 'scheduled' status", "prerequisites": "Appointment must be in 'scheduled' status",
@ -235,7 +235,7 @@ def api_root(request, format=None):
}, },
"appointment_stats": { "appointment_stats": {
"description": "Get appointment statistics and analytics (Admin only)", "description": "Get appointment statistics and analytics (Admin only)",
"url": "http://127.0.0.1:8000/api/meetings/appointments/stats/", "url": request.build_absolute_uri("/api/meetings/appointments/stats/"),
"methods": ["GET"], "methods": ["GET"],
"authentication": "Required (Staff users only)", "authentication": "Required (Staff users only)",
"response_fields": { "response_fields": {