feat: add 'getFiles' by fileIds route in Flame API

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-07-21 16:40:28 -03:00
parent 208ed73e59
commit 242fb156a2
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
2 changed files with 24 additions and 0 deletions

View File

@ -183,3 +183,26 @@ auto FlameAPI::getProjects(QStringList addonIds, QByteArray* response) const ->
return netJob;
}
auto FlameAPI::getFiles(QStringList fileIds, QByteArray* response) const -> NetJob*
{
auto* netJob = new NetJob(QString("Flame::GetFiles"), APPLICATION->network());
QJsonObject body_obj;
QJsonArray files_arr;
for (auto& fileId : fileIds) {
files_arr.append(fileId);
}
body_obj["fileIds"] = files_arr;
QJsonDocument body(body_obj);
auto body_raw = body.toJson();
netJob->addNetAction(Net::Upload::makeByteArray(QString("https://api.curseforge.com/v1/mods/files"), response, body_raw));
QObject::connect(netJob, &NetJob::finished, [response, netJob] { delete response; netJob->deleteLater(); });
QObject::connect(netJob, &NetJob::failed, [body_raw] { qDebug() << body_raw; });
return netJob;
}

View File

@ -12,6 +12,7 @@ class FlameAPI : public NetworkModAPI {
auto getLatestVersion(VersionSearchArgs&& args) -> ModPlatform::IndexedVersion;
auto getProjects(QStringList addonIds, QByteArray* response) const -> NetJob* override;
auto getFiles(QStringList fileIds, QByteArray* response) const -> NetJob*;
private:
inline auto getSortFieldInt(QString sortString) const -> int