openapi: 3.0.0
info:
  title: Support Tickets API
  description: API for creating and managing customer support tickets
  version: 1.0.0
  contact:
    name: Support Team
    url: https://ibm-wx-tools.egodev1.info

servers:
  - url: https://ibm-wx-tools.egodev1.info
    description: Production server
  - url: http://localhost
    description: Development server

paths:
  /report.php:
    post:
      summary: Create a new support ticket
      description: Creates a new support ticket with information about customer issue
      operationId: createSupportTicket
      tags:
        - Tickets
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTicketRequest'
            examples:
              high_priority:
                summary: High priority ticket
                value:
                  customer_email: "customer@example.com"
                  issue_description: "Order ORD-12345 has not arrived, it has been a week"
                  priority: "high"
              critical:
                summary: Critical ticket
                value:
                  customer_email: "vip@example.com"
                  issue_description: "Urgent! Refund for order ORD-54321 has not been received for a month"
                  priority: "critical"

      responses:
        '201':
          description: Ticket created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: "Ticket created successfully"
                  data:
                    $ref: '#/components/schemas/Ticket'
                  timestamp:
                    type: string
                    format: date-time
                    example: "2025-11-28 16:45:32"

        '400':
          description: Input parameter validation error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  errors:
                    type: array
                    items:
                      type: string
                    example:
                      - "Parameter customer_email is required"
                      - "Parameter issue_description is required"
                  code:
                    type: string
                    example: "VALIDATION_ERROR"

        '405':
          description: Method not allowed
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: "Method not allowed"
                  supported_methods:
                    type: array
                    items:
                      type: string
                    example: ["GET", "POST"]
                  code:
                    type: string
                    example: "METHOD_NOT_ALLOWED"

        '500':
          description: Server error when saving ticket
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    example: "Failed to save ticket"
                  code:
                    type: string
                    example: "STORAGE_ERROR"

    get:
      summary: Get list of all tickets
      description: Returns list of all created support tickets
      operationId: listSupportTickets
      tags:
        - Tickets
      responses:
        '200':
          description: Tickets list retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  total_tickets:
                    type: integer
                    example: 5
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Ticket'
                  timestamp:
                    type: string
                    format: date-time
                    example: "2025-11-28 16:50:00"

components:
  schemas:
    CreateTicketRequest:
      type: object
      required:
        - customer_email
        - issue_description
        - priority
      properties:
        customer_email:
          type: string
          format: email
          description: Customer email address
          example: "customer@example.com"
        issue_description:
          type: string
          minLength: 5
          maxLength: 500
          description: Problem description (minimum 5 characters)
          example: "Order has not arrived in a week, I don't know what to do"
        priority:
          type: string
          enum: [low, medium, high, critical]
          description: Ticket priority
          example: "high"

    Ticket:
      type: object
      required:
        - ticket_id
        - customer_email
        - issue_description
        - priority
        - status
        - created_at
      properties:
        ticket_id:
          type: string
          description: Unique ticket identifier
          example: "TK-A1B2C3D4"
        customer_email:
          type: string
          format: email
          description: Customer email address
          example: "customer@example.com"
        issue_description:
          type: string
          description: Problem description
          example: "Order has not arrived in a week"
        priority:
          type: string
          enum: [low, medium, high, critical]
          description: Ticket priority
          example: "high"
        status:
          type: string
          enum: [open, in_progress, closed, on_hold]
          description: Ticket status
          example: "open"
        created_at:
          type: string
          format: date-time
          description: Ticket creation time
          example: "2025-11-28 16:45:32"
        updated_at:
          type: string
          format: date-time
          description: Last update time
          example: "2025-11-28 16:45:32"
        notes:
          type: string
          description: Notes about the ticket
          example: "Ticket created through API"

tags:
  - name: Tickets
    description: API for managing support tickets
