Skip to content

Latest commit

 

History

History
415 lines (360 loc) · 7.94 KB

File metadata and controls

415 lines (360 loc) · 7.94 KB

EventManagement Project API Documentation


1. Health Check API

  • Endpoint: /api/entrysystem/health_check/
  • Method: GET
  • Permission: None
  • Description: Verifies if the API service is running.
  • Response:
    • Success:
      {
        "message": "API is running"
      }

2. User Registration API

  • Endpoint: /api/entrysystem/register/
  • Method: POST
  • Description: Allows a new user to register by providing email and Firebase UID.
  • Request Body:
    {
      "email": "student@example.com",
      "firebaseUID": "uniqueFirebaseUID123",
      "profileDetails": {
        "name": "John Doe",
        "college": "ABC University",
        "phoneNumber": "1234567890",
        "imageURL": "http://example.com/image.jpg",
        "collegeID": "COL12345",
        "collegeIdUrl": "http://example.com/college-id.jpg"
      },
      "paymentStatus": true
    }
  • Response:
    • Success:
      {
        "message": "User created successfully",
        "_id": "USER_MONGO_ID"
      }
    • Error:
      {
        "error": "User already exists"
      }
    • Validation Error:
      {
        "email": ["This field is required."]
      }

2. User Login API

  • Endpoint: /api/entrysystem/login/
  • Method: POST
  • Description: Authenticates the user by verifying email and Firebase UID, and returns JWT tokens.
  • Request Body:
    {
      "email": "user@example.com",
      "firebaseUID": "UID1234567890"
    }
  • Response:
    • Success:
      {
        "refresh": "REFRESH_TOKEN",
        "access": "ACCESS_TOKEN",
        "message": "Login successful"
      }
    • Error:
      {
        "error": "Invalid credentials"
      }
    • Validation Error:
      {
        "error": "Email and Firebase UID are required"
      }

3. Payment Processing API

  • Endpoint: /api/entrysystem/payments/
  • Method: POST
  • Permission: IsAuthenticated
  • Description: Handles payment processing and updates the user's payment status.
  • Request Body:
    {
      "status": "Completed",
      "amount": 100
    }
  • Response:
    • Success:
      {
        "message": "Payment successfully processed"
      }
    • Error:
      {
        "error": "User not found"
      }
    • Payment Status Error:
      {
        "error": "Invalid payment status"
      }

4. Check JWT Token API

  • Endpoint: /api/entrysystem/check_jwt/
  • Method: GET
  • Permission: IsAuthenticated
  • Description: Returns the user details based on the authenticated JWT token.
  • Response:
    {
      "user_id": "USER_MONGO_ID",
      "email": "user@example.com",
      "name": "User Name"
    }

5. User Profile API

  • Endpoint: /api/entrysystem/profile/
  • Method: GET
  • Permission: IsAuthenticated
  • Description: Fetches the full profile details of the logged-in user.
  • Response:
    {
      "_id": "USER_MONGO_ID",
      "email": "user@example.com",
      "firebaseUID": "UID1234567890",
      "profileDetails": {
        "name": "User Name",
        "college": "Some College",
        "phoneNumber": "+91 9876543210",
        "imageURL": "https://example.com/profile.jpg"
      },
      "paymentStatus": true,
      "created_at": "2024-10-12T14:53:03.917Z",
      "updated_at": "2024-10-12T14:53:03.917Z"
    }
  • Error:
    {
      "error": "User not found"
    }

6. Profile Completeness Check API

  • Endpoint: /api/entrysystem/profile_checker/
  • Method: GET
  • Permission: IsAuthenticated
  • Description: Checks whether the user's profile is complete by verifying essential fields (email, name, phone number, and image URL).
  • Response:
    • Complete Profile:
      {
        "success": true
      }
    • Incomplete Profile:
      {
        "success": false,
        "missing_fields": [
          "profileDetails.phoneNumber",
          "profileDetails.imageURL"
        ]
      }
    • Error:
      {
        "success": false,
        "error": "User not found"
      }

7. Profile Completeness Check API

  • Endpoint: /api/entrysystem/health_check/
  • Method: GET
  • Permission: None
  • Description: Checks the health of the API.
  • Response:
    • Complete Profile:
      {
        "message": "API is running"
      }

8. QR Validation API

  • Endpoint: /api/entrysystem/validate_qr/

  • Method: POST

  • Description: Validates a QR code for entry or exit, and checks the current entry status of the user associated with the QR code.

  • Request Body:

    {
      "qr_code": "670a1b65847c0d3f9c57b70c",
      "mode": "entry" // or "exit"
    }
  • Response Examples:

  1. Successful Entry Approval:

    {
      "success": true,
      "message": "Entry approved",
      "data": {
        "name": "Ankita Sharma",
        "vip": true
      }
    }
  2. Successful Exit Approval:

    {
      "success": true,
      "message": "Exit approved",
      "data": {
        "name": "Ankita Sharma",
        "vip": true
      }
    }
  3. Duplicate Entry (if user is already inside):

    {
      "success": false,
      "message": "Duplicate entry detected"
    }
  4. Duplicate Exit (if user is already outside):

    {
      "success": false,
      "message": "Duplicate exit detected"
    }
  5. Invalid QR Code:

    {
      "success": false,
      "message": "QR code not found"
    }
  6. Invalid Mode:

    {
      "success": false,
      "message": "Invalid mode"
    }
  7. Missing qr_code or mode in Request:

    {
      "success": false,
      "message": "qr_code and mode are required"
    }
  8. User Not Found:

    {
      "success": false,
      "message": "User not found"
    }
  9. Entry/Exit Data Not Found:

    {
      "success": false,
      "message": "Entry/Exit data not found"
    }
  10. Internal Server Error:

    {
      "success": false,
      "message": "An error occurred while processing the request"
    }

9. Entry System Analytics API

  • Endpoint: /api/entrysystem/analytics/

  • Method: GET

  • Permission: Admin

  • Description: Provides analytics data for the entry system, including the total number of users, counts of users inside campus and concert hall, and the breakdown by roles (students, VIPs, faculty), including paid students.

  • Response:

    • Successful Response:

      {
        "success": true,
        "message": "Analytics data fetched successfully",
        "data": {
          "total_users": 1000,
          "inside_campus": 500,
          "inside_concert_hall": 200,
          "students_count": 700,
          "vips_count": 50,
          "faculty_count": 150,
          "paid_students_count": 600,
          "students_inside_concert_hall": 150,
          "vips_inside_concert_hall": 30,
          "faculty_inside_concert_hall": 20
        }
      }
    • Error Response:

      {
        "success": false,
        "message": "Error message here"
      }

10. Dynamic QR Code Validation API

  • Endpoint: /api/entrysystem/validate_dynamic_qr/
  • Method: POST
  • Permission: None
  • Description: Validates a dynamic QR code for entry or exit with a number of people.
  • Request:
    • Body:
      {
        "qr_code": "dynamic-qr-code-object-id",
        "mode": "entry",
        "number": 5
      }
  • Response:
    • Entry Approved:
      {
        "success": true,
        "message": "Entry approved",
        "data": {
          "entered_ppl": 1,
          "vip": true
        }
      }
    • Duplicate Entry:
      {
        "success": false,
        "message": "Duplicate entry detected"
      }