magpie/API/api.h

29 lines
686 B
C
Raw Normal View History

2023-11-24 23:48:01 +00:00
#pragma once
#include <memory>
#include <QObject>
#include <QString>
#include <QUrl>
#include <QJSValue>
#include <QNetworkAccessManager>
#include <QNetworkReply>
class API : public QObject {
Q_OBJECT
public:
explicit API(const QUrl& path = QString(), QObject* parent = nullptr);
Q_INVOKABLE void test(const QString& path, const QJSValue& finished = QJSValue());
private slots:
void onTestSuccess(QNetworkReply* reply, const QJSValue& finished) const;
private:
void callCallback(const QJSValue& callback, const QString& error = QString(), const QJSValueList& arguments = QJSValueList()) const;
private:
QUrl address;
QNetworkAccessManager network;
};