MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / latestVersions

Method latestVersions

launcher/modplatform/modrinth/ModrinthAPI.cpp:67–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67auto ModrinthAPI::latestVersions(const QStringList& hashes,
68 QString hash_format,
69 std::list<Version> mcVersions,
70 ModLoaderTypes loaders,
71 QByteArray* response) -> NetJob::Ptr
72{
73 auto* netJob = new NetJob(QString("Modrinth::GetLatestVersions"), APPLICATION->network());
74
75 QJsonObject body_obj;
76
77 Json::writeStringList(body_obj, "hashes", hashes);
78 Json::writeString(body_obj, "algorithm", hash_format);
79
80 Json::writeStringList(body_obj, "loaders", getModLoaderStrings(loaders));
81
82 QStringList game_versions;
83 for (auto& ver : mcVersions) {
84 game_versions.append(ver.toString());
85 }
86 Json::writeStringList(body_obj, "game_versions", game_versions);
87
88 QJsonDocument body(body_obj);
89 auto body_raw = body.toJson();
90
91 netJob->addNetAction(Net::Upload::makeByteArray(QString(BuildConfig.MODRINTH_PROD_URL + "/version_files/update"), response, body_raw));
92
93 QObject::connect(netJob, &NetJob::finished, [response] { delete response; });
94
95 return netJob;
96}
97
98auto ModrinthAPI::getProjects(QStringList addonIds, QByteArray* response) const -> NetJob*
99{

Callers 1

executeTaskMethod · 0.80

Calls 8

QStringClass · 0.85
writeStringListFunction · 0.85
writeStringFunction · 0.85
networkMethod · 0.80
appendMethod · 0.80
toJsonMethod · 0.80
addNetActionMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected