feat: add some mod api calls
- Get Project: Already existed but required a specific caller type. This is more general. - Get Projects: A single call to multiple of the above Both providers support these calls. Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
@ -88,8 +88,19 @@ auto ModrinthAPI::latestVersions(const QStringList& hashes,
|
||||
QJsonDocument body(body_obj);
|
||||
auto body_raw = body.toJson();
|
||||
|
||||
netJob->addNetAction(Net::Upload::makeByteArray(
|
||||
QString(BuildConfig.MODRINTH_PROD_URL + "/version_files/update"), response, body_raw));
|
||||
netJob->addNetAction(Net::Upload::makeByteArray(QString(BuildConfig.MODRINTH_PROD_URL + "/version_files/update"), response, body_raw));
|
||||
|
||||
QObject::connect(netJob, &NetJob::finished, [response] { delete response; });
|
||||
|
||||
return netJob;
|
||||
}
|
||||
|
||||
auto ModrinthAPI::getProjects(QStringList addonIds, QByteArray* response) const -> NetJob::Ptr
|
||||
{
|
||||
auto netJob = new NetJob(QString("Modrinth::GetProjects"), APPLICATION->network());
|
||||
auto searchUrl = getMultipleModInfoURL(addonIds);
|
||||
|
||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), response));
|
||||
|
||||
QObject::connect(netJob, &NetJob::finished, [response] { delete response; });
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "modplatform/ModAPI.h"
|
||||
#include "modplatform/ModIndex.h"
|
||||
#include "modplatform/helpers/NetworkModAPI.h"
|
||||
#include "net/NetJob.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@ -48,6 +47,8 @@ class ModrinthAPI : public NetworkModAPI {
|
||||
ModLoaderTypes loaders,
|
||||
QByteArray* response) -> NetJob::Ptr;
|
||||
|
||||
auto getProjects(QStringList addonIds, QByteArray* response) const -> NetJob::Ptr override;
|
||||
|
||||
public:
|
||||
inline auto getAuthorURL(const QString& name) const -> QString { return "https://modrinth.com/user/" + name; };
|
||||
|
||||
@ -103,6 +104,11 @@ class ModrinthAPI : public NetworkModAPI {
|
||||
return BuildConfig.MODRINTH_PROD_URL + "/project/" + id;
|
||||
};
|
||||
|
||||
inline auto getMultipleModInfoURL(QStringList ids) const -> QString
|
||||
{
|
||||
return BuildConfig.MODRINTH_PROD_URL + QString("/projects?ids=[\"%1\"]").arg(ids.join("\",\""));
|
||||
};
|
||||
|
||||
inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override
|
||||
{
|
||||
return QString(BuildConfig.MODRINTH_PROD_URL +
|
||||
|
Reference in New Issue
Block a user