{
    "openapi": "3.0.0",
    "info": {
        "title": "Casafrique API",
        "description": "Casafrique Application API Documentation",
        "contact": {
            "email": "support@casafrique.com"
        },
        "version": "1.0.0"
    },
    "servers": [
        {
            "url": "https://appp.cryprtorq.com.ng/public/api",
            "description": "Production API Server"
        },
        {
            "url": "http://127.0.0.1:8000/api",
            "description": "Local API Server"
        }
    ],
    "paths": {
        "/hello": {
            "get": {
                "tags": ["Test"],
                "summary": "Hello World API",
                "description": "Returns a Hello World message",
                "operationId": "7dc5d2524c671257eb34a2447eab8e9f",
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "example": "Casafrique Api Live 🚀"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/up": {
            "get": {
                "tags": ["Test"],
                "summary": "Health check",
                "description": "Checks if the API is running",
                "operationId": "healthCheck",
                "responses": {
                    "200": {
                        "description": "API is healthy",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "ok"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/auth/register": {
            "post": {
                "tags": ["Auth"],
                "summary": "Register a new user",
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "first_name",
                                    "last_name",
                                    "email",
                                    "username",
                                    "password",
                                    "password_confirmation",
                                    "phone",
                                    "role_id"
                                ],
                                "properties": {
                                    "first_name": {
                                        "type": "string",
                                        "example": "Patrick"
                                    },
                                    "last_name": {
                                        "type": "string",
                                        "example": "Sanni"
                                    },
                                    "username": {
                                        "type": "string",
                                        "example": "john"
                                    },
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "example": "user@example.com"
                                    },
                                    "phone": {
                                        "type": "string",
                                        "example": "08012345678"
                                    },
                                    "role_id": {
                                        "type": "integer",
                                        "enum": [3, 4, 5, 6],
                                        "example": 3
                                    },
                                    "bvn": {
                                        "type": "string",
                                        "example": "12345678901"
                                    },
                                    "nin": {
                                        "type": "string",
                                        "example": "12345678901"
                                    },
                                    "gender": {
                                        "type": "string",
                                        "enum": ["male", "female", "other"],
                                        "example": "male"
                                    },
                                    "address": {
                                        "type": "string",
                                        "example": "123 Main Street"
                                    },
                                    "state": {
                                        "type": "string",
                                        "example": "Lagos"
                                    },
                                    "country": {
                                        "type": "string",
                                        "example": "Nigeria"
                                    },
                                    "password": {
                                        "type": "string",
                                        "format": "password",
                                        "example": "password123"
                                    },
                                    "password_confirmation": {
                                        "type": "string",
                                        "format": "password",
                                        "example": "password123"
                                    },
                                    "profile_picture": {
                                        "type": "string",
                                        "format": "binary"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "User registered successfully"
                    },
                    "422": {
                        "description": "Validation error"
                    },
                    "429": {
                        "description": "Too many OTP requests"
                    },
                    "500": {
                        "description": "Server error"
                    }
                }
            }
        },

        "/auth/loginold": {
            "post": {
                "tags": ["Auth"],
                "summary": "Login user",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": ["email", "password"],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "example": "tenant@casafrique.com.ng"
                                    },
                                    "password": {
                                        "type": "string",
                                        "example": "password123"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "JWT token returned"
                    },
                    "401": {
                        "description": "Unauthorized"
                    }
                }
            }
        },
        "/auth/login": {
            "post": {
                "tags": ["Auth"],
                "summary": "Login user",
                "description": "Authenticate user and return JWT token",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": ["email", "password"],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "example": "test@gmail.com"
                                    },
                                    "password": {
                                        "type": "string",
                                        "format": "password",
                                        "example": "password123"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Login successful"
                    },
                    "401": {
                        "description": "Unauthorized"
                    },
                    "403": {
                        "description": "Email not verified"
                    },
                    "422": {
                        "description": "Validation error"
                    },
                    "429": {
                        "description": "Too many login attempts"
                    }
                }
            }
        },

        "/auth/verify-otp": {
            "post": {
                "tags": ["Auth"],
                "summary": "Verify email OTP",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": ["email", "otp"],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "example": "user@example.com"
                                    },
                                    "otp": {
                                        "type": "string",
                                        "example": "123456"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Email verified successfully"
                    },
                    "400": {
                        "description": "Invalid or expired OTP"
                    },
                    "429": {
                        "description": "Too many attempts"
                    }
                }
            }
        },
        "/auth/resend-otp": {
            "post": {
                "tags": ["Auth"],
                "summary": "Resend OTP to email",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": ["email"],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "example": "user@example.com"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OTP resent successfully"
                    },
                    "404": {
                        "description": "User not found"
                    },
                    "429": {
                        "description": "Too many attempts"
                    }
                }
            }
        },
        "/auth/forgot-password": {
            "post": {
                "tags": ["Auth"],
                "summary": "Send password reset OTP",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": ["email"],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "example": "user@example.com"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "OTP sent"
                    },
                    "404": {
                        "description": "User not found"
                    }
                }
            }
        },
        "/auth/reset-password": {
            "post": {
                "tags": ["Auth"],
                "summary": "Reset password using OTP",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "email",
                                    "otp",
                                    "password",
                                    "password_confirmation"
                                ],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "example": "user@example.com"
                                    },
                                    "otp": {
                                        "type": "string",
                                        "example": "123456"
                                    },
                                    "password": {
                                        "type": "string",
                                        "format": "password",
                                        "example": "newpassword123"
                                    },
                                    "password_confirmation": {
                                        "type": "string",
                                        "format": "password",
                                        "example": "newpassword123"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Password reset successful"
                    },
                    "400": {
                        "description": "Invalid OTP"
                    },
                    "422": {
                        "description": "Validation error"
                    }
                }
            }
        },

        "/me": {
            "get": {
                "tags": ["Auth"],
                "summary": "Get current authenticated user",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": {
                        "description": "Authenticated user"
                    },
                    "401": {
                        "description": "Unauthenticated"
                    }
                }
            }
        },
        "/user/kyc/update": {
            "put": {
                "tags": ["Auth"],
                "summary": "Update user KYC information",
                "description": "Uploads and updates KYC details for landlord, lawyer, and realtor including file uploads.",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "landlord_cofo": {
                                        "type": "string",
                                        "format": "binary"
                                    },
                                    "landlord_deed_of_assignment": {
                                        "type": "string",
                                        "format": "binary"
                                    },
                                    "landlord_survey_plan": {
                                        "type": "string",
                                        "format": "binary"
                                    },
                                    "landlord_governor_consent": {
                                        "type": "string",
                                        "format": "binary"
                                    },
                                    "landlord_utility_bill": {
                                        "type": "string",
                                        "format": "binary"
                                    },
                                    "landlord_tax_id": {
                                        "type": "string"
                                    },

                                    "lawyer_certificate": {
                                        "type": "string",
                                        "format": "binary"
                                    },
                                    "lawyer_enrollment_number": {
                                        "type": "string"
                                    },
                                    "lawyer_nba_id": {
                                        "type": "string"
                                    },
                                    "lawyer_address": {
                                        "type": "string"
                                    },
                                    "lawyer_licence": {
                                        "type": "string",
                                        "format": "binary"
                                    },

                                    "realtor_cac_certificate": {
                                        "type": "string",
                                        "format": "binary"
                                    },
                                    "realtor_memart": {
                                        "type": "string",
                                        "format": "binary"
                                    },
                                    "realtor_corporate_account": {
                                        "type": "string"
                                    },
                                    "realtor_office_address": {
                                        "type": "string"
                                    },
                                    "realtor_utility_bill": {
                                        "type": "string",
                                        "format": "binary"
                                    },

                                    "realtor_directors": {
                                        "type": "array",
                                        "items": {
                                            "type": "object",
                                            "properties": {
                                                "nin": {
                                                    "type": "string"
                                                },
                                                "bvn": {
                                                    "type": "string"
                                                },
                                                "proof_of_address": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "KYC updated successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "status": {
                                            "type": "boolean",
                                            "example": true
                                        },
                                        "message": {
                                            "type": "string",
                                            "example": "KYC updated successfully"
                                        },
                                        "data": {
                                            "type": "object",
                                            "additionalProperties": true
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized"
                    },
                    "422": {
                        "description": "Validation error"
                    }
                }
            }
        },

        "/logout": {
            "post": {
                "tags": ["Auth"],
                "summary": "Logout user",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": {
                        "description": "Logged out successfully",
                        "content": {
                            "application/json": {
                                "example": {
                                    "message": "Successfully logged out"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized - invalid or missing token"
                    }
                }
            }
        },

        "/refresh": {
            "post": {
                "tags": ["Auth"],
                "summary": "Refresh JWT token",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": {
                        "description": "Token refreshed"
                    }
                }
            }
        },
        "/admin/dashboard": {
            "get": {
                "tags": ["Admin"],
                "summary": "Admin dashboard",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": { "description": "Admin dashboard data" },
                    "403": { "description": "Forbidden" }
                }
            }
        },
        "/admin/login": {
            "post": {
                "tags": ["Admin"],
                "summary": "Admin login",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "example": "superadmin@casafrique.com.ng"
                                    },
                                    "password": {
                                        "type": "string",
                                        "example": "password123"
                                    }
                                },
                                "required": ["email", "password"]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Login successful"
                    },
                    "401": {
                        "description": "Invalid credentials"
                    }
                }
            }
        },

        "/admin/forgot-password": {
            "post": {
                "tags": ["Admin"],
                "summary": "Send OTP for password reset",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "example": "superadmin@casafrique.com.ng"
                                    }
                                },
                                "required": ["email"]
                            }
                        }
                    }
                },
                "responses": {
                    "200": { "description": "OTP sent" }
                }
            }
        },

        "/admin/reset-password": {
            "post": {
                "tags": ["Admin"],
                "summary": "Reset admin password using OTP",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "example": "superadmin@casafrique.com.ng"
                                    },
                                    "otp": {
                                        "type": "string",
                                        "example": "123456"
                                    },
                                    "password": {
                                        "type": "string",
                                        "example": "newpassword"
                                    },
                                    "password_confirmation": {
                                        "type": "string",
                                        "example": "newpassword"
                                    }
                                },
                                "required": [
                                    "email",
                                    "otp",
                                    "password",
                                    "password_confirmation"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": { "description": "Password reset successful" },
                    "400": { "description": "Invalid OTP" }
                }
            }
        },

        "/admin/profile": {
            "get": {
                "tags": ["Admin"],
                "summary": "Get admin profile",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": { "description": "Admin profile" },
                    "401": { "description": "Unauthorized" }
                }
            }
        },

        "/admin/change-password": {
            "post": {
                "tags": ["Admin"],
                "summary": "Change admin password",
                "security": [{ "bearerAuth": [] }],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "old_password": { "type": "string" },
                                    "new_password": { "type": "string" },
                                    "new_password_confirmation": {
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "old_password",
                                    "new_password",
                                    "new_password_confirmation"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": { "description": "Password changed" }
                }
            }
        },

        "/admin/users": {
            "get": {
                "tags": ["Admin"],
                "summary": "Get all users",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": { "description": "List of users" }
                }
            }
        },

        "/admin/users/{id}/activate": {
            "post": {
                "tags": ["Admin"],
                "summary": "Activate user",
                "security": [{ "bearerAuth": [] }],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": { "type": "string" }
                    }
                ],
                "responses": {
                    "200": { "description": "User activated" },
                    "404": { "description": "User not found" }
                }
            }
        },

        "/admin/users/{id}/deactivate": {
            "post": {
                "tags": ["Admin"],
                "summary": "Deactivate user",
                "security": [{ "bearerAuth": [] }],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": { "type": "string" }
                    }
                ],
                "responses": {
                    "200": { "description": "User deactivated" },
                    "404": { "description": "User not found" }
                }
            }
        },
        "/admin/users/{id}/change-role": {
            "post": {
                "tags": ["Admin"],
                "summary": "Change user role",
                "security": [{ "bearerAuth": [] }],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "role_id": {
                                        "type": "integer",
                                        "example": 4,
                                        "description": "1=superadmin, 2=admin, 3=tenant, 4=agent, 5=landlord, 6=lawyer, 7=company_realtor"
                                    }
                                },
                                "required": ["role_id"]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Role updated successfully"
                    },
                    "404": {
                        "description": "User not found"
                    },
                    "422": {
                        "description": "Validation error"
                    }
                }
            }
        },
        "/user/dashboard": {
            "get": {
                "tags": ["User"],
                "summary": "User dashboard",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": { "description": "User dashboard data" },
                    "403": { "description": "Forbidden" }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "JWT"
            }
        }
    },
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "tags": [
        {
            "name": "Test",
            "description": "Test"
        }
    ]
}
