Skip to content

Firefly III: a personal finances manager

Some API route cleanup.

James Colefcf578784fe8
diff --git a/app/Api/V1/Controllers/Insight/Expense/DateController.php b/app/Api/V1/Controllers/Insight/Expense/AccountController.php
similarity index 80%
rename from app/Api/V1/Controllers/Insight/Expense/DateController.php
rename to app/Api/V1/Controllers/Insight/Expense/AccountController.php
index 63706917ad..7ef58c2c57 100644
--- a/app/Api/V1/Controllers/Insight/Expense/DateController.php
+++ b/app/Api/V1/Controllers/Insight/Expense/AccountController.php
@@ -35,19 +35,39 @@ use FireflyIII\User;
use Illuminate\Http\JsonResponse;
/**
- * Class DateController
+ * TODO per object group?
+ * TODO transfers voor piggies?
+ * TODO currency?
+ * TODO net worth?
+ *
+ * Class AccountController
*
* Shows expense information grouped or limited by date.
* Ie. all expenses grouped by account + currency.
+ *
+ * /api/v1/insight/expenses/expense
+ * Expenses grouped by expense account. Can be limited by date and by asset account.
+ * /api/v1/insight/expenses/asset
+ * Expenses grouped by asset account. Can be limited by date and by asset account.
+ * /api/v1/insight/expenses/total
+ * Expenses, total (no filter). Can be limited by date and by asset account.
+ * /api/v1/insight/expenses/budget
+ * Expenses per budget or no budget. Can be limited by date and by asset account.
+ * /api/v1/insight/expenses/budget
+ * Also per budget limit.
+ * /api/v1/insight/expenses/category
+ * Expenses per category or no category. Can be limited by date and by asset account.
+ * /api/v1/insight/expenses/bill
+ * Expenses per bill or no bill. Can be limited by date and by asset account.
+ *
*/
-class DateController extends Controller
+class AccountController extends Controller
{
use ApiSupport;
private CurrencyRepositoryInterface $currencyRepository;
private AccountRepositoryInterface $repository;
-
/**
* AccountController constructor.
*
@@ -72,11 +92,12 @@ class DateController extends Controller
}
/**
+ * @param DateRequest $request
*
+ * @return JsonResponse
*/
- public function basic(DateRequest $request): JsonResponse
+ public function expense(DateRequest $request): JsonResponse
{
- // parameters for chart:
$dates = $request->getAll();
/** @var Carbon $start */
$start = $dates['start'];
@@ -87,7 +108,6 @@ class DateController extends Controller
// prep some vars:
$currencies = [];
- $chartData = [];
$tempData = [];
// grab all accounts and names
diff --git a/routes/api.php b/routes/api.php
index f967d38419..4b0eb37a8b 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -77,9 +77,51 @@ Route::group(
}
);
+/**
+ * DATA CONTROLLERS
+ *
+ */
+
+// EXPORT TODO
+Route::group(
+ ['namespace' => 'FireflyIII\Api\V1\Controllers\Data\Export', 'prefix' => 'data/export',
+ 'as' => 'api.v1.data.export.',],
+ static function () {
+ Route::get('transactions', ['uses' => 'TransactionController@export', 'as' => 'transactions']);
+ }
+);
+
+/**
+ * INSIGHT CONTROLLERS
+ */
+
+// Insight in expenses:
+Route::group(
+ ['namespace' => 'FireflyIII\Api\V1\Controllers\Insight\Expense', 'prefix' => 'insight/expense',
+ 'as' => 'api.v1.insight.expense.',],
+ static function () {
+ // Insight in expenses.
+
+ // grouped by expense account or asset account:
+ Route::get('expense', ['uses' => 'AccountController@expense', 'as' => 'expense']);
+ Route::get('asset', ['uses' => 'AccountController@asset', 'as' => 'asset']);
+ // TODO total:
+ Route::get('total', ['uses' => 'PeriodController@total', 'as' => 'total']);
+ // TODO Budget/no budget and budget limit
+ Route::get('budget', ['uses' => 'BudgetController@budget', 'as' => 'budget']);
+ Route::get('no-budget', ['uses' => 'BudgetController@budget', 'as' => 'budget']);
+ // TODO category and no category
+
+ // TODO bill and no bill
+ }
+);
+
+//// Insight in income.
+// // Insight in income by date.
+// Route::get('income/date/basic', ['uses' => 'Income\DateController@basic', 'as' => 'income.date.basic']);
@@ -456,22 +498,6 @@ Route::group(
}
);
-// INSIGHT
-// TODO VERIFY API DOCS
-Route::group(
- ['namespace' => 'FireflyIII\Api\V1\Controllers\Insight', 'prefix' => 'insight',
- 'as' => 'api.v1.insight.',],
- static function () {
-
- // Insight in expenses.
- // Insight in expenses by date.
- Route::get('expense/date/basic', ['uses' => 'Expense\DateController@basic', 'as' => 'expense.date.basic']);
-
- // Insight in income.
- // Insight in income by date.
- Route::get('income/date/basic', ['uses' => 'Income\DateController@basic', 'as' => 'income.date.basic']);
- }
-);
// TODO VERIFY API DOCS
Route::group(