File indexing completed on 2024-05-12 16:59:02
0001 /* 0002 SPDX-FileCopyrightText: 2019 Harald Sitter <sitter@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #include "attachmentclient.h" 0008 0009 #include <QVariant> 0010 0011 namespace Bugzilla 0012 { 0013 QList<int> AttachmentClient::createAttachment(KJob *kjob) 0014 { 0015 auto *job = qobject_cast<APIJob *>(kjob); 0016 0017 auto ary = job->object().value(QStringLiteral("ids")).toArray(); 0018 // It's unclear if this can happen. When the ids would be empty there was 0019 // an error, and when there was an error the API should have sent an error. 0020 Q_ASSERT(ary.size() > 0); 0021 0022 QList<int> list; 0023 for (auto ids : ary) { 0024 bool ok = false; 0025 list.append(ids.toVariant().toInt(&ok)); 0026 Q_ASSERT(ok); 0027 } 0028 0029 return list; 0030 } 0031 0032 KJob *AttachmentClient::createAttachment(int bugId, const NewAttachment &attachment) 0033 { 0034 return m_connection.post(QStringLiteral("/bug/%1/attachment").arg(bugId), attachment.toJson()); 0035 } 0036 0037 } // namespace Bugzilla