{
  "openapi": "3.1.0",
  "info": {
    "title": "Comunidesk API — Configuración del edificio",
    "version": "1.0.0",
    "description": "Parámetros de cobro, mora, notificaciones, firma y reglas del edificio."
  },
  "servers": [
    {
      "url": "https://gateway.comunidesk.com",
      "description": "Gateway producción"
    }
  ],
  "tags": [
    {
      "name": "configuracion-edificio",
      "description": "Configuración del edificio — Parámetros de cobro, mora, notificaciones, firma y reglas del edificio."
    }
  ],
  "paths": {
    "/v1/rest/ConfiguracionEdificio": {
      "get": {
        "tags": [
          "configuracion-edificio"
        ],
        "operationId": "listConfiguracionEdificio",
        "summary": "Listar Configuración del edificio",
        "description": "Parámetros de cobro, mora, notificaciones, firma y reglas del edificio.",
        "security": [
          {
            "OAuth2App": [],
            "ComunideskUser": []
          }
        ],
        "parameters": [
          {
            "name": "edificioId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Contexto de edificio (requerido en la mayoría de módulos)."
          },
          {
            "name": "$filter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Filtro OData, p.ej. edificioId eq 'abc'"
          },
          {
            "name": "$top",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "$skip",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ConfiguracionEdificio"
                      }
                    },
                    "count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Token inválido"
          },
          "403": {
            "description": "Sin permiso"
          }
        }
      },
      "post": {
        "tags": [
          "configuracion-edificio"
        ],
        "operationId": "createConfiguracionEdificio",
        "summary": "Crear Configuración del edificio",
        "security": [
          {
            "OAuth2App": [],
            "ComunideskUser": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConfiguracionEdificio"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Creado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConfiguracionEdificio"
                }
              }
            }
          },
          "403": {
            "description": "Sin permiso"
          },
          "422": {
            "description": "Contrato inválido"
          }
        }
      }
    },
    "/v1/rest/ConfiguracionEdificio/{id}": {
      "get": {
        "tags": [
          "configuracion-edificio"
        ],
        "operationId": "getConfiguracionEdificio",
        "summary": "Obtener Configuración del edificio",
        "security": [
          {
            "OAuth2App": [],
            "ComunideskUser": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "edificioId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Contexto de edificio (requerido en la mayoría de módulos)."
          },
          {
            "name": "$filter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Filtro OData, p.ej. edificioId eq 'abc'"
          },
          {
            "name": "$top",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "$skip",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ConfiguracionEdificio"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No encontrado"
          }
        }
      },
      "patch": {
        "tags": [
          "configuracion-edificio"
        ],
        "operationId": "updateConfiguracionEdificio",
        "summary": "Actualizar Configuración del edificio",
        "security": [
          {
            "OAuth2App": [],
            "ComunideskUser": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConfiguracionEdificio"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Actualizado"
          },
          "403": {
            "description": "Sin permiso"
          },
          "422": {
            "description": "Contrato inválido"
          }
        }
      },
      "delete": {
        "tags": [
          "configuracion-edificio"
        ],
        "operationId": "deleteConfiguracionEdificio",
        "summary": "Eliminar Configuración del edificio",
        "security": [
          {
            "OAuth2App": [],
            "ComunideskUser": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "edificioId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Eliminado"
          },
          "403": {
            "description": "Sin permiso"
          },
          "404": {
            "description": "No encontrado"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "OAuth2App": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Access token OAuth2 de tu aplicación."
      },
      "ComunideskUser": {
        "type": "apiKey",
        "in": "header",
        "name": "x-comunidesk-user-authorization",
        "description": "Bearer <JWT de la cuenta Comunidesk del usuario>."
      }
    },
    "schemas": {
      "ConfiguracionEdificio": {
        "type": "object",
        "description": "Parámetros de cobro, mora, notificaciones, firma y reglas del edificio.",
        "properties": {
          "_id": {
            "type": "string"
          },
          "_rev": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "const": "configuracion_edificio"
          },
          "edificioId": {
            "type": "string"
          },
          "pais": {
            "type": "string"
          },
          "jurisdiccion": {
            "type": "string"
          },
          "estado": {
            "type": "string"
          },
          "provincia": {
            "type": "string"
          },
          "geo": {
            "type": "object",
            "additionalProperties": true
          },
          "diaGeneracionGastos": {
            "type": "number"
          },
          "diaEmisionGastos": {
            "type": "number"
          },
          "diaCobroGastosComunes": {
            "type": "number"
          },
          "diaVencimiento": {
            "type": "number"
          },
          "moneda": {
            "type": "string"
          },
          "monedaProveedores": {
            "type": "string"
          },
          "valorUFActual": {
            "type": "number"
          },
          "valoresUF": {
            "type": "array",
            "items": {}
          },
          "porcentajeMora": {
            "type": "number"
          },
          "porcentajeMulta": {
            "type": "number"
          },
          "diasGraciaMora": {
            "type": "number"
          },
          "diasGracia": {
            "type": "number"
          },
          "permitirPagoOnline": {
            "type": "boolean"
          },
          "notificacionesEmail": {
            "type": "boolean"
          },
          "notificacionesSMS": {
            "type": "boolean"
          },
          "informacionBancaria": {
            "type": "string"
          },
          "intereses": {
            "type": "object",
            "additionalProperties": true
          },
          "fondoReserva": {
            "type": "object",
            "additionalProperties": true
          },
          "fondosEspeciales": {
            "type": "array",
            "items": {}
          },
          "torreSeguros": {
            "type": "object",
            "additionalProperties": true
          },
          "seguroColectivo": {
            "type": "object",
            "additionalProperties": true
          },
          "datosBancarios": {
            "type": "object",
            "additionalProperties": true
          },
          "administrador": {
            "type": "object",
            "additionalProperties": true
          },
          "firmaOficial": {
            "type": "object",
            "additionalProperties": true
          },
          "firmaDigital": {
            "type": "object",
            "additionalProperties": true
          },
          "pagoOnline": {
            "type": "object",
            "additionalProperties": true
          },
          "recordatoriosConsumos": {
            "type": "object",
            "additionalProperties": true
          },
          "tarifasServicios": {
            "type": "object",
            "additionalProperties": true
          },
          "configuracionTickets": {
            "type": "object",
            "additionalProperties": true
          },
          "configuracionMedidores": {
            "type": "object",
            "additionalProperties": true
          },
          "configuracionSMS": {
            "type": "object",
            "additionalProperties": true
          },
          "createdAt": {
            "type": "string",
            "readOnly": true
          },
          "updatedAt": {
            "type": "string",
            "readOnly": true
          }
        },
        "required": [
          "edificioId"
        ]
      },
      "OAuthScopes": {
        "type": "string",
        "enum": [
          "comunidesk:read",
          "comunidesk:write",
          "files:pdf",
          "files:excel",
          "ai:models",
          "ai:chat",
          "ai:extract",
          "ai:web",
          "flex-pro:manage",
          "flex-pro:runtime",
          "flex-pro:marketplace"
        ],
        "description": "Scopes OAuth soportados por el gateway."
      }
    }
  },
  "security": [
    {
      "OAuth2App": [],
      "ComunideskUser": []
    }
  ]
}