#pragma once

#include <QString>
#include <QDateTime>

enum class AccountType {
    Outlook,
    Gmail,
    IMAP
};

class Account
{
public:
    Account() = default;
    Account(int id, const QString& email, const QString& displayName,
            AccountType type, const QString& accessToken = QString(),
            const QString& refreshToken = QString(),
            const QDateTime& tokenExpires = QDateTime());

    int id() const { return m_id; }
    void setId(int id) { m_id = id; }

    QString email() const { return m_email; }
    void setEmail(const QString& email) { m_email = email; }

    QString displayName() const { return m_displayName; }
    void setDisplayName(const QString& displayName) { m_displayName = displayName; }

    AccountType type() const { return m_type; }
    void setType(AccountType type) { m_type = type; }

    QString accessToken() const { return m_accessToken; }
    void setAccessToken(const QString& token) { m_accessToken = token; }

    QString refreshToken() const { return m_refreshToken; }
    void setRefreshToken(const QString& token) { m_refreshToken = token; }

    QDateTime tokenExpires() const { return m_tokenExpires; }
    void setTokenExpires(const QDateTime& expires) { m_tokenExpires = expires; }

    bool isTokenValid() const {
        return !m_accessToken.isEmpty() && m_tokenExpires.isValid() &&
               m_tokenExpires > QDateTime::currentDateTimeUtc();
    }

private:
    int m_id{0};
    QString m_email;
    QString m_displayName;
    AccountType m_type{AccountType::IMAP};
    QString m_accessToken;
    QString m_refreshToken;
    QDateTime m_tokenExpires;
};