openapi: 3.0.3
info:
  title: Materials Admin
  version: v1.0.0
  description: |
    Endpoints administrativos para gestão de Materiais (afl_materiais) por contrato.
servers:
  - url: /adm/api
tags:
  - name: MaterialsAdmin
paths:
  /MaterialsAdmin/list:
    post:
      tags: [MaterialsAdmin]
      summary: Listagem server-side (DataTables)
      description: |
        Retorna dados no formato esperado pelo DataTables server-side:
        draw, recordsTotal, recordsFiltered, data[].
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                draw: { type: integer, example: 1 }
                start: { type: integer, example: 0 }
                length: { type: integer, example: 25 }
                search:
                  type: object
                  properties:
                    value: { type: string, example: "" }
                order:
                  type: array
                  items:
                    type: object
                    properties:
                      column: { type: integer, example: 1 }
                      dir: { type: string, example: "desc" }
                contrato: { type: integer, example: 38 }
                q: { type: string, example: "" }
                tipo: { type: string, example: "banner" }
                status:
                  oneOf:
                    - type: string
                    - type: integer
                  example: "1"
                data_ini: { type: string, example: "2026-03-01" }
                data_fim: { type: string, example: "2026-03-31" }
      responses:
        "200":
          description: OK
  /MaterialsAdmin/get:
    post:
      tags: [MaterialsAdmin]
      summary: Carrega 1 material
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id: { type: integer, example: 10 }
      responses:
        "200":
          description: OK
  /MaterialsAdmin/save:
    post:
      tags: [MaterialsAdmin]
      summary: Cria/edita material
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id: { type: integer, example: 0 }
                contrato: { type: integer, example: 38 }
                titulo: { type: string, example: "Banner X" }
                descricao: { type: string, example: "<p>conteúdo</p>" }
                tipo: { type: string, example: "banner" }
                status: { type: integer, example: 1 }
                url: { type: string, example: "https://..." }
                media: { type: string, example: "https://..." }
                ordem: { type: integer, example: 1 }
      responses:
        "200":
          description: OK
  /MaterialsAdmin/delete:
    post:
      tags: [MaterialsAdmin]
      summary: Exclui 1 material
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id: { type: integer, example: 10 }
      responses:
        "200":
          description: OK
  /MaterialsAdmin/batch_activate:
    post:
      tags: [MaterialsAdmin]
      summary: Ativa em lote
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                ids:
                  type: array
                  items: { type: integer }
                  example: [9, 10, 11]
      responses:
        "200":
          description: OK
  /MaterialsAdmin/batch_deactivate:
    post:
      tags: [MaterialsAdmin]
      summary: Desativa em lote
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                ids:
                  type: array
                  items: { type: integer }
                  example: [9, 10, 11]
      responses:
        "200":
          description: OK
  /MaterialsAdmin/batch_delete:
    post:
      tags: [MaterialsAdmin]
      summary: Exclui em lote
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                ids:
                  type: array
                  items: { type: integer }
                  example: [9, 10, 11]
      responses:
        "200":
          description: OK