Pass strings to api_post and api_get directly, ensure distro_series is null if distro_series_link is empty
This commit is contained in:
parent
65fe1e54f5
commit
6870125249
@ -211,14 +211,14 @@ bool launchpad::is_authenticated() const {
|
||||
std::string launchpad::build_full_url(const std::string& endpoint) const {
|
||||
if (endpoint.rfind("http", 0) == 0) {
|
||||
return endpoint;
|
||||
} else if (endpoint != "") {
|
||||
} else if (!endpoint.empty()) {
|
||||
return service_root + "/" + api_version + "/" + endpoint;
|
||||
}
|
||||
std::cerr << "Internal error: endpoint is empty" << std::endl;
|
||||
return "";
|
||||
}
|
||||
|
||||
std::optional<std::string> launchpad::api_get(const std::string& endpoint, const std::map<std::string, std::string>& params) const {
|
||||
std::optional<std::string> launchpad::api_get(const std::string endpoint, const std::map<std::string, std::string> params) const {
|
||||
std::string url = build_full_url(endpoint);
|
||||
if (url.empty()) {
|
||||
if (!params.empty()) {
|
||||
@ -296,10 +296,10 @@ std::optional<std::string> launchpad::api_get(const std::string& endpoint, const
|
||||
}
|
||||
|
||||
std::optional<std::string> launchpad::api_post(
|
||||
const std::string& endpoint,
|
||||
const std::map<std::string, std::string>& params,
|
||||
const std::string endpoint,
|
||||
const std::map<std::string, std::string> params,
|
||||
bool build_endpoint,
|
||||
const std::string& token_secret_override
|
||||
const std::string token_secret_override
|
||||
) {
|
||||
if (endpoint.empty()) {
|
||||
if (!params.empty()) {
|
||||
|
@ -69,11 +69,11 @@ public:
|
||||
// API Methods
|
||||
std::optional<archive> get_archive(const std::string& distribution_name);
|
||||
|
||||
std::optional<std::string> api_get(const std::string& endpoint = "", const std::map<std::string, std::string>& params = {}) const;
|
||||
std::optional<std::string> api_post(const std::string& endpoint = "",
|
||||
const std::map<std::string, std::string>& params = {},
|
||||
std::optional<std::string> api_get(const std::string endpoint = "", const std::map<std::string, std::string> params = {}) const;
|
||||
std::optional<std::string> api_post(const std::string endpoint = "",
|
||||
const std::map<std::string, std::string> params = {},
|
||||
bool build_endpoint = true,
|
||||
const std::string& token_secret_override = "");
|
||||
const std::string token_secret_override = "");
|
||||
std::optional<std::string> api_patch(const std::string& endpoint = "", const nlohmann::json& data = nlohmann::json{});
|
||||
std::optional<std::string> api_delete(const std::string& endpoint = "");
|
||||
|
||||
|
@ -82,6 +82,7 @@ void source_package_publishing_history::set_lp(launchpad* lp_ptr) {
|
||||
}
|
||||
|
||||
const std::optional<class distro_series> source_package_publishing_history::getDistroSeries() {
|
||||
if (distro_series_link.empty()) return std::nullopt;
|
||||
auto response = lp->api_get(distro_series_link);
|
||||
if (!response) return std::nullopt;
|
||||
auto data = nlohmann::json::parse(response.value());
|
||||
|
Loading…
x
Reference in New Issue
Block a user