openapi: 3.0.3
info:
  title: NammaRyduu
  version: 1.0.11

servers:
  - url: https://swaggerapi.nammaryduu.co.in/NAMMARYDUUAPI

tags:
  - name: Login
  - name: Signup

paths:
  /login.php:
    post:
      tags:
        - Login
      summary: Mobile Login
      description: Authenticates a user and generates a JWT token upon successful login.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                mobile:
                  type: string
                  example: "1234567890"
                password:
                  type: string
                  example: "password123"
              required:
                - mobile
                - password
      responses:
        '200':
          description: Successful login
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponse'
        '400':
          description: Bad request due to missing or invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Invalid credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '405':
          description: Method not allowed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

  /signup.php:
    post:
      tags:
        - Signup
      summary: User Signup
      description: Creates a new user account with the provided details, including image uploads.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                user_type:
                  type: string
                  example: "Driver"
                user_name:
                  type: string
                  example: "John Doe"
                license_no:
                  type: string
                  example: "DL123456789"
                mobile:
                  type: string
                  example: "1234567890"
                password:
                  type: string
                  example: "password123"
                confirm_password:
                  type: string
                  example: "password123"
                vehicle:
                  type: string
                  example: "Toyota"
                vehicle_type:
                  type: string
                  example: "Sedan"
                dl_image_front:
                  type: string
                  format: binary
                  description: Front image of driver's license
                dl_image_back:
                  type: string
                  format: binary
                  description: Back image of driver's license
              required:
                - user_type
                - user_name
                - license_no
                - mobile
                - password
                - confirm_password
                - vehicle
                - vehicle_type
                - dl_image_front
                - dl_image_back
      responses:
        '201':
          description: Account created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponse'
        '400':
          description: Bad request due to missing or invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: Conflict error if the user already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'

components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          example: "error"
        message:
          type: string
          example: "Invalid request or user already exists."
    SuccessResponse:
      type: object
      properties:
        status:
          type: string
          example: "success"
        message:
          type: string
          example: "Account created successfully."
    TokenResponse:
      type: object
      properties:
        status:
          type: string
          example: "success"
        token:
          type: string
          example: "token"

  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Please enter a valid token

security:
  - BearerAuth: []
