#pragma once #include "common/network/NetworkRequest.hpp" #include #include #include namespace chatterino { using IvrFailureCallback = std::function; template using ResultCallback = std::function; struct IvrSubage { const bool isSubHidden; const bool isSubbed; const QString subTier; const int totalSubMonths; const QString followingSince; IvrSubage(const QJsonObject &root) : isSubHidden(root.value("statusHidden").toBool()) , isSubbed(!root.value("meta").isNull()) , subTier(root.value("meta").toObject().value("tier").toString()) , totalSubMonths( root.value("cumulative").toObject().value("months").toInt()) , followingSince(root.value("followedAt").toString()) { } }; class IvrApi final { public: // https://api.ivr.fi/v2/docs/static/index.html#/Twitch/get_twitch_subage__user___channel_ void getSubage(QString userName, QString channelName, ResultCallback resultCallback, IvrFailureCallback failureCallback); static void initialize(); IvrApi() = default; IvrApi(const IvrApi &) = delete; IvrApi &operator=(const IvrApi &) = delete; IvrApi(IvrApi &&) = delete; IvrApi &operator=(IvrApi &&) = delete; private: NetworkRequest makeRequest(QString url, QUrlQuery urlQuery); }; IvrApi *getIvr(); } // namespace chatterino