Included XML files for the "pay to new number" and "pay to old number" features in the Ozon platform.
102 lines
2.3 KiB
C++
102 lines
2.3 KiB
C++
#pragma once
|
|
#include <qhttpmultipart.h>
|
|
#include <QJsonArray>
|
|
#include <QNetworkAccessManager>
|
|
#include <QObject>
|
|
#include <QMap>
|
|
|
|
class NetworkService final : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit NetworkService(QObject *parent = nullptr);
|
|
|
|
~NetworkService() override;
|
|
|
|
void setPayload(const QByteArray &json) { m_json = json; }
|
|
|
|
void setDeviceId(const QString &deviceId) {
|
|
m_deviceId = deviceId;
|
|
}
|
|
|
|
void addExtra(const QString &key, const QVariant &value);
|
|
|
|
public slots:
|
|
void postAccountsData();
|
|
|
|
void postBankProfile();
|
|
|
|
void patchBankProfile();
|
|
|
|
void postMaterial();
|
|
|
|
void postDeviceScreenshot();
|
|
|
|
void getPayments();
|
|
|
|
void postAppStatus();
|
|
|
|
void postEventStatus();
|
|
|
|
void insertTransactionData();
|
|
|
|
void updateTransactionData();
|
|
|
|
void loginAndSetup();
|
|
|
|
void createDevice();
|
|
|
|
void updateDevice();
|
|
|
|
void getTasks();
|
|
|
|
void postTaskResult();
|
|
|
|
void start();
|
|
void stop();
|
|
|
|
signals:
|
|
void finished();
|
|
void finishedWithResult(int value);
|
|
void tokenRefreshFailed();
|
|
void tasksReceived(QJsonArray tasks);
|
|
|
|
private:
|
|
QByteArray m_json;
|
|
QString m_deviceId;
|
|
QString m_token;
|
|
QString m_accessToken;
|
|
QString m_apiBase;
|
|
QMap<QString, QVariant> m_extraData = {};
|
|
bool m_running = true;
|
|
bool m_tokenErrorShown = false;
|
|
|
|
QString m_urlAccountUpdate;
|
|
QString m_urlPaymentsGet;
|
|
QString m_urlTransactionUpdate;
|
|
QString m_urlAppStatusUpdate;
|
|
QString m_urlTransactionInsert;
|
|
QString m_urlEventStatusUpdate;
|
|
QString m_pathAuthLogin;
|
|
QString m_pathAuthRefresh;
|
|
QString m_pathDesktopCreate;
|
|
QString m_pathDevice;
|
|
QString m_pathDeviceScreenshot;
|
|
QString m_pathBankProfile;
|
|
QString m_pathMaterial;
|
|
QString m_pathGetTasks;
|
|
QString m_pathTaskResult;
|
|
bool m_fetchingTasks = false;
|
|
|
|
QNetworkAccessManager *m_manager;
|
|
|
|
QJsonValue post(QHttpMultiPart *multiPart, const QString &path);
|
|
QJsonArray get(const QString &path, const QMap<QString, QString> ¶ms);
|
|
QJsonValue postJson(const QString &path, const QJsonObject &body, bool withAuth = false);
|
|
QJsonValue patchJson(const QString &path, const QJsonObject &body, bool withAuth = false);
|
|
|
|
bool refreshToken();
|
|
bool ensureValidToken();
|
|
void scheduleNextRefresh();
|
|
};
|