{
  "info": {
    "name": "GessoControl API",
    "description": "Coleção de requisições para a API do GessoControl (Multi-Tenant).",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "Autenticação",
      "item": [
        {
          "name": "Login",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"email\": \"alpha@gesso.com\",\n    \"password\": \"password\"\n}",
              "options": {
                "raw": { "language": "json" }
              }
            },
            "url": {
              "raw": "{{base_url}}/auth/login",
              "host": ["{{base_url}}"],
              "path": ["auth", "login"]
            }
          }
        },
        {
          "name": "Me (Usuário Logado)",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/me",
              "host": ["{{base_url}}"],
              "path": ["me"]
            }
          }
        }
      ]
    },
    {
      "name": "Materiais",
      "item": [
        {
          "name": "Listar Materiais",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/materials?search=&category=",
              "host": ["{{base_url}}"],
              "path": ["materials"],
              "query": [
                { "key": "search", "value": "" },
                { "key": "category", "value": "" }
              ]
            }
          }
        },
        {
          "name": "Criar Material",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"name\": \"Saco de Gesso 40kg\",\n    \"category\": \"Insumos\",\n    \"current_quantity\": 100,\n    \"min_quantity\": 10,\n    \"cost_price\": 25.50\n}",
              "options": {
                "raw": { "language": "json" }
              }
            },
            "url": {
              "raw": "{{base_url}}/materials",
              "host": ["{{base_url}}"],
              "path": ["materials"]
            }
          }
        },
        {
          "name": "Atualizar Material",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"cost_price\": 30.00\n}",
              "options": {
                "raw": { "language": "json" }
              }
            },
            "url": {
              "raw": "{{base_url}}/materials/1",
              "host": ["{{base_url}}"],
              "path": ["materials", "1"]
            }
          }
        },
        {
          "name": "Deletar Material",
          "request": {
            "method": "DELETE",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/materials/1",
              "host": ["{{base_url}}"],
              "path": ["materials", "1"]
            }
          }
        }
      ]
    },
    {
      "name": "Obras e Finanças",
      "item": [
        {
          "name": "Listar Projetos",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/projects",
              "host": ["{{base_url}}"],
              "path": ["projects"]
            }
          }
        },
        {
          "name": "Criar Projeto",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"client_name\": \"Cliente Teste\",\n    \"status\": \"orcamento\",\n    \"total_value\": 10000.00,\n    \"labor_cost\": 3000.00,\n    \"extra_costs\": 0\n}",
              "options": {
                "raw": { "language": "json" }
              }
            },
            "url": {
              "raw": "{{base_url}}/projects",
              "host": ["{{base_url}}"],
              "path": ["projects"]
            }
          }
        },
        {
          "name": "Atualizar Status da Obra",
          "request": {
            "method": "PATCH",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"status\": \"em_andamento\"\n}",
              "options": {
                "raw": { "language": "json" }
              }
            },
            "url": {
              "raw": "{{base_url}}/projects/1/status",
              "host": ["{{base_url}}"],
              "path": ["projects", "1", "status"]
            }
          }
        },
        {
          "name": "Lançar Custo Extra",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"amount\": 150.00\n}",
              "options": {
                "raw": { "language": "json" }
              }
            },
            "url": {
              "raw": "{{base_url}}/projects/1/extra-costs",
              "host": ["{{base_url}}"],
              "path": ["projects", "1", "extra-costs"]
            }
          }
        },
        {
          "name": "Dashboard Métricas",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/dashboard/metrics",
              "host": ["{{base_url}}"],
              "path": ["dashboard", "metrics"]
            }
          }
        }
      ]
    },
    {
      "name": "Orçamentos",
      "item": [
        {
          "name": "Listar Orçamentos",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "url": {
              "raw": "{{base_url}}/budgets",
              "host": ["{{base_url}}"],
              "path": ["budgets"]
            }
          }
        },
        {
          "name": "Criar Orçamento com Itens",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Accept", "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"project_id\": 1,\n    \"square_meters\": 120.50,\n    \"price_per_sqm\": 85.00,\n    \"items\": [\n        {\n            \"material_id\": 1,\n            \"quantity\": 10,\n            \"price\": 30.00\n        },\n        {\n            \"material_id\": 2,\n            \"quantity\": 20,\n            \"price\": 45.00\n        }\n    ]\n}",
              "options": {
                "raw": { "language": "json" }
              }
            },
            "url": {
              "raw": "{{base_url}}/budgets",
              "host": ["{{base_url}}"],
              "path": ["budgets"]
            }
          }
        },
        {
          "name": "Download Contrato em PDF",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Accept", "value": "application/pdf" }
            ],
            "url": {
              "raw": "{{base_url}}/budgets/1/download-pdf",
              "host": ["{{base_url}}"],
              "path": ["budgets", "1", "download-pdf"]
            }
          }
        }
      ]
    }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{access_token}}",
        "type": "string"
      }
    ]
  },
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          ""
        ]
      }
    },
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          "var response = pm.response.json();",
          "if (response.access_token) {",
          "    pm.environment.set(\"access_token\", response.access_token);",
          "}"
        ]
      }
    }
  ],
  "variable": [
    {
      "key": "base_url",
      "value": "http://localhost:8000/api",
      "type": "string"
    }
  ]
}
