You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							46 lines
						
					
					
						
							1.0 KiB
						
					
					
				
			
		
		
	
	
							46 lines
						
					
					
						
							1.0 KiB
						
					
					
				#pragma once
 | 
						|
 | 
						|
#include <QJsonObject>
 | 
						|
#include <QNetworkReply>
 | 
						|
#include <QString>
 | 
						|
#include <QTimer>
 | 
						|
 | 
						|
namespace CommaApi {
 | 
						|
 | 
						|
QByteArray rsa_sign(const QByteArray &data);
 | 
						|
QString create_jwt(const QJsonObject &payloads = {}, int expiry = 3600);
 | 
						|
 | 
						|
}  // namespace CommaApi
 | 
						|
 | 
						|
/**
 | 
						|
 * Makes a request to the request endpoint.
 | 
						|
 */
 | 
						|
 | 
						|
class HttpRequest : public QObject {
 | 
						|
  Q_OBJECT
 | 
						|
 | 
						|
public:
 | 
						|
  enum class Method {GET, DELETE};
 | 
						|
 | 
						|
  explicit HttpRequest(QObject* parent, bool create_jwt = true, int timeout = 20000);
 | 
						|
  void sendRequest(const QString &requestURL, const Method method = Method::GET);
 | 
						|
  bool active();
 | 
						|
 | 
						|
protected:
 | 
						|
  QNetworkReply *reply = nullptr;
 | 
						|
 | 
						|
private:
 | 
						|
  QNetworkAccessManager *networkAccessManager = nullptr;
 | 
						|
  QTimer *networkTimer = nullptr;
 | 
						|
  bool create_jwt;
 | 
						|
 | 
						|
private slots:
 | 
						|
  void requestTimeout();
 | 
						|
  void requestFinished();
 | 
						|
 | 
						|
signals:
 | 
						|
  void requestDone(bool success);
 | 
						|
  void receivedResponse(const QString &response);
 | 
						|
  void failedResponse(const QString &errorString);
 | 
						|
  void timeoutResponse(const QString &errorString);
 | 
						|
};
 | 
						|
 |