QAlphaCloud  0.0.1
Qt bindings for Alpha Cloud
qalphacloud.h
1 /*
2  * SPDX-FileCopyrightText: 2023 Kai Uwe Broulik <ghqalpha@broulik.de>
3  * SPDX-License-Identifier: LGPL-2.1-or-later
4  */
5 
6 #pragma once
7 
8 #include "qalphacloud_export.h"
9 
10 #include <QLocale>
11 #include <QNetworkReply>
12 #include <QObject>
13 
14 #include <optional>
15 #include <ratio>
16 #include <type_traits>
17 
21 namespace QAlphaCloud
22 {
23 Q_NAMESPACE_EXPORT(QALPHACLOUD_EXPORT)
24 
25 
28 enum class RequestStatus {
29  NoRequest = 0,
30  Loading,
31  Finished,
32  Error,
33 };
34 Q_ENUM_NS(RequestStatus)
35 
36 
45 enum class ErrorCode {
46  UnknownError = -1,
47  NoError = 0,
48 
49  // ... QNetworkReply::Error ...
50 
51  // Our own errors.
52  JsonParseError = 1001,
54  EmptyJsonObjectError = 1002,
55 
56  // API errors
57  ParameterError = 6001,
58  SnNotBoundToUser = 6002,
59  // ///< "You have bound this SN"
60  CheckCodeError = 6004,
61  AppIdNotBoundToSn = 6005,
62  TimestampError = 6006,
63  SignVerificationError = 6007,
64  SetFailed = 6008,
66  SignEmpty = 6010,
67  TimestampEmpty = 6011,
68  AppIdEmpty = 6012,
69  DataDoesNotExist = 6016,
70  InvalidDate = 6026,
71  OperationFailed = 6029,
72  SystemSnDoesNotExist = 6038,
73  SystemOffline = 6042,
74  VerificationCode = 6046,
75  TooManyRequests = 6053,
76 };
77 Q_ENUM_NS(ErrorCode)
78 
79 
86 QALPHACLOUD_EXPORT QString errorText(ErrorCode code, const QVariant &details = QVariant());
87 
95 enum class SystemStatus {
96  UnknownStatus = -1,
97  Normal,
98  Fault,
99  // TODO Find out the others.
100 };
101 Q_ENUM_NS(SystemStatus)
102 
103 } // namespace QAlphaCloud
Utility namespace.
Definition: apirequest.cpp:24
QString errorText(ErrorCode code, const QVariant &details)
Human-readable error text.
Definition: qalphacloud.cpp:16
SystemStatus
System status.
Definition: qalphacloud.h:95
@ Fault
There is a system fault.
@ UnknownStatus
Unknown status.
@ Normal
The system is performing normally.
RequestStatus
Request status.
Definition: qalphacloud.h:28
@ Loading
The request is being loaded from the server.
@ NoRequest
No request has been issued.
@ Finished
The request has finished successfully.
@ Error
The request failed with an error.
ErrorCode
Error codes.
Definition: qalphacloud.h:45
@ UnexpectedJsonDataError
Valid JSON received but it was not an Object (perhaps null, or an Array).
@ DataDoesNotExist
"Data does not exist or has been deleted"
@ InvalidDate
Date is invalid, documented as "internal error". Also returned when requesting historic data for a fu...
@ ParameterError
"Parameter error"
@ TimestampEmpty
"timestamp is empty"
@ SystemSnDoesNotExist
"system sn does not exist"
@ SignEmpty
"Sign is empty"
@ WhitelistVerificationFailed
"Whitelist verification failed"
@ JsonParseError
Failed to parse JSON received.
@ AppIdEmpty
"AppId is empty"
@ AppIdNotBoundToSn
"This appId is not bound to the SN"
@ SignVerificationError
"Sign verification error"
@ TimestampError
"Timestamp error"
@ CheckCodeError
"CheckCode error"
@ NoError
API returns 200.
@ VerificationCode
"Verification code error"
@ OperationFailed
"Operation failed"
@ TooManyRequests
"The request was too fast, please try again later"
@ SystemOffline
"system offline"
@ EmptyJsonObjectError
Valid JSON object was received but it was empty.
@ SnNotBoundToUser
"The SN is not bound to the user"
@ SetFailed
"Set failed"