149 lines
3.9 KiB
HTTP
149 lines
3.9 KiB
HTTP
# Xpensely API — Manual test file (IntelliJ HTTP Client / VS Code REST Client)
|
|
#
|
|
# HOW TO GET A TOKEN:
|
|
# 1. Run the Flutter dev app and sign in with Google
|
|
# 2. Add a breakpoint or log in auth_interceptor.dart after _storage.read(key: 'id_token')
|
|
# 3. Paste the token value below (valid for ~1 hour)
|
|
#
|
|
# Switch between dev and prod by changing @baseUrl.
|
|
|
|
@devBaseUrl = https://dev-xpensely.zendric.de/api
|
|
@prodBaseUrl = https://xpensely.zendric.de/api
|
|
@baseUrl = {{devBaseUrl}}
|
|
|
|
# Paste your Google ID token here:
|
|
@token = PASTE_ID_TOKEN_HERE
|
|
|
|
# Your Google sub (from the JWT payload — decode at jwt.io):
|
|
@googleId = PASTE_GOOGLE_SUB_HERE
|
|
|
|
|
|
### ─── Health ────────────────────────────────────────────────────────────────
|
|
|
|
### Version (no auth required — should always return 200)
|
|
GET {{baseUrl}}/version
|
|
|
|
### ─── Auth probe ─────────────────────────────────────────────────────────────
|
|
|
|
### Any protected endpoint without a token — expect 401
|
|
GET {{baseUrl}}/users/byGoogleId?id={{googleId}}
|
|
|
|
### ─── Users ──────────────────────────────────────────────────────────────────
|
|
|
|
### Look up your account by Google ID — expect 200 if account exists, 403 if not
|
|
GET {{baseUrl}}/users/byGoogleId?id={{googleId}}
|
|
Authorization: Bearer {{token}}
|
|
|
|
###
|
|
|
|
### Get your account by DB id — replace {id} with your numeric user id
|
|
GET {{baseUrl}}/users?id=1
|
|
Authorization: Bearer {{token}}
|
|
|
|
###
|
|
|
|
### Get any user by username (no auth required)
|
|
GET {{baseUrl}}/users/byName?username=testuser
|
|
|
|
###
|
|
|
|
### Create a new account (requires valid JWT — account must not exist yet)
|
|
POST {{baseUrl}}/users/createUser
|
|
Content-Type: application/json
|
|
Authorization: Bearer {{token}}
|
|
|
|
{
|
|
"username": "myusername",
|
|
"googleId": "{{googleId}}"
|
|
}
|
|
|
|
###
|
|
|
|
### Delete your account — replace {id} with your numeric user id
|
|
DELETE {{baseUrl}}/users?id=1
|
|
Authorization: Bearer {{token}}
|
|
|
|
### ─── Expense Lists ───────────────────────────────────────────────────────────
|
|
|
|
### Get all your expense lists — expect 200 (with data) or 204 (empty)
|
|
GET {{baseUrl}}/expenselist/mine
|
|
Authorization: Bearer {{token}}
|
|
|
|
###
|
|
|
|
### Get a specific expense list by id
|
|
GET {{baseUrl}}/expenselist/byId?id=1
|
|
Authorization: Bearer {{token}}
|
|
|
|
###
|
|
|
|
### Create a new expense list
|
|
POST {{baseUrl}}/expenselist/create
|
|
Content-Type: application/json
|
|
Authorization: Bearer {{token}}
|
|
|
|
{
|
|
"name": "Groceries"
|
|
}
|
|
|
|
###
|
|
|
|
### Add an expense to a list — replace {listId} in the URL
|
|
POST {{baseUrl}}/expenselist/1/add
|
|
Content-Type: application/json
|
|
Authorization: Bearer {{token}}
|
|
|
|
{
|
|
"title": "Coffee",
|
|
"owner": "myusername",
|
|
"amount": 4.50,
|
|
"date": "2026-05-15",
|
|
"category": "Food"
|
|
}
|
|
|
|
###
|
|
|
|
### Update an expense in a list
|
|
PUT {{baseUrl}}/expenselist/1/update
|
|
Content-Type: application/json
|
|
Authorization: Bearer {{token}}
|
|
|
|
{
|
|
"id": 1,
|
|
"title": "Coffee (updated)",
|
|
"ownerName": "myusername",
|
|
"amount": 5.00,
|
|
"date": "2026-05-15",
|
|
"category": "Food",
|
|
"expenseListId": 1
|
|
}
|
|
|
|
###
|
|
|
|
### Delete an expense from a list
|
|
DELETE {{baseUrl}}/expenselist/1/delete?expenseId=1
|
|
Authorization: Bearer {{token}}
|
|
|
|
###
|
|
|
|
### Generate an invite code for a list (you must be the owner)
|
|
POST {{baseUrl}}/expenselist/1/invite
|
|
Authorization: Bearer {{token}}
|
|
|
|
###
|
|
|
|
### Accept an invite
|
|
POST {{baseUrl}}/expenselist/accept-invite
|
|
Content-Type: application/json
|
|
Authorization: Bearer {{token}}
|
|
|
|
{
|
|
"inviteCode": "PASTE_6_CHAR_CODE_HERE"
|
|
}
|
|
|
|
###
|
|
|
|
### Delete an expense list (you must be the owner)
|
|
DELETE {{baseUrl}}/expenselist/1
|
|
Authorization: Bearer {{token}}
|