{
  "openapi": "3.0.3",
  "info": {
    "title": "Optigest API Professional",
    "description": "API Integração PRO – Documentação Técnica",
    "version": "1.2"
  },
  "servers": [
    {
      "url": "https://api.example.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "AuthRequest": {
        "type": "object",
        "required": ["systemId", "clientId", "username", "password", "lifetime"],
        "properties": {
          "systemId": { "type": "integer" },
          "clientId": { "type": "integer" },
          "username": { "type": "string" },
          "password": { "type": "string" },
          "lifetime": { "type": "integer" }
        }
      },
      "AuthResponse": {
        "type": "object",
        "properties": {
          "error": { "type": "boolean" },
          "code": { "type": "integer" },
          "message": { "type": "string" },
          "data": {
            "type": "object",
            "properties": {
              "status": { "type": "string" },
              "token": { "type": "string" },
              "generated_at": { "type": "integer" },
              "expires_at": { "type": "integer" },
              "expires_in": { "type": "integer" }
            }
          }
        }
      },
      "NoteRequest": {
        "type": "object",
        "required": ["type", "text"],
        "properties": {
          "type": { "type": "string", "example": "INTERNAL" },
          "text": { "type": "string" }
        }
      },
      "PassengerRequest": {
        "type": "object",
        "required": ["name", "surname", "title", "birthdate", "type"],
        "properties": {
          "name": { "type": "string" },
          "surname": { "type": "string" },
          "title": { "type": "string" },
          "birthdate": { "type": "string", "format": "date" },
          "type": { "type": "string", "example": "ADT" }
        }
      },
      "ClientSupplierRequest": {
        "type": "object",
        "required": ["name", "address", "city", "countryRegionCode", "vatRegistrationNo", "email", "phoneNo"],
        "properties": {
          "name": { "type": "string" },
          "address": { "type": "string" },
          "city": { "type": "string" },
          "countryRegionCode": { "type": "string" },
          "vatRegistrationNo": { "type": "string" },
          "email": { "type": "string" },
          "phoneNo": { "type": "integer" }
        }
      },
      "PriceLineRequest": {
        "type": "object",
        "required": ["desc", "finantialService", "costVal", "sellVal", "quant", "supplierId"],
        "properties": {
          "desc": { "type": "string" },
          "finantialService": { "type": "string" },
          "costVal": { "type": "number" },
          "sellVal": { "type": "number" },
          "quant": { "type": "integer" },
          "supplierId": { "type": "integer" }
        }
      }
    }
  },
  "security": [
    { "BearerAuth": [] }
  ],
  "paths": {
    "/Auth/Login": {
      "post": {
        "tags": ["Auth"],
        "summary": "Autenticação",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/AuthRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token criado",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AuthResponse" }
              }
            }
          }
        }
      }
    },
    "/bookings/full": {
      "post": {
        "tags": ["Bookings"],
        "summary": "Criar reserva completa",
        "security": [{ "BearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "type": "object" }
            }
          }
        },
        "responses": {
          "200": { "description": "Reserva criada" }
        }
      }
    },
    "/financial/documents/issue/FA": {
      "post": {
        "tags": ["Financial"],
        "summary": "Faturar serviços",
        "security": [{ "BearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "type": "object" }
            }
          }
        },
        "responses": {
          "200": { "description": "Fatura criada" }
        }
      }
    },
    "/financial/documents/issue/FAD": {
      "post": {
        "tags": ["Financial"],
        "summary": "Gerar fatura de adiantamento",
        "security": [{ "BearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "type": "object" }
            }
          }
        },
        "responses": {
          "200": { "description": "Fatura de adiantamento criada" }
        }
      }
    },
    "/financial/documents/detail/booking/{reserveId}/{docType}": {
      "post": {
        "tags": ["Financial"],
        "summary": "Obter documentos financeiros",
        "parameters": [
          { "name": "reserveId", "in": "path", "required": true, "schema": { "type": "integer" } },
          { "name": "docType", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "Lista de documentos" }
        }
      }
    },
    "/bookings/{reserveId}/notes": {
      "post": {
        "tags": ["Bookings"],
        "summary": "Adicionar nota à reserva",
        "parameters": [
          { "name": "reserveId", "in": "path", "required": true, "schema": { "type": "integer" } }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/NoteRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "Nota adicionada" }
        }
      }
    },
    "/bookings/{reserveId}/passengers": {
      "post": {
        "tags": ["Bookings"],
        "summary": "Adicionar passageiro",
        "parameters": [
          { "name": "reserveId", "in": "path", "required": true, "schema": { "type": "integer" } }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/PassengerRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "Passageiro adicionado" }
        }
      }
    },
    "/clients": {
      "post": {
        "tags": ["Clients"],
        "summary": "Adicionar cliente",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ClientSupplierRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "Cliente criado" }
        }
      }
    },
    "/suppliers": {
      "post": {
        "tags": ["Suppliers"],
        "summary": "Adicionar fornecedor",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ClientSupplierRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "Fornecedor criado" }
        }
      }
    },
    "/bookings/{reserveId}/price": {
      "post": {
        "tags": ["Bookings"],
        "summary": "Adicionar linha de cálculo",
        "parameters": [
          { "name": "reserveId", "in": "path", "required": true, "schema": { "type": "integer" } }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/PriceLineRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "Linha de cálculo criada" }
        }
      }
    }
  }
}
