### 1. Get access token for user "maria" POST http://localhost:8081/realms/hemhub/protocol/openid-connect/token Content-Type: application/x-www-form-urlencoded client_id=hemhub-public& grant_type=password& username=maria& password=Passw0rd > {% client.global.set("token", response.body.access_token); client.global.set("refresh_token", response.body.refresh_token); %} ### 2. Decode token (optional, debugging) GET https://jwt.io/?access_token={{token}} ### 3. Get current user info GET http://localhost:8080/me Authorization: Bearer {{token}} ### 4. Create a household POST http://localhost:8080/api/v1/households Content-Type: application/json Authorization: Bearer {{token}} { "name": "Familjen Andersson" } > {% client.global.set("householdId", response.body.id); %} ### 5. List my households GET http://localhost:8080/api/v1/households Authorization: Bearer {{token}} ### 6. List household members GET http://localhost:8080/api/v1/households/{{householdId}}/members Authorization: Bearer {{token}} ### 7. Add a member (requires OWNER role) POST http://localhost:8080/api/v1/households/{{householdId}}/members Content-Type: application/json Authorization: Bearer {{token}} { "userSub": "ulf-sub", "email": "ulf@example.com", "displayName": "Ulf", "role": "MEMBER" } ### 8. List members again (should now include Ulf) GET http://localhost:8080/api/v1/households/{{householdId}}/members Authorization: Bearer {{token}} ### 9) Create project (OWNER only) POST http://localhost:8080/api/v1/projects Content-Type: application/json Authorization: Bearer {{token}} { "householdId": "{{householdId}}", "name": "Sovrumsrenovering", "description": "Måla, golv, el" } > {% client.global.set("projectId", response.body.id); %} ### 10) List projects in household GET http://localhost:8080/api/v1/households/{{householdId}}/projects Authorization: Bearer {{token}} ### 11) Create task POST http://localhost:8080/api/v1/tasks Content-Type: application/json Authorization: Bearer {{token}} { "projectId": "{{projectId}}", "title": "Damsug soffan", "priority": "LOW" } > {% client.global.set("taskId", response.body.id); %} ### 12) List tasks GET http://localhost:8080/api/v1/projects/{{projectId}}/tasks Authorization: Bearer {{token}} ### 13) Update task PATCH http://localhost:8080/api/v1/tasks/{{taskId}} Content-Type: application/json Authorization: Bearer {{token}} { "status": "DONE" } ### 14) Create a household-level task (no project) POST http://localhost:8080/api/v1/households/{{householdId}}/tasks Content-Type: application/json Authorization: Bearer {{token}} { "title": "Buy milk", "priority": "HIGH" } > {% client.global.set("taskId", response.body.id); %} ### 15) List household-level tasks GET http://localhost:8080/api/v1/households/{{householdId}}/tasks Authorization: Bearer {{token}} ### 15a) Prepare a {{tomorrow}} variable (YYYY-MM-DD) GET http://localhost:8080/public/info > {% const d = new Date(); d.setDate(d.getDate() + 1); const tomorrow = d.toISOString().slice(0,10); client.global.set("tomorrow", tomorrow); %} ### 15b) Capture latest household task id (if not already set) GET http://localhost:8080/api/v1/households/{{householdId}}/tasks?size=1&sort=createdAt,desc Authorization: Bearer {{token}} > {% if (!client.global.get("taskId")) { const id = response.body?.content?.length ? response.body.content[0].id : null; if (id) client.global.set("taskId", id); } %} ### 15c) Set that task's dueDate to {{tomorrow}} PATCH http://localhost:8080/api/v1/tasks/{{taskId}} Content-Type: application/json Authorization: Bearer {{token}} { "dueDate": "{{tomorrow}}" } ### 16) My tasks due tomorrow GET http://localhost:8080/api/v1/tasks/due/tomorrow Authorization: Bearer {{token}}