openapi: 3.0.2
paths:

  /app/teachers/payments:
    post:
      summary: Request a payment of a class
      tags:
        - Teachers
        - Payments

      security:
        - teacherAuthToken: []

      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentResponse'

      responses:
        201:
          description: Payment requested successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Payment requested successfully
                  transaction:
                    $ref: '#/components/schemas/PaymentResponse'

        400:
          $ref: '#/components/responses/BadRequest'

        401:
          $ref: '#/components/responses/Unauthorized'

        500:
          $ref: '#/components/responses/InternalServerError'

    get:
      summary: List all payments
      tags:
        - Teachers
        - Payments

      security:
        - teacherAuthToken: []

      responses:
        200:
          description: A list of payments
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PaymentResponse'

        401:
          $ref: '#/components/responses/Unauthorized'

        500:
          $ref: '#/components/responses/InternalServerError'

  /app/teachers/payments/{id}:

    get:
      summary: Find one payment by ID
      tags:
        - Teachers
        - Payments

      security:
        - teacherAuthToken: []

      parameters:
        - $ref: '#/components/parameters/IdParameter'

      responses:
        200:
          description: A single payment object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentWithBillingInfoResponse'

        400:
          $ref: '#/components/responses/BadRequest'

        401:
          $ref: '#/components/responses/Unauthorized'

        404:
          $ref: '#/components/responses/NotFoundError'

        500:
          $ref: '#/components/responses/InternalServerError'

  /app/students/payments/cardToken:
    post:
      summary: Register a new credit card and saves the token
      tags:
        - Students
        - Payments

      security:
        - studentAuthToken: []

      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCheckout'

      responses:
        201:
          description: Card registered successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Card registered successfully
                  student:
                    $ref: '#/components/schemas/StudentResponse'

        400:
          $ref: '#/components/responses/BadRequest'

        401:
          $ref: '#/components/responses/Unauthorized'

        500:
          $ref: '#/components/responses/InternalServerError'

  /app/students/payments/checkout:
    post:
      summary: Request a payment of a class with checkout
      tags:
        - Students
        - Payments

      security:
        - studentAuthToken: []

      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCheckout'

      responses:
        201:
          description: Checkout created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Checkout created successfully
                  link:
                    type: string
                    format: uri
                    description: Link to checkout
                    example: "https://api.example.com/checkoutSession/show/123456"

        400:
          $ref: '#/components/responses/BadRequest'

        401:
          $ref: '#/components/responses/Unauthorized'

        500:
          $ref: '#/components/responses/InternalServerError'

  /app/students/payments:
    post:
      summary: Request a payment of a class
      description:
        To make a payment via Pix or Boleto, it's not necessary to send card details.
        You can pay by card, either by directly entering the details (they will not be saved) or by saving a card and then using its token.
      tags:
        - Students
        - Payments

      security:
        - studentAuthToken: []

      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePayment'

      responses:
        201:
          description: Transaction created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Transaction created successfully
                  transaction:
                    $ref: '#/components/schemas/PaymentResponse'

        400:
          $ref: '#/components/responses/BadRequest'

        401:
          $ref: '#/components/responses/Unauthorized'

        500:
          $ref: '#/components/responses/InternalServerError'

    get:
      summary: List all payments
      tags:
        - Students
        - Payments

      security:
        - studentAuthToken: []

      responses:
        200:
          description: A list of payments
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PaymentResponse'

        401:
          $ref: '#/components/responses/Unauthorized'

        500:
          $ref: '#/components/responses/InternalServerError'

  /app/students/payments/{id}:

    get:
      summary: Find one payment by ID
      tags:
        - Students
        - Payments

      security:
        - studentAuthToken: []

      parameters:
        - $ref: '#/components/parameters/IdParameter'

      responses:
        200:
          description: A single payment object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentWithBillingInfoResponse'

        400:
          $ref: '#/components/responses/BadRequest'

        401:
          $ref: '#/components/responses/Unauthorized'

        404:
          $ref: '#/components/responses/NotFoundError'

        500:
          $ref: '#/components/responses/InternalServerError'

  /admin/users/payments:
    get:
      summary: List all payments
      tags:
        - Users
        - Payments

      security:
        - userAdminAuthToken: []

      responses:
        200:
          description: A list of payments
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PaymentResponse'

        401:
          $ref: '#/components/responses/Unauthorized'

        500:
          $ref: '#/components/responses/InternalServerError'

  /admin/users/payments/{id}:

    get:
      summary: Find one payment by ID
      tags:
        - Users
        - Payments

      security:
        - userAdminAuthToken: []

      parameters:
        - $ref: '#/components/parameters/IdParameter'

      responses:
        200:
          description: A single payment object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentWithBillingInfoResponse'

        400:
          $ref: '#/components/responses/BadRequest'

        401:
          $ref: '#/components/responses/Unauthorized'

        404:
          $ref: '#/components/responses/NotFoundError'

        500:
          $ref: '#/components/responses/InternalServerError'