diff --git a/src/api/controller/path/block.hpp b/src/api/controller/path/block.hpp index 0c071a07..c95d947b 100644 --- a/src/api/controller/path/block.hpp +++ b/src/api/controller/path/block.hpp @@ -15,9 +15,9 @@ #ifndef BlockController_hpp #define BlockController_hpp -#include "dto/BlockDetailsDto.hpp" -#include "dto/TransactionDetailsDto.hpp" -#include "controller/ApiCoreInfoComponent.hpp" +#include "modal/block/details.hpp" +#include "modal/transaction/details.hpp" +#include "controller/ApiCoreInfo.hpp" #include "oatpp/web/server/api/ApiController.hpp" #include "oatpp/core/macro/codegen.hpp" @@ -34,7 +34,7 @@ */ class BlockController : public oatpp::web::server::api::ApiController { private: - OATPP_COMPONENT(std::shared_ptr, m_core_info); + OATPP_COMPONENT(std::shared_ptr, m_core_info); public: explicit BlockController(OATPP_COMPONENT(std::shared_ptr, objectMapper)) : oatpp::web::server::api::ApiController(objectMapper) @@ -45,7 +45,7 @@ public: info->summary = "Get a block by its hash or height (ID)"; info->addTag("Block"); info->pathParams["identifier"].description = "The hash (hex string) or height (integer) of the block to retrieve."; - info->addResponse>(Status::CODE_200, "application/json"); + info->addResponse>(Status::CODE_200, "application/json"); info->addResponse(Status::CODE_404, "text/plain"); info->addResponse(Status::CODE_400, "text/plain"); } @@ -77,7 +77,7 @@ public: } // Common logic to populate the DTO - auto blockDetails = BlockDetailsDto::createShared(); + auto blockDetails = BlockDetailsModel::createShared(); blockDetails->id = rpc_details.id; blockDetails->height = rpc_details.height; @@ -99,16 +99,16 @@ public: blockDetails->miner_text_info = rpc_details.miner_text_info; blockDetails->type = rpc_details.type; - auto tx_details_list = oatpp::List>::createShared(); + auto tx_details_list = oatpp::List>::createShared(); for(const auto& tx_rpc_info : rpc_details.transactions_details) { - auto tx_dto = TransactionDetailsDto::createShared(); - tx_dto->id = tx_rpc_info.id; - tx_dto->fee = tx_rpc_info.fee; - tx_dto->amount = tx_rpc_info.amount; - tx_dto->blob_size = tx_rpc_info.blob_size; - tx_dto->keeper_block = tx_rpc_info.keeper_block; - tx_dto->timestamp = tx_rpc_info.timestamp; - tx_details_list->push_back(tx_dto); + auto tx_model = TransactionDetailsModel::createShared(); + tx_model->id = tx_rpc_info.id; + tx_model->fee = tx_rpc_info.fee; + tx_model->amount = tx_rpc_info.amount; + tx_model->blob_size = tx_rpc_info.blob_size; + tx_model->keeper_block = tx_rpc_info.keeper_block; + tx_model->timestamp = tx_rpc_info.timestamp; + tx_details_list->push_back(tx_model); } blockDetails->transactions_details = tx_details_list; diff --git a/src/api/controller/path/block/hash.hpp b/src/api/controller/path/block/hash.hpp index 05b2a5c2..b949d3d7 100644 --- a/src/api/controller/path/block/hash.hpp +++ b/src/api/controller/path/block/hash.hpp @@ -15,9 +15,9 @@ #ifndef BlockByHashController_hpp #define BlockByHashController_hpp -#include "dto/BlockDetailsDto.hpp" -#include "dto/TransactionDetailsDto.hpp" -#include "controller/ApiCoreInfoComponent.hpp" +#include "modal/block/details.hpp" +#include "modal/transaction/details.hpp" +#include "controller/ApiCoreInfo.hpp" #include "oatpp/web/server/api/ApiController.hpp" #include "oatpp/core/macro/codegen.hpp" @@ -32,7 +32,7 @@ */ class BlockByHashController : public oatpp::web::server::api::ApiController { private: - OATPP_COMPONENT(std::shared_ptr, m_core_info); + OATPP_COMPONENT(std::shared_ptr, m_core_info); public: explicit BlockByHashController(OATPP_COMPONENT(std::shared_ptr, objectMapper)) : oatpp::web::server::api::ApiController(objectMapper) @@ -43,7 +43,7 @@ public: info->summary = "Get a block by its hash"; info->addTag("Block"); info->pathParams["hash"].description = "The hash of the block to retrieve"; - info->addResponse>(Status::CODE_200, "application/json"); + info->addResponse>(Status::CODE_200, "application/json"); info->addResponse(Status::CODE_404, "text/plain"); info->addResponse(Status::CODE_400, "text/plain"); } @@ -60,7 +60,7 @@ public: return createResponse(Status::CODE_404, "Block not found"); } - auto blockDetails = BlockDetailsDto::createShared(); + auto blockDetails = BlockDetailsModel::createShared(); blockDetails->id = rpc_details.id; blockDetails->height = rpc_details.height; @@ -82,16 +82,16 @@ public: blockDetails->miner_text_info = rpc_details.miner_text_info; blockDetails->type = rpc_details.type; - auto tx_details_list = oatpp::List>::createShared(); + auto tx_details_list = oatpp::List>::createShared(); for(const auto& tx_rpc_info : rpc_details.transactions_details) { - auto tx_dto = TransactionDetailsDto::createShared(); - tx_dto->id = tx_rpc_info.id; - tx_dto->fee = tx_rpc_info.fee; - tx_dto->amount = tx_rpc_info.amount; - tx_dto->blob_size = tx_rpc_info.blob_size; - tx_dto->keeper_block = tx_rpc_info.keeper_block; - tx_dto->timestamp = tx_rpc_info.timestamp; - tx_details_list->push_back(tx_dto); + auto tx_model = TransactionDetailsModel::createShared(); + tx_model->id = tx_rpc_info.id; + tx_model->fee = tx_rpc_info.fee; + tx_model->amount = tx_rpc_info.amount; + tx_model->blob_size = tx_rpc_info.blob_size; + tx_model->keeper_block = tx_rpc_info.keeper_block; + tx_model->timestamp = tx_rpc_info.timestamp; + tx_details_list->push_back(tx_model); } blockDetails->transactions_details = tx_details_list; diff --git a/src/api/controller/path/block/id.hpp b/src/api/controller/path/block/id.hpp index bf367d02..781c5335 100644 --- a/src/api/controller/path/block/id.hpp +++ b/src/api/controller/path/block/id.hpp @@ -15,9 +15,9 @@ #ifndef BlockByIdController_hpp #define BlockByIdController_hpp -#include "dto/BlockDetailsDto.hpp" -#include "dto/TransactionDetailsDto.hpp" -#include "controller/ApiCoreInfoComponent.hpp" +#include "modal/block/details.hpp" +#include "modal/transaction/details.hpp" +#include "controller/ApiCoreInfo.hpp" #include "oatpp/web/server/api/ApiController.hpp" #include "oatpp/core/macro/codegen.hpp" @@ -32,7 +32,7 @@ */ class BlockByIdController : public oatpp::web::server::api::ApiController { private: - OATPP_COMPONENT(std::shared_ptr, m_core_info); + OATPP_COMPONENT(std::shared_ptr, m_core_info); public: explicit BlockByIdController(OATPP_COMPONENT(std::shared_ptr, objectMapper)) : oatpp::web::server::api::ApiController(objectMapper) @@ -43,7 +43,7 @@ public: info->summary = "Get a block by its ID (height)"; info->addTag("Block"); info->pathParams["id"].description = "The ID (height) of the block to retrieve"; - info->addResponse>(Status::CODE_200, "application/json"); + info->addResponse>(Status::CODE_200, "application/json"); info->addResponse(Status::CODE_404, "text/plain"); } ENDPOINT("GET", "/block/id/{id}", getBlockById, PATH(UInt64, id)) { @@ -53,7 +53,7 @@ public: return createResponse(Status::CODE_404, "Block not found"); } - auto blockDetails = BlockDetailsDto::createShared(); + auto blockDetails = BlockDetailsModel::createShared(); blockDetails->id = rpc_details.id; blockDetails->height = rpc_details.height; @@ -75,16 +75,16 @@ public: blockDetails->miner_text_info = rpc_details.miner_text_info; blockDetails->type = rpc_details.type; - auto tx_details_list = oatpp::List>::createShared(); + auto tx_details_list = oatpp::List>::createShared(); for(const auto& tx_rpc_info : rpc_details.transactions_details) { - auto tx_dto = TransactionDetailsDto::createShared(); - tx_dto->id = tx_rpc_info.id; - tx_dto->fee = tx_rpc_info.fee; - tx_dto->amount = tx_rpc_info.amount; - tx_dto->blob_size = tx_rpc_info.blob_size; - tx_dto->keeper_block = tx_rpc_info.keeper_block; - tx_dto->timestamp = tx_rpc_info.timestamp; - tx_details_list->push_back(tx_dto); + auto tx_model = TransactionDetailsModel::createShared(); + tx_model->id = tx_rpc_info.id; + tx_model->fee = tx_rpc_info.fee; + tx_model->amount = tx_rpc_info.amount; + tx_model->blob_size = tx_rpc_info.blob_size; + tx_model->keeper_block = tx_rpc_info.keeper_block; + tx_model->timestamp = tx_rpc_info.timestamp; + tx_details_list->push_back(tx_model); } blockDetails->transactions_details = tx_details_list; diff --git a/src/api/controller/path/info.hpp b/src/api/controller/path/info.hpp index a6e9f5a7..9298194f 100644 --- a/src/api/controller/path/info.hpp +++ b/src/api/controller/path/info.hpp @@ -18,7 +18,7 @@ #include "oatpp/web/server/api/ApiController.hpp" #include "oatpp/core/macro/codegen.hpp" #include "version.h" -#include "dto/VersionDto.hpp" +#include "modal/meta/version.hpp" #include OATPP_CODEGEN_BEGIN(ApiController) @@ -37,17 +37,17 @@ public: info->addTag("Info"); info->summary = "Get API version"; info->description = "Returns the current version of the API."; - info->addResponse>(Status::CODE_200, "application/json"); + info->addResponse>(Status::CODE_200, "application/json"); } ENDPOINT("GET", "/info/version", version) { - auto dto = VersionDto::createShared(); - dto->version = PROJECT_VERSION; - dto->version_long = PROJECT_VERSION_LONG; - dto->major = PROJECT_MAJOR_VERSION; - dto->minor = PROJECT_MINOR_VERSION; - dto->revision = PROJECT_REVISION; - return createDtoResponse(Status::CODE_200, dto); + auto model = VersionModel::createShared(); + model->version = PROJECT_VERSION; + model->version_long = PROJECT_VERSION_LONG; + model->major = PROJECT_MAJOR_VERSION; + model->minor = PROJECT_MINOR_VERSION; + model->revision = PROJECT_REVISION; + return createDtoResponse(Status::CODE_200, model); } }; diff --git a/src/api/controller/path/info/version.hpp b/src/api/controller/path/info/version.hpp index 61256a8b..1cfeb72f 100644 --- a/src/api/controller/path/info/version.hpp +++ b/src/api/controller/path/info/version.hpp @@ -12,20 +12,46 @@ // SPDX‑License‑Identifier: EUPL-1.2 // -ENDPOINT_INFO(version) -{ - info->addTag("Info"); - info->summary = "Get API version"; - info->description = "Returns the current version of the API."; - info->addResponse>(Status::CODE_200, "application/json"); -} -ENDPOINT("GET", "/info/version", version) -{ - auto dto = VersionDto::createShared(); - dto->version = PROJECT_VERSION; - dto->version_long = PROJECT_VERSION_LONG; - dto->major = PROJECT_MAJOR_VERSION; - dto->minor = PROJECT_MINOR_VERSION; - dto->revision = PROJECT_REVISION; - return createDtoResponse(Status::CODE_200, dto); -} +#ifndef InfoVersionController_hpp +#define InfoVersionController_hpp + +#include "oatpp/web/server/api/ApiController.hpp" +#include "oatpp/core/macro/codegen.hpp" +#include "version.h" +#include "modal/meta/version.hpp" + +#include OATPP_CODEGEN_BEGIN(ApiController) + +/** + * Version Controller + */ +class InfoVersionController : public oatpp::web::server::api::ApiController { +public: + explicit InfoVersionController(OATPP_COMPONENT(std::shared_ptr, objectMapper)) + : oatpp::web::server::api::ApiController(objectMapper) + {} +public: + + ENDPOINT_INFO(version) + { + info->addTag("Info"); + info->summary = "Get API version"; + info->description = "Returns the current version of the API."; + info->addResponse>(Status::CODE_200, "application/json"); + } + ENDPOINT("GET", "/info/version", version) + { + auto model = VersionModel::createShared(); + model->version = PROJECT_VERSION; + model->version_long = PROJECT_VERSION_LONG; + model->major = PROJECT_MAJOR_VERSION; + model->minor = PROJECT_MINOR_VERSION; + model->revision = PROJECT_REVISION; + return createDtoResponse(Status::CODE_200, model); + } + +}; + +#include OATPP_CODEGEN_END(ApiController) + +#endif /* InfoVersionController_hpp */ diff --git a/src/api/dto/BlockDetailsDto.hpp b/src/api/modal/block/details.hpp similarity index 84% rename from src/api/dto/BlockDetailsDto.hpp rename to src/api/modal/block/details.hpp index d8199d69..865c12d2 100644 --- a/src/api/dto/BlockDetailsDto.hpp +++ b/src/api/modal/block/details.hpp @@ -12,20 +12,20 @@ // SPDX‑License‑Identifier: EUPL-1.2 // -#ifndef BlockDetailsDto_hpp -#define BlockDetailsDto_hpp +#ifndef BlockDetailsModel_hpp +#define BlockDetailsModel_hpp -#include "TransactionDetailsDto.hpp" +#include "../transaction/details.hpp" #include "oatpp/core/macro/codegen.hpp" #include "oatpp/core/Types.hpp" #include OATPP_CODEGEN_BEGIN(DTO) /** - * DTO for detailed block information. + * Model for detailed block information. */ -class BlockDetailsDto : public oatpp::DTO { - DTO_INIT(BlockDetailsDto, DTO); +class BlockDetailsModel : public oatpp::DTO { + DTO_INIT(BlockDetailsModel, DTO); DTO_FIELD(UInt64, actual_timestamp, "actual_timestamp"); DTO_FIELD(String, already_generated_coins, "already_generated_coins"); @@ -50,10 +50,10 @@ class BlockDetailsDto : public oatpp::DTO { DTO_FIELD(UInt64, timestamp, "timestamp"); DTO_FIELD(UInt64, total_fee, "total_fee"); DTO_FIELD(UInt64, total_txs_size, "total_txs_size"); - DTO_FIELD(List>, transactions_details, "transactions_details"); + DTO_FIELD(List>, transactions_details, "transactions_details"); DTO_FIELD(UInt32, type, "type"); }; #include OATPP_CODEGEN_END(DTO) -#endif /* BlockDetailsDto_hpp */ +#endif /* BlockDetailsModel_hpp */ diff --git a/src/api/dto/VersionDto.hpp b/src/api/modal/meta/version.hpp similarity index 83% rename from src/api/dto/VersionDto.hpp rename to src/api/modal/meta/version.hpp index 836ba3d3..e8734aa7 100644 --- a/src/api/dto/VersionDto.hpp +++ b/src/api/modal/meta/version.hpp @@ -12,17 +12,17 @@ // SPDX‑License‑Identifier: EUPL-1.2 // -#ifndef VersionDto_hpp -#define VersionDto_hpp +#ifndef VersionModel_hpp +#define VersionModel_hpp #include "oatpp/core/macro/codegen.hpp" #include "oatpp/core/Types.hpp" #include OATPP_CODEGEN_BEGIN(DTO) -class VersionDto final : public oatpp::DTO +class VersionModel final : public oatpp::DTO { - DTO_INIT(VersionDto, DTO); + DTO_INIT(VersionModel, DTO); DTO_FIELD(String, version); DTO_FIELD(String, version_long); @@ -33,4 +33,4 @@ class VersionDto final : public oatpp::DTO #include OATPP_CODEGEN_END(DTO) -#endif /* VersionDto_hpp */ +#endif /* VersionModel_hpp */ diff --git a/src/api/dto/TransactionDetailsDto.hpp b/src/api/modal/transaction/details.hpp similarity index 63% rename from src/api/dto/TransactionDetailsDto.hpp rename to src/api/modal/transaction/details.hpp index f283c0c1..57ab33d3 100644 --- a/src/api/dto/TransactionDetailsDto.hpp +++ b/src/api/modal/transaction/details.hpp @@ -12,8 +12,8 @@ // SPDX‑License‑Identifier: EUPL-1.2 // -#ifndef TransactionDetailsDto_hpp -#define TransactionDetailsDto_hpp +#ifndef TransactionDetailsModel_hpp +#define TransactionDetailsModel_hpp #include "oatpp/core/macro/codegen.hpp" #include "oatpp/core/Types.hpp" @@ -21,30 +21,30 @@ #include OATPP_CODEGEN_BEGIN(DTO) /** - * DTO for transaction attachments. + * Model for transaction attachments. */ -class TransactionAttachmentDto : public oatpp::DTO { - DTO_INIT(TransactionAttachmentDto, DTO); +class TransactionAttachmentModel : public oatpp::DTO { + DTO_INIT(TransactionAttachmentModel, DTO); DTO_FIELD(String, type, "type"); DTO_FIELD(String, short_view, "short_view"); DTO_FIELD(String, details_view, "details_view"); }; /** - * DTO for transaction extra data. + * Model for transaction extra data. */ -class TransactionExtraDto : public oatpp::DTO { - DTO_INIT(TransactionExtraDto, DTO); +class TransactionExtraModel : public oatpp::DTO { + DTO_INIT(TransactionExtraModel, DTO); DTO_FIELD(String, type, "type"); DTO_FIELD(String, short_view, "short_view"); DTO_FIELD(String, details_view, "details_view"); }; /** - * DTO for transaction inputs. + * Model for transaction inputs. */ -class TransactionInputDto : public oatpp::DTO { - DTO_INIT(TransactionInputDto, DTO); +class TransactionInputModel : public oatpp::DTO { + DTO_INIT(TransactionInputModel, DTO); DTO_FIELD(UInt64, amount, "amount"); DTO_FIELD(Vector, global_indexes, "global_indexes"); DTO_FIELD(String, htlc_origin, "htlc_origin"); @@ -53,10 +53,10 @@ class TransactionInputDto : public oatpp::DTO { }; /** - * DTO for transaction outputs. + * Model for transaction outputs. */ -class TransactionOutputDto : public oatpp::DTO { - DTO_INIT(TransactionOutputDto, DTO); +class TransactionOutputModel : public oatpp::DTO { + DTO_INIT(TransactionOutputModel, DTO); DTO_FIELD(UInt64, amount, "amount"); DTO_FIELD(UInt64, global_index, "global_index"); DTO_FIELD(Boolean, is_spent, "is_spent"); @@ -65,25 +65,25 @@ class TransactionOutputDto : public oatpp::DTO { }; /** - * DTO for detailed transaction information. + * Model for detailed transaction information. */ -class TransactionDetailsDto : public oatpp::DTO { - DTO_INIT(TransactionDetailsDto, DTO); +class TransactionDetailsModel : public oatpp::DTO { + DTO_INIT(TransactionDetailsModel, DTO); DTO_FIELD(UInt64, amount, "amount"); - DTO_FIELD(List>, attachments, "attachments"); + DTO_FIELD(List>, attachments, "attachments"); DTO_FIELD(String, blob, "blob"); DTO_FIELD(UInt64, blob_size, "blob_size"); - DTO_FIELD(List>, extra, "extra"); + DTO_FIELD(List>, extra, "extra"); DTO_FIELD(UInt64, fee, "fee"); DTO_FIELD(String, id, "id"); - DTO_FIELD(List>, ins, "ins"); + DTO_FIELD(List>, ins, "ins"); DTO_FIELD(Int64, keeper_block, "keeper_block"); DTO_FIELD(String, object_in_json, "object_in_json"); - DTO_FIELD(List>, outs, "outs"); + DTO_FIELD(List>, outs, "outs"); DTO_FIELD(String, pub_key, "pub_key"); DTO_FIELD(UInt64, timestamp, "timestamp"); }; #include OATPP_CODEGEN_END(DTO) -#endif /* TransactionDetailsDto_hpp */ +#endif /* TransactionDetailsModel_hpp */