Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions App/Server/OpenAPIGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,15 @@ QJsonObject OpenAPIGenerator::retrieveJson(

clsAPIObject* APIObject = RESTAPIRegistry::Registry.value(Key);

if (Key == "GET /Account/OfflinePayments")
qDebug() << "*******************************************";

qDebug() << Key << endl
<< " " << APIObject->ParamNames.count() << " : " << APIObject->ParamNames.join(", ") << endl
<< " " << APIObject->ParamTypesName.count() << " : " << APIObject->ParamTypesName.join(", ") << endl
<< " " << APIObject->BaseMethod.DefaultValues.count() << " : " << APIObject->BaseMethod.DefaultValues << endl
;

if (APIObject->BaseMethod.DefaultValues.count() != APIObject->ParamNames.count())
qDebug() << "<><><><><><><><><><><><><><><><><><><><><><><><><><><>" << endl;
qDebug().noquote().nospace()
<< Key << endl
<< " ParamNames: [" << APIObject->ParamNames.count() << "] " << APIObject->ParamNames.join(", ") << endl
<< " ParamTypesName: [" << APIObject->ParamTypesName.count() << "] " << APIObject->ParamTypesName.join(", ") << endl
<< " DefaultValues: [" << APIObject->BaseMethod.DefaultValues.count() << "] " << APIObject->BaseMethod.DefaultValues << endl
<< (APIObject->BaseMethod.DefaultValues.count() != APIObject->ParamNames.count()
? " ******************** ERROR IN COUNTERS ********************"
: "")
;
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions App/Server/RESTAPIRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void RESTAPIRegistry::registerRESTAPI(
QString ParameterTypeName = parameterTypes.at(ParamIndex);

//check APICallBoom
if (ParameterTypeName.startsWith(APICALLBOOM_TYPE_NAME_BASE)) {
if (ParameterTypeName.startsWith(APICALLBOOM_TYPE_BASE_STR)) {
DefaultValues.append(QVariant());
continue;
}
Expand Down Expand Up @@ -506,7 +506,7 @@ void RESTAPIRegistry::validateMethodInputAndOutput(const QMetaMethod& _method) {
QString ParameterTypeName = parameterTypes.at(i);

//check APICallBoom
if (ParameterTypeName.startsWith(APICALLBOOM_TYPE_NAME_BASE)) {
if (ParameterTypeName.startsWith(APICALLBOOM_TYPE_BASE_STR)) {
if (HasApiCallBoomParam)
throw exRESTRegistry(QString("Invalid duplicate APICALLBOOM parameter (%1) at %2 of %3")
.arg(_method.parameterNames().at(i).constData())
Expand Down
20 changes: 6 additions & 14 deletions App/Server/StaticModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ StaticModule::StaticModule() :
{ ; }

TAPI::RawData_t IMPL_REST_GET_OR_POST(StaticModule, openAPI_json, (
APICallBoom<false> &_APICALLBOOM
APICALLBOOM_TYPE_NO_JWT_IMPL &APICALLBOOM_PARAM
)) {
gServerStats.Success.inc();

Expand All @@ -49,17 +49,15 @@ TAPI::RawData_t IMPL_REST_GET_OR_POST(StaticModule, openAPI_json, (
}

QVariant IMPL_REST_GET_OR_POST(StaticModule, openAPI_yaml, (
APICallBoom<false> &_APICALLBOOM
APICALLBOOM_TYPE_NO_JWT_IMPL &APICALLBOOM_PARAM
)) {
Q_UNUSED(_APICALLBOOM)

throw exHTTPMethodNotAllowed("Yaml openAPI is not implemented yet");
}

//TAPI::ResponseRedirect_t
//TAPI::FileData_t
QVariant IMPL_REST_GET_OR_POST(StaticModule, swaggerui, (
APICallBoom<false> &_APICALLBOOM
APICALLBOOM_TYPE_NO_JWT_IMPL &APICALLBOOM_PARAM
)) {
if (ServerConfigs::SwaggerUI.value().isEmpty())
throw exHTTPNotFound("Swagger is not configured");
Expand All @@ -78,21 +76,17 @@ QVariant IMPL_REST_GET_OR_POST(StaticModule, swaggerui, (
}

QVariant IMPL_REST_GET_OR_POST(StaticModule, stats_json, (
APICallBoom<false> &_APICALLBOOM,
APICALLBOOM_TYPE_NO_JWT_IMPL &APICALLBOOM_PARAM,
bool _full
)) {
Q_UNUSED(_APICALLBOOM)

gServerStats.Success.inc();

return gServerStats.toJson(_full);
}

QVariant IMPL_REST_GET_OR_POST(StaticModule, version, (
APICallBoom<false> &_APICALLBOOM
APICALLBOOM_TYPE_NO_JWT_IMPL &APICALLBOOM_PARAM
)) {
Q_UNUSED(_APICALLBOOM)

gServerStats.Success.inc();

QJsonObject Version;
Expand All @@ -107,10 +101,8 @@ QVariant IMPL_REST_GET_OR_POST(StaticModule, version, (
}

QVariant IMPL_REST_GET_OR_POST(StaticModule, ping, (
APICallBoom<false> &_APICALLBOOM
APICALLBOOM_TYPE_NO_JWT_IMPL &APICALLBOOM_PARAM
)) {
Q_UNUSED(_APICALLBOOM)

gServerStats.Success.inc();

return QJsonObject({
Expand Down
12 changes: 6 additions & 6 deletions App/Server/StaticModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private slots:
openAPI_json,
"openAPI.json",
(
APICallBoom<false> &_APICALLBOOM
APICALLBOOM_TYPE_NO_JWT_DECL &APICALLBOOM_PARAM
),
""
);
Expand All @@ -51,7 +51,7 @@ private slots:
openAPI_yaml,
"openAPI.yaml",
(
APICallBoom<false> &_APICALLBOOM
APICALLBOOM_TYPE_NO_JWT_DECL &APICALLBOOM_PARAM
),
""
);
Expand All @@ -61,7 +61,7 @@ private slots:
QVariant REST_GET_OR_POST(
swaggerui,
(
APICallBoom<false> &_APICALLBOOM
APICALLBOOM_TYPE_NO_JWT_DECL &APICALLBOOM_PARAM
),
""
);
Expand All @@ -70,7 +70,7 @@ private slots:
stats_json,
"stats.json",
(
APICallBoom<false> &_APICALLBOOM,
APICALLBOOM_TYPE_NO_JWT_DECL &APICALLBOOM_PARAM,
bool _full = false
),
""
Expand All @@ -79,15 +79,15 @@ private slots:
QVariant REST_GET_OR_POST(
version,
(
APICallBoom<false> &_APICALLBOOM
APICALLBOOM_TYPE_NO_JWT_DECL &APICALLBOOM_PARAM
),
""
);

QVariant REST_GET_OR_POST(
ping,
(
APICallBoom<false> &_APICALLBOOM
APICALLBOOM_TYPE_NO_JWT_DECL &APICALLBOOM_PARAM
),
""
);
Expand Down
7 changes: 4 additions & 3 deletions App/Server/clsAPIObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "clsAPIObject.h"
#include "APICache.hpp"
#include "Interfaces/Server/APICallBoom.h"

namespace Targoman::API::Server {

Expand Down Expand Up @@ -62,15 +63,15 @@ clsAPIObject::clsAPIObject(
foreach (const QByteArray &ParamName, _method.parameterNames()) {
QString ParameterTypeName = parameterTypes.at(i);

/*if (ParameterTypeName.startsWith(APICALLBOOM_JWT_TYPE_NAME)) {
/*if (ParameterTypeName.startsWith(APICALLBOOM_TYPE_JWT_DECL)) {
this->ParamNames.append("JWT");
this->ParamTypesName.append(PARAM_JWT);
this->ParamTypesID.append(QMetaType::type(PARAM_JWT));
this->BaseMethod.DefaultValues[0] = {};
} else */if (ParameterTypeName.startsWith(APICALLBOOM_TYPE_NAME_BASE)) { //APICALLBOOM_NO_TYPE_NAME)) {
} else */if (ParameterTypeName.startsWith(APICALLBOOM_TYPE_BASE_STR)) { //APICALLBOOM_TYPE_NO_JWT_DECL)) {
--this->RequiredParamsCount;
this->BaseMethod.DefaultValues.removeAt(0);
if (ParameterTypeName.startsWith(APICALLBOOM_JWT_TYPE_NAME))
if (ParameterTypeName.startsWith(APICALLBOOM_TYPE_JWT_DECL_STR))
this->RequiresJWT = true;
} else {
QByteArray ParamNameNoUnderScore = (ParamName.startsWith('_') ? ParamName.mid(1) : ParamName);
Expand Down
5 changes: 0 additions & 5 deletions App/Server/clsAPIObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@

namespace Targoman::API::Server {

#define APICALLBOOM_TYPE_NAME_BASE "APICallBoom<"
#define APICALLBOOM_NO_TYPE_NAME "APICallBoom<false>"
#define APICALLBOOM_JWT_TYPE_NAME "APICallBoom<true>"
#define APICALLBOOM_PARAM_NAME "_APICALLBOOM"

#define PARAM_JWT "TAPI::JWT_t"
#define PARAM_COOKIES "TAPI::COOKIES_t"
#define PARAM_REMOTE_IP "TAPI::RemoteIP_t"
Expand Down
4 changes: 2 additions & 2 deletions App/Server/clsRequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ clsRequestHandler::stuResult clsRequestHandler::run(

QScopedPointer<intfAPICallBoom> APICALLBOOM;
if (_apiObject->requiresJWT())
APICALLBOOM.reset(new APICallBoom<true>());
APICALLBOOM.reset(new APICALLBOOM_TYPE_JWT_DECL());
else
APICALLBOOM.reset(new APICallBoom<false>());
APICALLBOOM.reset(new APICALLBOOM_TYPE_NO_JWT_DECL());

try {
for (auto QueryIter = _queries.begin(); QueryIter != _queries.end(); ++QueryIter)
Expand Down
4 changes: 2 additions & 2 deletions Interfaces/AAA/Accounting_Interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ QVariant intfAccountUserAssets::apiGET(GET_METHOD_ARGS_IMPL_APICALL) {
}

bool intfAccountUserAssets::apiUPDATEsetAsPrefered(
APICallBoom<true> &_APICALLBOOM,
APICALLBOOM_TYPE_JWT_IMPL &APICALLBOOM_PARAM,
TAPI::PKsByPath_t _pksByPath
) {
bool Ok;
Expand All @@ -444,7 +444,7 @@ bool intfAccountUserAssets::apiUPDATEsetAsPrefered(
}

bool intfAccountUserAssets::apiUPDATEdisablePackage(
APICallBoom<true> &_APICALLBOOM,
APICALLBOOM_TYPE_JWT_IMPL &APICALLBOOM_PARAM,
TAPI::PKsByPath_t _pksByPath
) {
bool Ok;
Expand Down
4 changes: 2 additions & 2 deletions Interfaces/AAA/Accounting_Interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private slots:
bool REST_UPDATE(
disablePackage,
(
APICallBoom<true> &_APICALLBOOM,
APICALLBOOM_TYPE_JWT_DECL &APICALLBOOM_PARAM,
TAPI::PKsByPath_t _pksByPath
),
"Mark a user Asset banned by priviledged user"
Expand All @@ -92,7 +92,7 @@ private slots:
bool REST_UPDATE(
setAsPrefered,
(
APICallBoom<true> &_APICALLBOOM,
APICALLBOOM_TYPE_JWT_DECL &APICALLBOOM_PARAM,
TAPI::PKsByPath_t _pksByPath
),
"Mark a user Asset as prefered"
Expand Down
12 changes: 6 additions & 6 deletions Interfaces/AAA/intfAccountingBasedModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ stuActiveCredit intfAccountingBasedModule::activeAccountObject(quint64 _usrID) {
}

void intfAccountingBasedModule::checkUsageIsAllowed(
intfAPICallBoom &_APICALLBOOM,
intfAPICallBoom &APICALLBOOM_PARAM,
const ServiceUsage_t &_requestedUsage
) {
QJsonObject Privs = _APICALLBOOM.getJWTPrivsObject();
Expand Down Expand Up @@ -309,7 +309,7 @@ stuActiveCredit intfAccountingBasedModule::findBestMatchedCredit(
}

Targoman::API::AAA::stuPreVoucher intfAccountingBasedModule::apiPOSTaddToBasket(
APICallBoom<true> &_APICALLBOOM,
APICALLBOOM_TYPE_JWT_IMPL &APICALLBOOM_PARAM,
TAPI::SaleableCode_t _saleableCode,
Targoman::API::AAA::OrderAdditives_t _orderAdditives,
qreal _qty,
Expand Down Expand Up @@ -745,7 +745,7 @@ Targoman::API::AAA::stuPreVoucher intfAccountingBasedModule::apiPOSTaddToBasket(
}

Targoman::API::AAA::stuPreVoucher intfAccountingBasedModule::apiPOSTremoveBasketItem(
APICallBoom<true> &_APICALLBOOM,
APICALLBOOM_TYPE_JWT_IMPL &APICALLBOOM_PARAM,
// quint64 _orderID, //it is uasID
TAPI::MD5_t _itemUUID,
Targoman::API::AAA::stuPreVoucher _lastPreVoucher
Expand Down Expand Up @@ -811,7 +811,7 @@ Targoman::API::AAA::stuPreVoucher intfAccountingBasedModule::apiPOSTremoveBasket
}
/*
Targoman::API::AAA::stuPreVoucher intfAccountingBasedModule::apiPOSTupdateBasketItem(
APICallBoom<true> &_APICALLBOOM,
APICALLBOOM_TYPE_JWT_IMPL &APICALLBOOM_PARAM,
TAPI::MD5_t _itemUUID,
quint16 _new_qty, ///TODO: float
Targoman::API::AAA::stuPreVoucher _lastPreVoucher
Expand Down Expand Up @@ -1084,7 +1084,7 @@ void checkVoucherItemForTrustedActionSanity(stuVoucherItemForTrustedAction &_dat
}

bool intfAccountingBasedModule::apiPOSTprocessVoucherItem(
APICallBoom<false> &_APICALLBOOM,
APICALLBOOM_TYPE_NO_JWT_IMPL &APICALLBOOM_PARAM,
Targoman::API::AAA::stuVoucherItemForTrustedAction _data
) {
checkVoucherItemForTrustedActionSanity(_data);
Expand All @@ -1093,7 +1093,7 @@ bool intfAccountingBasedModule::apiPOSTprocessVoucherItem(
}

bool intfAccountingBasedModule::apiPOSTcancelVoucherItem(
APICallBoom<false> &_APICALLBOOM,
APICALLBOOM_TYPE_NO_JWT_IMPL &APICALLBOOM_PARAM,
Targoman::API::AAA::stuVoucherItemForTrustedAction _data
) {
checkVoucherItemForTrustedActionSanity(_data);
Expand Down
18 changes: 8 additions & 10 deletions Interfaces/AAA/intfAccountingBasedModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class intfAccountingBasedModule : public API::intfSQLBasedWithActionLogsModule
virtual bool isUnlimited(const UsageLimits_t& _limits) const = 0;
virtual bool isEmpty(const UsageLimits_t& _limits) const = 0;

void checkUsageIsAllowed(intfAPICallBoom &_APICALLBOOM, const ServiceUsage_t& _requestedUsage);
void checkUsageIsAllowed(intfAPICallBoom &APICALLBOOM_PARAM, const ServiceUsage_t& _requestedUsage);

virtual bool increaseDiscountUsage(
const Targoman::API::AAA::stuVoucherItem &_voucherItem
Expand Down Expand Up @@ -124,7 +124,7 @@ protected slots:
Targoman::API::AAA::stuPreVoucher REST_POST(
addToBasket,
(
APICallBoom<true> &_APICALLBOOM,
APICALLBOOM_TYPE_JWT_DECL &APICALLBOOM_PARAM,
TAPI::SaleableCode_t _saleableCode,
Targoman::API::AAA::OrderAdditives_t _orderAdditives = {},
qreal _qty = 1,
Expand All @@ -139,7 +139,7 @@ protected slots:
Targoman::API::AAA::stuPreVoucher REST_POST(
removeBasketItem,
(
APICallBoom<true> &_APICALLBOOM,
APICALLBOOM_TYPE_JWT_DECL &APICALLBOOM_PARAM,
TAPI::MD5_t _itemUUID,
Targoman::API::AAA::stuPreVoucher _lastPreVoucher
),
Expand All @@ -150,7 +150,7 @@ protected slots:
// Targoman::API::AAA::stuPreVoucher REST_POST(
// updateBasketItem,
// (
// APICallBoom<true> &_APICALLBOOM,
// APICALLBOOM_TYPE_JWT_DECL &APICALLBOOM_PARAM,
// TAPI::MD5_t _itemUUID,
// quint16 _new_qty,
// Targoman::API::AAA::stuPreVoucher _lastPreVoucher
Expand All @@ -162,7 +162,7 @@ protected slots:
bool REST_POST(
processVoucherItem,
(
APICallBoom<false> &_APICALLBOOM,
APICALLBOOM_TYPE_NO_JWT_DECL &APICALLBOOM_PARAM,
Targoman::API::AAA::stuVoucherItemForTrustedAction _data
),
"Process voucher item"
Expand All @@ -171,7 +171,7 @@ protected slots:
bool REST_POST(
cancelVoucherItem,
(
APICallBoom<false> &_APICALLBOOM,
APICALLBOOM_TYPE_NO_JWT_DECL &APICALLBOOM_PARAM,
Targoman::API::AAA::stuVoucherItemForTrustedAction _data
),
"Cancel voucher item"
Expand All @@ -186,21 +186,19 @@ protected slots:
Q_UNUSED(_assetItem)
};
virtual void applyAssetAdditives(
intfAPICallBoom &_APICALLBOOM,
Q_DECL_UNUSED intfAPICallBoom &APICALLBOOM_PARAM,
INOUT stuAssetItem& _assetItem,
const OrderAdditives_t& _orderAdditives
) {
Q_UNUSED(_APICALLBOOM);
Q_UNUSED(_assetItem)
Q_UNUSED(_orderAdditives)
};
virtual void applyReferrer(
intfAPICallBoom &_APICALLBOOM,
Q_DECL_UNUSED intfAPICallBoom &APICALLBOOM_PARAM,
INOUT stuAssetItem& AssetItem,
QString _referrer,
TAPI::JSON_t _extraReferrerParams
) {
Q_UNUSED(_APICALLBOOM);
Q_UNUSED(AssetItem);
Q_UNUSED(_referrer);
Q_UNUSED(_extraReferrerParams);
Expand Down
Loading