Banking_System_Client  1.0.0
Qt-based banking app for user/admin account management, transactions, secure server communication via PostgreSQL/Supabase.
ResponseManager.h
1 #ifndef RESPONSEMANAGER_H
2 #define RESPONSEMANAGER_H
3 
4 #include <QObject>
5 #include <QJsonDocument>
6 #include <QJsonObject>
7 #include <QJsonArray>
8 
17 class ResponseManager : public QObject
18 {
19  Q_OBJECT
20 
21  //private:
22 public: // for testing
28  {
29  Login = 1,
39  // Special requests
44  Connection = -2
45  };
46 
53  bool getResponseStatus(QJsonObject Data);
54 
61  QString getResponseMessage(QJsonObject Data);
62 
63 signals:
64 
73  void userloginSuccess(QString email, QString first_name, QString account_number, QString balance);
74 
81  void adminLoginSuccess(QString email, QString first_name);
82 
88  void ConnectionResponse(bool status);
89 
95  void TransactionsFetched(const QList<QMap<QString, QString>>& transactions);
96 
102  void DatabaseFetched(const QList<QMap<QString, QString>>& databaseContent);
103 
109  void BalanceFetched(QString balance);
110 
116  void SuccessfullRequest(QString message);
117 
123  void FailedRequest(QString message);
124 
125 public:
131  explicit ResponseManager(QObject* parent = nullptr);
132 
139  void handleResponse(QJsonObject Data);
140 };
141 
142 #endif // RESPONSEMANAGER_H
Manages the responses received from the server.
Definition: ResponseManager.h:18
ResponseManager(QObject *parent=nullptr)
Constructor for ResponseManager.
Definition: ResponseManager.cpp:24
void TransactionsFetched(const QList< QMap< QString, QString >> &transactions)
Signal emitted when transactions are fetched.
void FailedRequest(QString message)
Signal emitted for a failed request.
void userloginSuccess(QString email, QString first_name, QString account_number, QString balance)
Signal emitted when a user login is successful.
void ConnectionResponse(bool status)
Signal emitted for connection response.
void adminLoginSuccess(QString email, QString first_name)
Signal emitted when an admin login is successful.
void handleResponse(QJsonObject Data)
Handles the response received from the server.
Definition: ResponseManager.cpp:28
QString getResponseMessage(QJsonObject Data)
Retrieves the message from the response.
Definition: ResponseManager.cpp:15
void DatabaseFetched(const QList< QMap< QString, QString >> &databaseContent)
Signal emitted when the database content is fetched.
bool getResponseStatus(QJsonObject Data)
Checks the status value in the response.
Definition: ResponseManager.cpp:3
AvailableRequests
Defines the types of requests that can be handled.
Definition: ResponseManager.h:28
@ CreateNewUser
Response to create a new user.
Definition: ResponseManager.h:36
@ UserInit
Response to initialize user.
Definition: ResponseManager.h:40
@ GetTransactionsHistory
Response to get transaction history.
Definition: ResponseManager.h:32
@ MakeTransaction
Response to make a transaction.
Definition: ResponseManager.h:33
@ DeleteUser
Response to delete a user.
Definition: ResponseManager.h:37
@ JsonParseError
Indicates a JSON parse error.
Definition: ResponseManager.h:43
@ GetDatabase
Response to get the database.
Definition: ResponseManager.h:35
@ UpdatePassword
Response to update user password.
Definition: ResponseManager.h:42
@ TransferAmount
Response to transfer an amount (not used for now)
Definition: ResponseManager.h:34
@ GetAccountnumber
Response to get account number.
Definition: ResponseManager.h:30
@ Login
User login response.
Definition: ResponseManager.h:29
@ UpdateEmail
Response to update user email.
Definition: ResponseManager.h:41
@ Connection
Indicates a connection response.
Definition: ResponseManager.h:44
@ UpdateUser
Response to update user information.
Definition: ResponseManager.h:38
@ GetBalance
Response to get account balance.
Definition: ResponseManager.h:31
void SuccessfullRequest(QString message)
Signal emitted for a successful request.
void BalanceFetched(QString balance)
Signal emitted when the balance is fetched.