openapi: 3.0.3
info:
  title: Ticket Booking System API
  version: 1.0.0
  description: |
    OpenAPI specification generated from the provided Postman collection.
    Includes variables and example payloads mirrored from the collection.
servers:
  - url: "{BACKEND_URL}"
    description: Base server URL
    variables:
      BACKEND_URL:
        default: http://localhost:9000
        description: Value comes from the Postman variable {{BACKEND_URL}}.
tags:
  - name: Admin
  - name: Store
  - name: Tickets
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    publishableApiKey:
      type: apiKey
      in: header
      name: x-publishable-api-key
  schemas:
    LoginRequest:
      type: object
      properties:
        email:
          type: string
          format: email
          example: admin@gmail.com
        password:
          type: string
          format: password
          example: supersecret
      required: [email, password]
    TicketProductCreate:
      type: object
      properties:
        name:
          type: string
          example: Hamilton
        venue_id:
          type: string
          description: ID of the venue where the show is hosted.
        dates:
          type: array
          items:
            type: string
            format: date
          example: ["2025-11-01", "2025-11-02"]
        variants:
          type: array
          items:
            $ref: "#/components/schemas/TicketVariantCreate"
      required: [name, venue_id, dates, variants]
    TicketVariantCreate:
      type: object
      properties:
        row_type:
          type: string
          example: vip
        seat_count:
          type: integer
          example: 10
        prices:
          type: array
          items:
            $ref: "#/components/schemas/Price"
      required: [row_type, seat_count, prices]
    Price:
      type: object
      properties:
        currency_code:
          type: string
          example: eur
        amount:
          type: number
          example: 150
      required: [currency_code, amount]
    VenueCreate:
      type: object
      properties:
        name:
          type: string
          example: Theater
        address:
          type: string
          example: ""
        rows:
          type: array
          items:
            $ref: "#/components/schemas/VenueRowCreate"
      required: [name, rows]
    VenueRowCreate:
      type: object
      properties:
        row_number:
          type: string
          example: A
        row_type:
          type: string
          example: vip
        seat_count:
          type: integer
          example: 10
      required: [row_number, row_type, seat_count]
    GenericResponse:
      type: object
      description: Generic success response (schema not defined in collection).
      additionalProperties: true
    Error:
      type: object
      properties:
        message:
          type: string
paths:
  /auth/user/emailpass:
    post:
      tags: [Admin]
      summary: Login
      description: Login using email and password.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LoginRequest"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GenericResponse"
  /admin/ticket-products:
    get:
      tags: [Admin]
      summary: Get Ticket Products
      security:
        - bearerAuth: []
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GenericResponse"
    post:
      tags: [Admin]
      summary: Create Ticket Product
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TicketProductCreate"
            example:
              name: Hamilton
              venue_id: ""
              dates: ["2025-11-01", "2025-11-02"]
              variants:
                - row_type: vip
                  seat_count: 10
                  prices:
                    - currency_code: eur
                      amount: 150
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GenericResponse"
  /admin/venues:
    get:
      tags: [Admin]
      summary: Get Venues
      security:
        - bearerAuth: []
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GenericResponse"
    post:
      tags: [Admin]
      summary: Create Venue
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/VenueCreate"
            example:
              name: Theater
              address: ""
              rows:
                - row_number: A
                  row_type: vip
                  seat_count: 10
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GenericResponse"
  /store/carts/{id}/complete-tickets:
    post:
      tags: [Store]
      summary: Complete Cart with Ticket Product
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GenericResponse"
  /store/ticket-products/{id}/availability:
    get:
      tags: [Store]
      summary: Check Date Availabilities for Product
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GenericResponse"
  /store/ticket-products/{id}/seats:
    get:
      tags: [Store]
      summary: Check seat availabilities for Product
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GenericResponse"
  /tickets/{ticket_purchase_id}/verify:
    get:
      tags: [Tickets]
      summary: Verify Ticket After Scanning with QR Code
      parameters:
        - name: ticket_purchase_id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/GenericResponse"
x-variables:
  # These mirror Postman variables for reference.
  BACKEND_URL: "{BACKEND_URL}"
  MEDUSA_PUBLISHABLE_API_KEY: ""
  ADMIN_AUTH_TOKEN: ""