summaryrefslogtreecommitdiff
path: root/src/apiuseraccount.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-06-14 01:38:07 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-06-14 01:38:07 -0400
commit616925ebbb8e916119f8dbee0c1f0cb97b14a68b (patch)
tree543883f92fced3a3cd92537d5dc6ec5d2a9e5a12 /src/apiuseraccount.cpp
parenta7757e8ba6f5d10feea9e58611bde4dcb911079b (diff)
moved api user account classes to their own files
api label in status bar: - now shows when not logged in - changed some of the colour thresholds to correspond to real throttling numbers make sure the api key is also cleared from the access manager when clearing from the settings removed unused bool m_ValidateAttempted in NXMAccessManager update the window title and status bar api label with correct values on startup, which fixes incorrect values when "restarting" MO after changing nexus settings
Diffstat (limited to 'src/apiuseraccount.cpp')
-rw-r--r--src/apiuseraccount.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/apiuseraccount.cpp b/src/apiuseraccount.cpp
new file mode 100644
index 00000000..b901e41a
--- /dev/null
+++ b/src/apiuseraccount.cpp
@@ -0,0 +1,67 @@
+#include "apiuseraccount.h"
+
+APIUserAccount::APIUserAccount()
+ : m_type(APIUserAccountTypes::None)
+{
+}
+
+const QString& APIUserAccount::id() const
+{
+ return m_id;
+}
+
+const QString& APIUserAccount::name() const
+{
+ return m_name;
+}
+
+APIUserAccountTypes APIUserAccount::type() const
+{
+ return m_type;
+}
+
+const APILimits& APIUserAccount::limits() const
+{
+ return m_limits;
+}
+
+APIUserAccount& APIUserAccount::id(const QString& id)
+{
+ m_id = id;
+ return *this;
+}
+
+APIUserAccount& APIUserAccount::name(const QString& name)
+{
+ m_name = name;
+ return *this;
+}
+
+APIUserAccount& APIUserAccount::type(APIUserAccountTypes type)
+{
+ m_type = type;
+ return *this;
+}
+
+APIUserAccount& APIUserAccount::limits(const APILimits& limits)
+{
+ m_limits = limits;
+ return *this;
+}
+
+int APIUserAccount::remainingRequests() const
+{
+ return std::max(
+ m_limits.remainingDailyRequests,
+ m_limits.remainingHourlyRequests);
+}
+
+bool APIUserAccount::shouldThrottle() const
+{
+ return (remainingRequests() < ThrottleThreshold);
+}
+
+bool APIUserAccount::exhausted() const
+{
+ return (remainingRequests() <= 0);
+}