Package no.idata1002.group19.web.api
Class TransactionController
java.lang.Object
no.idata1002.group19.web.api.TransactionController
Controller class responsible for providing RESTful services
at the /transactions enpoint and its descendant enpoints for
API provision of Transaction instances.
- Since:
- 16.04.2023
- Version:
- 16.04.2023
- Author:
- Group19
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<?>
addTransaction
(TransactionCredentials credentials) Adds a new transaction to the system using the TransactionService and returns an appropriate HTTP response.org.springframework.http.ResponseEntity<?>
delete
(long id) Deletes a transaction with the specified ID using the TransactionService and returns an appropriate HTTP response.getDates
(long id) Retrieves a list of all unique transaction dates for a specific budget from TransactionRepository and returns them as an HTTP response.Retrieves a list of all transaction from the TransactionService and returns them as an HTTP response.getIncomesById
(String id) Retrieves a list of all incomes from a budget with the specified id from the TransactionService and returns them as an HTTP response.org.springframework.http.ResponseEntity<?>
getTransactionById
(long id) Retrieves a transaction from TransactionService and returns them as an HTTP responseRetrieves a list of all transaction from the TransactionService and returns them as an HTTP response.org.springframework.http.ResponseEntity<?>
update
(long id, TransactionCredentials credentials) Updates a transaction with the specified ID using the TransactionService and returns an appropriate HTTP response.
-
Constructor Details
-
TransactionController
public TransactionController()
-
-
Method Details
-
getTransactions
Retrieves a list of all transaction from the TransactionService and returns them as an HTTP response.- Returns:
- ResponseEntityinvalid input: '<'List
> - an HTTP response containing a list of all transaction
-
getExpensesById
@GetMapping("/transactions/expensesById/{id}") public Iterable<Transaction> getExpensesById(@PathVariable String id) Retrieves a list of all transaction from the TransactionService and returns them as an HTTP response.- Returns:
- ResponseEntityinvalid input: '<'List
> - an HTTP response containing a list of all transaction
-
getIncomesById
@GetMapping("/transactions/incomesById/{id}") public Iterable<Transaction> getIncomesById(@PathVariable String id) Retrieves a list of all incomes from a budget with the specified id from the TransactionService and returns them as an HTTP response.- Parameters:
id
- - the ID of the budget to get incomes from.- Returns:
- ResponseEntityinvalid input: '<'List
> - an HTTP response containing a list of all incomes from the budget.
-
getTransactionById
@GetMapping("/transactions/{id}") public org.springframework.http.ResponseEntity<?> getTransactionById(@PathVariable long id) Retrieves a transaction from TransactionService and returns them as an HTTP response- Parameters:
id
- of the transaction that you want to get- Returns:
- ResponseEntity.ok - and HTTP response containing the transaction.
-
addTransaction
@PostMapping("/transactions") public org.springframework.http.ResponseEntity<?> addTransaction(@RequestBody TransactionCredentials credentials) Adds a new transaction to the system using the TransactionService and returns an appropriate HTTP response.- Parameters:
transaction
- - the transaction object representing the transaction to add.- Returns:
- ResponseEntity - an HTTP response indicating whether the transaction was added successfully.
-
update
@PutMapping("/transactions/{id}") public org.springframework.http.ResponseEntity<?> update(@PathVariable long id, @RequestBody TransactionCredentials credentials) Updates a transaction with the specified ID using the TransactionService and returns an appropriate HTTP response.- Parameters:
id
- - the ID of the transaction to update.transaction
- - the Transaction object representing the updated Transaction.- Returns:
- ResponseEntity - an HTTP response indicating whether the transaction was updated successfully.
-
delete
@DeleteMapping("/transactions/{id}") public org.springframework.http.ResponseEntity<?> delete(@PathVariable long id) Deletes a transaction with the specified ID using the TransactionService and returns an appropriate HTTP response.- Parameters:
id
- - the ID of the transaction to delete.- Returns:
- ResponseEntity - an HTTP response indicating whether the transaction was deleted successfully.
-
getDates
@GetMapping("/transactions/budgetTransactionDates/{id}") public Iterable<String> getDates(@PathVariable long id) Retrieves a list of all unique transaction dates for a specific budget from TransactionRepository and returns them as an HTTP response.- Parameters:
id
- - the ID of the budget to retrieve transaction dates for.- Returns:
- ResponseEntity - an HTTP response containing a list of all unique transaction dates for the specified budget.
-