diff --git a/src/source_package_publishing_history.cpp b/src/source_package_publishing_history.cpp
index 5d59d06..be391a7 100644
--- a/src/source_package_publishing_history.cpp
+++ b/src/source_package_publishing_history.cpp
@@ -13,9 +13,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-#include "build.h"
#include "source_package_publishing_history.h"
-#include "utils.h"
+#include "build.h"
#include "launchpad.h"
#include
#include
@@ -46,6 +45,10 @@ void source_package_publishing_history::parse_json(const std::string& json_data)
if (data.contains("self_link") && data["self_link"].is_string()) {
self_link = data["self_link"].get();
}
+
+ if (data.contains("distro_series_link") && data["distro_series_link"].is_string()) {
+ distro_series_link = data["distro_series_link"].get();
+ }
} catch (const std::exception& e) {
std::cerr << "Error parsing source JSON: " << e.what() << std::endl;
}
@@ -76,3 +79,15 @@ std::generator source_package_publishing_history::getBuilds() const {
void source_package_publishing_history::set_lp(launchpad* lp_ptr) {
lp = lp_ptr;
}
+
+const std::optional source_package_publishing_history::getDistroSeries() {
+ auto response = lp->api_get(distro_series_link);
+ if (!response) return std::nullopt;
+ auto data = nlohmann::json::parse(response.value());
+ auto ds = distro_series::parse(data.dump());
+ if (ds) {
+ ds->set_lp(lp);
+ return ds;
+ }
+ return std::nullopt;
+}
diff --git a/src/source_package_publishing_history.h b/src/source_package_publishing_history.h
index cb1d4ab..4799c1b 100644
--- a/src/source_package_publishing_history.h
+++ b/src/source_package_publishing_history.h
@@ -19,6 +19,7 @@
#include
#include
#include
+#include "distro_series.h"
class launchpad;
class build;
@@ -36,12 +37,13 @@ public:
source_package_publishing_history();
~source_package_publishing_history();
- // Add static parse method declaration
static std::optional parse(const std::string& json_data);
void parse_json(const std::string& json_data);
std::generator getBuilds() const;
+ std::optional distro_series = getDistroSeries();
+ std::string distro_series_link;
std::string self_link;
std::string source_package_name;
std::string source_package_version;
@@ -50,6 +52,7 @@ public:
private:
launchpad* lp;
+ const std::optional getDistroSeries();
};
#endif // SOURCE_PACKAGE_PUBLISHING_HISTORY