From f36567c546e24e2e3d84e898c114ac87f23a7fff Mon Sep 17 00:00:00 2001 From: Dominik Meyer Date: Wed, 9 Oct 2024 15:46:51 +0200 Subject: [PATCH] feat: make upload method public --- include/Redmine/API.hpp | 19 ++++++++++--------- src/Redmine/API.cpp | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/Redmine/API.hpp b/include/Redmine/API.hpp index 6821442..8aced1b 100644 --- a/include/Redmine/API.hpp +++ b/include/Redmine/API.hpp @@ -60,15 +60,7 @@ namespace Redmine void post(const std::string &path, const nlohmann::json &data) const; void processGenericErrors_(httplib::Result &res) const; - /** - * @brief upload a file to the redmine server - * - * @param file - the file to upload - * @param filename - the filename used inside redmine - * @return std::string - the redmine internal token (reference) for the uploaded file - */ - std::string upload_(const std::filesystem::path &file, const std::string &filename) const; - + public: /** @@ -140,6 +132,15 @@ namespace Redmine * @return std::vector */ std::vector getIssues(const Redmine::Filter& filter = {}) const; + + /** + * @brief upload a file to the redmine server + * + * @param file - the file to upload + * @param filename - the filename used inside redmine + * @return std::string - the redmine internal token (reference) for the uploaded file + */ + std::string upload(const std::filesystem::path &file, const std::string &filename) const; /*@}*/ diff --git a/src/Redmine/API.cpp b/src/Redmine/API.cpp index 9f3f515..844d538 100644 --- a/src/Redmine/API.cpp +++ b/src/Redmine/API.cpp @@ -145,7 +145,7 @@ void Redmine::API::put(const std::string &path, const nlohmann::json &data) con DLOG_S(INFO) << "post successful"; } -std::string Redmine::API::upload_(const std::filesystem::path &file, const std::string &filename) const +std::string Redmine::API::upload(const std::filesystem::path &file, const std::string &filename) const { httplib::Client client{redmineApiURL_}; client.set_basic_auth(authToken_, ""); @@ -234,7 +234,7 @@ bool Redmine::API::ready() const void Redmine::API::uploadFileToProject(const std::uint64_t projectId, const std::string &filePath, const std::string &fileName, const std::string &description, const std::uint32_t version) const { - std::string token = upload_(filePath, fileName); + std::string token = upload(filePath, fileName); nlohmann::json file; file["token"] = token;