feat: make upload method public

This commit is contained in:
Dominik Meyer 2024-10-09 15:46:51 +02:00
parent 7f269901c5
commit f36567c546
Signed by: byterazor
GPG Key ID: EABDA0FD5981BC97
2 changed files with 12 additions and 11 deletions

View File

@ -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<Redmine::Issue>
*/
std::vector<Redmine::Issue> 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;
/*@}*/

View File

@ -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;