#ifndef HTTPCARDLOGIN_H
#define HTTPCARDLOGIN_H
#include <QThread>
#include <QtQml/qqml.h>
#include <QNetworkAccessManager>
#include <QTimer>

class HttpCardLogin : public QThread
{
    Q_OBJECT
    QML_NAMED_ELEMENT(HttpCardLogin)

    Q_PROPERTY(QString cardID READ cardID WRITE setCardID)
public:
    explicit HttpCardLogin(QObject *parent = nullptr);

    QString cardID()
    {
        return this->m_cardID;
    }
    void setCardID(const QString& cardId)
    {
        m_cardID = cardId;
    }
protected:
    void run() override;
private:
    void httpRequestCardLogin(void);
    bool cardIDToNfc(const QString& cardId);
public slots:
    void slotHttpResponseCardLogin(QByteArray data);
signals:
    void signalPostRequestData(quint64 id, QString postUrl, QByteArray data, QByteArray file, QString token);
    void signalLoginReturnStat(int stat, QString str);
    void signalLoginReturnParam(QString name, int auth);
private:
    bool m_threadstatus = true;
    QString m_cardID;
    QString m_cardNfc;
    QString m_accessToken;
    QString m_refreshToken;
};

#endif // HTTPCARDLOGIN_H
