From 6d1af2f46d6e582a78b956cbf87c37c17eef8dd5 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Thu, 12 Feb 2026 12:21:56 -0500 Subject: [PATCH] Added @GetMapping, prepped for new category/balance api --- finnow-api/source/data_api.d | 4 ++-- finnow-api/source/transaction/api.d | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/finnow-api/source/data_api.d b/finnow-api/source/data_api.d index 94b5821..3953ddd 100644 --- a/finnow-api/source/data_api.d +++ b/finnow-api/source/data_api.d @@ -1,11 +1,11 @@ module data_api; import handy_http_primitives; -import handy_http_handlers.path_handler : PathMapping; +import handy_http_handlers.path_handler : GetMapping; import handy_http_data; import util.money; -@PathMapping(HttpMethod.GET, "/api/currencies") +@GetMapping("/api/currencies") void handleGetCurrencies(ref ServerHttpRequest request, ref ServerHttpResponse response) { writeJsonBody(response, ALL_CURRENCIES); } \ No newline at end of file diff --git a/finnow-api/source/transaction/api.d b/finnow-api/source/transaction/api.d index 79e40d5..3db020b 100644 --- a/finnow-api/source/transaction/api.d +++ b/finnow-api/source/transaction/api.d @@ -135,24 +135,33 @@ private ulong getVendorId(in ServerHttpRequest request) { // Categories API -@PathMapping(HttpMethod.GET, PROFILE_PATH ~ "/categories") +@GetMapping(PROFILE_PATH ~ "/categories") void handleGetCategories(ref ServerHttpRequest request, ref ServerHttpResponse response) { TransactionCategoryTree[] categories = getCategories(getProfileDataSource(request)); writeJsonBody(response, categories); } -@PathMapping(HttpMethod.GET, PROFILE_PATH ~ "/categories/:categoryId:ulong") +@GetMapping(PROFILE_PATH ~ "/categories/:categoryId:ulong") void handleGetCategory(ref ServerHttpRequest request, ref ServerHttpResponse response) { auto category = getCategory(getProfileDataSource(request), getCategoryId(request)); writeJsonBody(response, category); } -@PathMapping(HttpMethod.GET, PROFILE_PATH ~ "/categories/:categoryId:ulong/children") +@GetMapping(PROFILE_PATH ~ "/categories/:categoryId:ulong/children") void handleGetChildCategories(ref ServerHttpRequest request, ref ServerHttpResponse response) { auto children = getChildCategories(getProfileDataSource(request), getCategoryId(request)); writeJsonBody(response, children); } +@GetMapping(PROFILE_PATH ~ "/categories/:categoryId:ulong/balances") +void handleGetCategoryBalances(ref ServerHttpRequest request, ref ServerHttpResponse response) { + response.status = HttpStatus.NOT_IMPLEMENTED; + // TODO: Add an API endpoint to provide a "balance" for the category. + // This would be the sum of credits and debits for all transactions set + // to this category or any child of it, over a specified interval, or for + // some default interval if none is provided. +} + struct CategoryPayload { string name; string description;