{
  "openapi": "3.1.0",
  "info": {
    "title": "Api",
    "version": "1.0.0",
    "description": "API pública e somente leitura da Infinity ISP para agentes consultarem empresa, ofertas, serviços e orientação comercial."
  },
  "servers": [
    {
      "url": "/api",
      "description": "Base API path"
    }
  ],
  "tags": [
    {
      "name": "health",
      "description": "Saúde do serviço"
    },
    {
      "name": "sales",
      "description": "Informações comerciais públicas e verificáveis"
    },
    {
      "name": "discovery",
      "description": "Descoberta do contrato OpenAPI"
    }
  ],
  "paths": {
    "/healthz": {
      "get": {
        "operationId": "healthCheck",
        "tags": [
          "health"
        ],
        "summary": "Verificar saúde da API",
        "description": "Retorna o estado operacional do serviço.",
        "responses": {
          "200": {
            "description": "Serviço saudável",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthStatus"
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApiSpec",
        "tags": [
          "discovery"
        ],
        "summary": "Obter contrato OpenAPI",
        "description": "Retorna a especificação completa usada por agentes e ferramentas de function calling.",
        "responses": {
          "200": {
            "description": "Especificação OpenAPI",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v1/company": {
      "get": {
        "operationId": "getInfinityCompany",
        "tags": [
          "sales"
        ],
        "summary": "Consultar a Infinity ISP",
        "description": "Retorna identidade, área atendida e canais oficiais da Infinity ISP.",
        "responses": {
          "200": {
            "description": "Dados públicos da empresa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Company"
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v1/offers": {
      "get": {
        "operationId": "listInfinityOffers",
        "tags": [
          "sales"
        ],
        "summary": "Listar ofertas de internet",
        "description": "Lista planos publicados. Valores e disponibilidade devem ser confirmados antes da contratação.",
        "responses": {
          "200": {
            "description": "Ofertas públicas atuais",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Offer"
                  }
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v1/offers/{offerId}": {
      "get": {
        "operationId": "getInfinityOffer",
        "tags": [
          "sales"
        ],
        "summary": "Consultar uma oferta",
        "description": "Retorna uma oferta pelo identificador estável, com preços, velocidades e benefícios publicados.",
        "parameters": [
          {
            "name": "offerId",
            "in": "path",
            "required": true,
            "description": "Identificador da oferta",
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "example": "600"
          }
        ],
        "responses": {
          "200": {
            "description": "Oferta encontrada",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Offer"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v1/services": {
      "get": {
        "operationId": "listInfinityServices",
        "tags": [
          "sales"
        ],
        "summary": "Listar serviços",
        "description": "Lista os serviços públicos apresentados pela Infinity ISP e suas páginas oficiais.",
        "responses": {
          "200": {
            "description": "Serviços públicos",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Service"
                  }
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v1/sales-guide": {
      "get": {
        "operationId": "getInfinitySalesGuide",
        "tags": [
          "sales"
        ],
        "summary": "Orientar uma recomendação comercial",
        "description": "Retorna regras de segurança, fontes e próximo passo oficial para um agente orientar interessados sem inventar cobertura ou condições.",
        "responses": {
          "200": {
            "description": "Guia comercial para agentes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesGuide"
                }
              }
            }
          },
          "405": {
            "$ref": "#/components/responses/MethodNotAllowed"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "BadRequest": {
        "description": "Parâmetro inválido",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "NotFound": {
        "description": "Recurso não encontrado",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "MethodNotAllowed": {
        "description": "Método não permitido em um recurso somente leitura",
        "headers": {
          "Allow": {
            "description": "Métodos aceitos",
            "schema": {
              "type": "string",
              "example": "GET, HEAD"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Limite de 60 solicitações por minuto excedido",
        "headers": {
          "Retry-After": {
            "description": "Segundos até nova tentativa",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "InternalError": {
        "description": "Erro interno estruturado",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      }
    },
    "schemas": {
      "HealthStatus": {
        "type": "object",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok"
            ]
          }
        }
      },
      "Company": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "description",
          "serviceArea",
          "website",
          "phone",
          "email",
          "address",
          "whatsappUrl"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "serviceArea": {
            "type": "string"
          },
          "website": {
            "type": "string",
            "format": "uri"
          },
          "phone": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "address": {
            "type": "string"
          },
          "whatsappUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Offer": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "downloadMbps",
          "uploadMbps",
          "promotionalPriceBRL",
          "regularPriceBRL",
          "noLoyaltyPriceBRL",
          "promotionMonths",
          "features",
          "featured"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "downloadMbps": {
            "type": "integer",
            "minimum": 1
          },
          "uploadMbps": {
            "type": "integer",
            "minimum": 1
          },
          "promotionalPriceBRL": {
            "type": "number",
            "minimum": 0
          },
          "regularPriceBRL": {
            "type": "number",
            "minimum": 0
          },
          "noLoyaltyPriceBRL": {
            "type": "number",
            "minimum": 0
          },
          "promotionMonths": {
            "type": "integer",
            "minimum": 0
          },
          "features": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "featured": {
            "type": "boolean"
          }
        }
      },
      "Service": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "description",
          "url"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "SalesGuide": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "rules",
          "sources",
          "contact",
          "documentation"
        ],
        "properties": {
          "rules": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "contact": {
            "$ref": "#/components/schemas/Company"
          },
          "documentation": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "ApiError": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "message",
              "resolution",
              "documentation"
            ],
            "properties": {
              "code": {
                "type": "string",
                "example": "RESOURCE_NOT_FOUND"
              },
              "message": {
                "type": "string"
              },
              "resolution": {
                "type": "string"
              },
              "documentation": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}
