openapi: 3.0.3
info:
  title: Predefined Messages Admin API
  version: v1.0.0
  description: |
    Endpoints administrativos para gestao da biblioteca de mensagens pre-definidas
    usada em comunicacao, email e WhatsApp no TIIX.
servers:
  - url: /adm/api
tags:
  - name: PredefinedMessages
    description: Modelos reutilizaveis de comunicacao

paths:
  /PredefinedMessages/list:
    post:
      tags: [PredefinedMessages]
      summary: Listar modelos
      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
                id_contrato:
                  type: integer
                  example: 57
                tipo:
                  type: string
                  example: texto
                q:
                  type: string
                  example: reativacao
      responses:
        "200":
          description: OK

  /PredefinedMessages/byContract:
    post:
      tags: [PredefinedMessages]
      summary: Listar modelos por contrato
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [id_contrato]
              properties:
                id_contrato:
                  type: integer
                  example: 57
                tipo:
                  type: string
                  example: texto
      responses:
        "200":
          description: OK

  /PredefinedMessages/get:
    post:
      tags: [PredefinedMessages]
      summary: Buscar modelo por id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [id]
              properties:
                id:
                  type: integer
                  example: 12
      responses:
        "200":
          description: OK
        "404":
          description: Modelo nao encontrado

  /PredefinedMessages/save:
    post:
      tags: [PredefinedMessages]
      summary: Criar ou atualizar modelo
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [id_contrato, tipo, titulo, mensagem]
              properties:
                id:
                  type: integer
                  example: 12
                id_contrato:
                  type: integer
                  example: 57
                tipo:
                  type: string
                  enum: [texto, imagem, audio, video, documento, link]
                  example: texto
                titulo:
                  type: string
                  example: Reativacao de plano
                mensagem:
                  type: string
                  example: Ola {{nome}}, seu plano pode ser reativado hoje.
                midia:
                  type: string
                  example: https://dominio.com/arquivo.pdf
      responses:
        "200":
          description: Modelo salvo

  /PredefinedMessages/delete:
    post:
      tags: [PredefinedMessages]
      summary: Excluir modelo
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [id]
              properties:
                id:
                  type: integer
                  example: 12
      responses:
        "200":
          description: Modelo removido

  /PredefinedMessages/upload:
    post:
      tags: [PredefinedMessages]
      summary: Upload de midia do modelo
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [id_contrato, arquivo]
              properties:
                id_contrato:
                  type: integer
                  example: 57
                arquivo:
                  type: string
                  format: binary
      responses:
        "200":
          description: Upload concluido
