refactor: do not automatically extend fetch path

This commit is contained in:
Dominik Meyer 2024-08-11 16:46:53 +02:00
parent 74d0b209b7
commit 3e508c344f
Signed by: byterazor
GPG Key ID: EABDA0FD5981BC97

View File

@ -98,7 +98,7 @@ void Redmine::API::processGenericErrors_(httplib::Result &res) const
nlohmann::json Redmine::API::get(const std::string &path) const
{
DLOG_S(INFO) << "getting API endpoint " << path+".json" << " from " <<redmineApiURL_;
DLOG_S(INFO) << "getting API endpoint " << path << " from " <<redmineApiURL_;
httplib::Client client{redmineApiURL_};
httplib::Headers headers =
@ -107,7 +107,7 @@ void Redmine::API::processGenericErrors_(httplib::Result &res) const
{ "Content-Type", "application/json"}
};
auto res = client.Get(path + ".json" , headers);
auto res = client.Get(path , headers);
processGenericErrors_(res);
@ -118,11 +118,11 @@ void Redmine::API::processGenericErrors_(httplib::Result &res) const
void Redmine::API::put(const std::string &path, const nlohmann::json &data) const
{
DLOG_S(INFO) << "putting API endpoint " << path+".json" << " from " <<redmineApiURL_;
DLOG_S(INFO) << "putting API endpoint " << path << " from " <<redmineApiURL_;
httplib::Client client{redmineApiURL_};
client.set_basic_auth(authToken_, "");
auto res = client.Put(path + ".json", data.dump(),"application/json");
auto res = client.Put(path, data.dump(),"application/json");
processGenericErrors_(res);
@ -131,11 +131,11 @@ void Redmine::API::put(const std::string &path, const nlohmann::json &data) con
void Redmine::API::post(const std::string &path, const nlohmann::json &data) const
{
DLOG_S(INFO) << "posting to API endpoint " << path+".json" << " at " <<redmineApiURL_;
DLOG_S(INFO) << "posting to API endpoint " << path << " at " <<redmineApiURL_;
httplib::Client client{redmineApiURL_};
client.set_basic_auth(authToken_, "");
auto res = client.Post(path + ".json", data.dump(),"application/json");
auto res = client.Post(path, data.dump(),"application/json");
processGenericErrors_(res);
@ -173,7 +173,7 @@ std::string Redmine::API::upload_(const std::filesystem::path &file, const std::
Redmine::User Redmine::API::getMyAccount() const
{
nlohmann::json userInfo = get("/my/account");
nlohmann::json userInfo = get("/my/account.json");
return Redmine::User{userInfo};
}
@ -181,13 +181,13 @@ Redmine::User Redmine::API::getMyAccount() const
void Redmine::API::setMyAccount(const Redmine::User &user) const
{
put("/my/account", user.get());
put("/my/account.json", user.get());
}
std::vector<Redmine::Project> Redmine::API::getProjects() const
{
nlohmann::json projectList = get("/projects");
nlohmann::json projectList = get("/projects.json");
std::vector<Redmine::Project> projects;
for (auto it = projectList["projects"].begin(); it != projectList["projects"].end(); ++it)
@ -202,7 +202,7 @@ std::vector<Redmine::Project> Redmine::API::getProjects() const
std::vector<Redmine::IssueStatus> Redmine::API::getIssueStatusList()
{
nlohmann::json statusList = get("/issue_statuses");
nlohmann::json statusList = get("/issue_statuses.json");
issueStatusList_.clear();
@ -241,5 +241,5 @@ void Redmine::API::uploadFileToProject(const std::uint64_t projectId, const std:
nlohmann::json upload;
upload["file"] = file;
post("/projects/"+std::to_string(projectId)+"/files", upload);
post("/projects/"+std::to_string(projectId)+"/files.json", upload);
}