openapi: 3.0.3

info:
  version: "2.0"
  title: CF 2022
  description: CF 2022
  license:
    name: Artistic License 2.0
    url: https://www.perlfoundation.org/artistic-license-20.html
  contact:
    name: Andrej Ramašeuski
    email: andrej.ramaseuski@pirati.cz
    url: https://pardubicky.pirati.cz/lide/andrej-ramaseuski/

servers:
    - url: https://cf2022.pirati.cz/api
      description: Production server
    - url: https://cf2022.pir-test.eu/api
      description: Developement server
    - url: http://127.0.0.1:3000/api
      description: Local server

components:
  schemas:
    Question:
      type: object
      properties:
        id:
          type: integer
        question:
          type: string
        help:
          type: string
    Response:
      type: object
      properties:
        question_id:
          type: integer
        response:
          type: string
    Variation:
      type: object
      properties:
        id:
          type: integer
        value:
          type: string
        price:
          type: integer
    Product:
      type: object
      properties:
        id:
          type: integer
        category_id:
          type: integer
        name:
          type: string
        description:
          type: string
        variations:
          type: array
          items:
             $ref: '#/components/schemas/Variation'
        price:
          type: integer
        free_price:
          type: boolean
    ProductOrder:
      type: object
      properties:
        id:
         type: integer
        variation:
          type: integer
        price:
          type: integer

paths:
  /questions:
    get:
      x-mojo-to: questions#list
      tags:
        - options
      summary: "Questions"
      operationId: getQuestions
      responses:
        200:
          description: Questions list
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Question'
  /products:
    get:
      x-mojo-to: products#list
      tags:
        - options
      summary: "Products"
      operationId: getProducts
      responses:
        200:
          description: Products list
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Product'


  /orders:
    post:
      x-mojo-to: orders#create
      tags:
        - orders
      summary: "Vytvorit registraci"
      operationId: createOrder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                token:
                  type: string
                name:
                  type: string
                  maxLength: 128
                  example: 'Ivan Bartoš'
                email:
                  type: string
                  maxLength: 128
                  example: 'ivan.bartos@pirati.cz'
                organization:
                  type: string
                  example: 'ČTK'
                products:
                  type: array
                  items:
                    $ref: '#/components/schemas/ProductOrder'
                responses:
                  type: array
                  items:
                    $ref: '#/components/schemas/Response'
                  example:
                    - question_id: 1
                      response: XXXXX
                    - question_id: 2
                      response: ZZZZZ
      responses:
        201:
          description: Order created
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                    description: Tickets url

  /orders/exists:
    get:
      x-mojo-to: orders#exists
      tags:
        - order
      summary: "Existence objednavky"
      operationId: checkOrder
      parameters:
      - name: key
        in: query
        required: true
        example: andrej.ramaseuski@pirati.cz
        description: "Email nebo SSO UUID"
        schema:
          type: string
      responses:
        200:
          description: Stav
          content:
            application/json:
              schema:
                type: object
                properties:
                  exists:
                    type: boolean

  /orders/detail:
    get:
      x-mojo-to: orders#get
      tags:
        - order
      summary: "Objednavka"
      operationId: getOrder
      parameters:
      - name: "X-Token"
        in: header
        required: true
        description: "SSO Token"
        schema:
          type: string
      responses:
        200:
          description: Objednavka
          content:
            application/json:
              schema:
                type: object

  /orders/{id}/payment/:
    get:
      x-mojo-to: orders#payment
      tags:
        - order
      summary: "Info o platbe"
      operationId: getOrderPayment
      parameters:
      - name: "id"
        in: path
        required: true
        description: "ID nebo Pretix ID"
        schema:
          type: string
      responses:
        200:
          description: Informace o platbe
          content:
            application/json:
              schema:
                type: object
