diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -77,5 +77,6 @@ add_libkgapi2_test(drive filesearchquerytest) add_libkgapi2_test(drive teamdrivecreatejobtest) add_libkgapi2_test(drive teamdrivedeletejobtest) +add_libkgapi2_test(drive teamdrivemodifyjobtest) add_libkgapi2_test(drive teamdrivefetchjobtest) add_libkgapi2_test(drive teamdrivesearchquerytest) diff --git a/autotests/drive/data/teamdrive_modify_request.txt b/autotests/drive/data/teamdrive_modify_request.txt new file mode 100644 --- /dev/null +++ b/autotests/drive/data/teamdrive_modify_request.txt @@ -0,0 +1,7 @@ +POST https://www.googleapis.com/drive/v2/teamdrives/0APqEW6eViiMXUk9PVA + +{ + "kind": "drive#teamDrive", + "id": "0APqEW6eViiMXUk9PVA", + "name": "Renamed Team Drive" +} diff --git a/autotests/drive/data/teamdrive_modify_response.txt b/autotests/drive/data/teamdrive_modify_response.txt new file mode 100644 --- /dev/null +++ b/autotests/drive/data/teamdrive_modify_response.txt @@ -0,0 +1,8 @@ +HTTP/1.1 200 OK +content-type: application/json; charset=UTF-8 + +{ + "kind": "drive#teamDrive", + "id": "0APqEW6eViiMXUk9PVA", + "name": "Renamed Team Drive" +} diff --git a/autotests/drive/teamdrivecreatejobtest.cpp b/autotests/drive/teamdrivecreatejobtest.cpp --- a/autotests/drive/teamdrivecreatejobtest.cpp +++ b/autotests/drive/teamdrivecreatejobtest.cpp @@ -1,5 +1,5 @@ /* - * Createright (C) 2019 David Barchiesi + * Copyright (C) 2019 David Barchiesi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -14,7 +14,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * - * You should have received a create of the GNU Lesser General Public + * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ diff --git a/autotests/drive/teamdrivedeletejobtest.cpp b/autotests/drive/teamdrivedeletejobtest.cpp --- a/autotests/drive/teamdrivedeletejobtest.cpp +++ b/autotests/drive/teamdrivedeletejobtest.cpp @@ -1,5 +1,5 @@ /* - * Deleteright (C) 2019 David Barchiesi + * Copyright (C) 2019 David Barchiesi * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -14,7 +14,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * - * You should have received a delete of the GNU Lesser General Public + * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ diff --git a/autotests/drive/teamdrivemodifyjobtest.cpp b/autotests/drive/teamdrivemodifyjobtest.cpp new file mode 100644 --- /dev/null +++ b/autotests/drive/teamdrivemodifyjobtest.cpp @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2019 David Barchiesi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#include +#include + +#include "fakenetworkaccessmanagerfactory.h" +#include "testutils.h" +#include "drivetestutils.h" + +#include "types.h" +#include "teamdrivemodifyjob.h" +#include "teamdrive.h" +#include "account.h" + +using namespace KGAPI2; + +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(KGAPI2::Drive::TeamdrivePtr) + +class TeamdriveModifyJobTest : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void initTestCase() + { + NetworkAccessManagerFactory::setFactory(new FakeNetworkAccessManagerFactory); + } + + void testModify_data() + { + QTest::addColumn>("scenarios"); + QTest::addColumn("sourceTeamdrive"); + QTest::addColumn("requestId"); + + QTest::newRow("metadata only") + << QList{ + scenarioFromFile(QFINDTESTDATA("data/teamdrive_modify_request.txt"), + QFINDTESTDATA("data/teamdrive_modify_response.txt")) + } + << teamdriveFromFile(QFINDTESTDATA("data/teamdrive.json")) + << QStringLiteral("MockRequestId"); + } + + void testModify() + { + QFETCH(QList, scenarios); + QFETCH(Drive::TeamdrivePtr, sourceTeamdrive); + QFETCH(QString, requestId); + + FakeNetworkAccessManagerFactory::get()->setScenarios(scenarios); + + sourceTeamdrive->setName(QStringLiteral("Renamed Team Drive")); + + auto account = AccountPtr::create(QStringLiteral("MockAccount"), QStringLiteral("MockToken")); + Drive::TeamdriveModifyJob *job = new Drive::TeamdriveModifyJob(sourceTeamdrive, account); + + QVERIFY(execJob(job)); + + const auto items = job->items(); + QCOMPARE(items.count(), 1); + + Drive::TeamdrivePtr firstResult = (*items.cbegin()).dynamicCast(); + QVERIFY(firstResult); + QCOMPARE(*firstResult, *sourceTeamdrive); + } +}; + +QTEST_GUILESS_MAIN(TeamdriveModifyJobTest) + +#include "teamdrivemodifyjobtest.moc" + + + + + diff --git a/examples/teamdrive/mainwindow.h b/examples/teamdrive/mainwindow.h --- a/examples/teamdrive/mainwindow.h +++ b/examples/teamdrive/mainwindow.h @@ -65,6 +65,16 @@ */ void slotTeamdriveCreateJobFinished(KGAPI2::Job *job); + /** + * Rename the selected Team Drive with name in renameTeamdriveEdit + */ + void renameSelectedTeamdrive(); + + /** + * Team Drive was modified. + */ + void slotTeamdriveModifyJobFinished(KGAPI2::Job *job); + /** * All Team Drives were fetched. */ diff --git a/examples/teamdrive/mainwindow.cpp b/examples/teamdrive/mainwindow.cpp --- a/examples/teamdrive/mainwindow.cpp +++ b/examples/teamdrive/mainwindow.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,8 @@ this, &MainWindow::fetchTeamdriveList); connect(m_ui->teamdriveSelectedDeleteButton, &QAbstractButton::clicked, this, &MainWindow::deleteSelectedTeamdrive); + connect(m_ui->renameTeamdriveButton, &QAbstractButton::clicked, + this, &MainWindow::renameSelectedTeamdrive); connect(m_ui->teamdriveList, &QListWidget::itemSelectionChanged, this, &MainWindow::teamdriveSelected); } @@ -92,6 +95,8 @@ m_ui->authStatusLabel->setText(QStringLiteral("Authenticated")); m_ui->teamdriveListButton->setEnabled(true); + m_ui->newTeamdriveEdit->setEnabled(true); + m_ui->newTeamdriveButton->setEnabled(true); m_ui->authButton->setEnabled(false); } @@ -105,6 +110,7 @@ KGAPI2::Drive::TeamdrivePtr teamdrive = KGAPI2::Drive::TeamdrivePtr::create(); teamdrive->setName(teamdriveName); + KGAPI2::Drive::TeamdriveCreateJob *createJob = new KGAPI2::Drive::TeamdriveCreateJob(requestId, teamdrive, m_account, this); connect(createJob, &KGAPI2::Job::finished, this, &MainWindow::slotTeamdriveCreateJobFinished); @@ -127,6 +133,39 @@ fetchTeamdriveList(); } +void MainWindow::renameSelectedTeamdrive() +{ + QString teamdriveName = m_ui->renameTeamdriveEdit->text(); + if (teamdriveName.isEmpty()) { + return; + } + QString teamdriveId = m_ui->teamdriveList->selectedItems().at(0)->data(Qt::UserRole).toString(); + + KGAPI2::Drive::TeamdrivePtr teamdrive = KGAPI2::Drive::TeamdrivePtr::create(); + teamdrive->setId(teamdriveId); + teamdrive->setName(teamdriveName); + + KGAPI2::Drive::TeamdriveModifyJob *modifyJob = new KGAPI2::Drive::TeamdriveModifyJob(teamdrive, m_account, this); + connect(modifyJob, &KGAPI2::Job::finished, + this, &MainWindow::slotTeamdriveModifyJobFinished); +} + +void MainWindow::slotTeamdriveModifyJobFinished(KGAPI2::Job *job) +{ + KGAPI2::Drive::TeamdriveModifyJob *modifyJob = qobject_cast(job); + Q_ASSERT(modifyJob); + modifyJob->deleteLater(); + + if (modifyJob->error() != KGAPI2::NoError) { + m_ui->errorLabel->setText(QStringLiteral("Error: %1").arg(modifyJob->errorString())); + m_ui->errorLabel->setVisible(true); + m_ui->teamdriveListButton->setEnabled(true); + return; + } + + fetchTeamdriveList(); +} + void MainWindow::fetchTeamdriveList() { if (m_account.isNull()) { @@ -202,13 +241,18 @@ bool hasSelection = (m_ui->teamdriveList->selectedItems().count() != 0); m_ui->teamdriveSelectedDeleteButton->setEnabled(hasSelection); + m_ui->renameTeamdriveButton->setEnabled(hasSelection); + m_ui->renameTeamdriveEdit->setEnabled(hasSelection); if (!hasSelection) { m_ui->teamdrivePreview->clear(); + m_ui->renameTeamdriveEdit->clear(); return; } const QString id = m_ui->teamdriveList->selectedItems().at(0)->data(Qt::UserRole).toString(); + const QString name = m_ui->teamdriveList->selectedItems().at(0)->data(Qt::DisplayRole).toString(); + m_ui->renameTeamdriveEdit->setText(name); KGAPI2::Drive::FileSearchQuery query; query.addQuery(KGAPI2::Drive::FileSearchQuery::Trashed, KGAPI2::Drive::FileSearchQuery::Equals, false); diff --git a/examples/teamdrive/ui/main.ui b/examples/teamdrive/ui/main.ui --- a/examples/teamdrive/ui/main.ui +++ b/examples/teamdrive/ui/main.ui @@ -43,10 +43,17 @@ - + + + false + + + + false + Create @@ -54,6 +61,27 @@ + + + + + + false + + + + + + + false + + + Rename + + + + + diff --git a/src/drive/CMakeLists.txt b/src/drive/CMakeLists.txt --- a/src/drive/CMakeLists.txt +++ b/src/drive/CMakeLists.txt @@ -42,6 +42,7 @@ teamdrivecreatejob.cpp teamdrivedeletejob.cpp teamdrivefetchjob.cpp + teamdrivemodifyjob.cpp teamdrivesearchquery.cpp user.cpp @@ -92,6 +93,7 @@ TeamdriveCreateJob TeamdriveDeleteJob TeamdriveFetchJob + TeamdriveModifyJob TeamdriveSearchQuery User PREFIX KGAPI/Drive diff --git a/src/drive/teamdrive.h b/src/drive/teamdrive.h --- a/src/drive/teamdrive.h +++ b/src/drive/teamdrive.h @@ -69,6 +69,14 @@ */ bool adminManagedRestrictions() const; + /** + * @brief Sets whether administrative privileges on this Team Drive + * are required to modify restrictions. + * + * @param adminManagedRestrictions + */ + void setAdminManagedRestrictions(bool adminManagedRestrictions) const; + /** * @brief Returns whether the options to copy, print, or download files * inside this Team Drive, should be disabled for readers and commenters. @@ -77,6 +85,16 @@ */ bool copyRequiresWriterPermission() const; + /** + * @brief Sets whether the options to copy, print, or download files + * inside this Team Drive, should be disabled for readers and commenters. + * When this restriction is set to true, it will override the similarly + * named field to true for any file inside this Team Drive. + * + * @param copyRequiresWriterPermission + */ + void setCopyRequiresWriterPermission(bool copyRequiresWriterPermission) const; + /** * @brief Returns whether access to this Team Drive and items inside this * Team Drive is restricted to users of the domain to which this Team @@ -85,12 +103,30 @@ */ bool domainUsersOnly() const; + /** + * @brief Sets whether access to this Team Drive and items inside this + * Team Drive is restricted to users of the domain to which this Team + * Drive belongs. This restriction may be overridden by other sharing + * policies controlled outside of this Team Drive. + * + * @param domainUsersOnly + */ + void setDomainUsersOnly(bool domainUsersOnly) const; + /** * @brief Returns whether access to items inside this Team Drive is * restricted to members of this Team Drive. */ bool teamMembersOnly() const; + /** + * @brief Sets whether access to items inside this Team Drive is + * restricted to members of this Team Drive. + * + * @param teamMembersOnly + */ + void setTeamMembersOnly(bool teamMembersOnly) const; + private: class Private; QScopedPointer const d; @@ -249,21 +285,49 @@ */ QString id() const; + /** + * @brief Sets the id of the background image file. + * + * @param id + */ + void setId(const QString &id) const; + /** * @brief Returns the x coordinate for this background image file. */ float xCoordinate() const; + /** + * @brief Sets the x coordinate for this background image file. + * + * @param xCoordinate + */ + void setXCoordinate(float xCoordinate) const; + /** * @brief Returns the y coordinate for this background image file. */ float yCoordinate() const; + /** + * @brief Sets the y coordinate for this background image file. + * + * @param yCoordinate + */ + void setYCoordinate(float yCoordinate) const; + /** * @brief Returns the width for this background image file. */ float width() const; + /** + * @brief Sets the width for this background image file. + * + * @param width + */ + void setWidth(float width) const; + private: class Private; QScopedPointer const d; @@ -284,6 +348,13 @@ */ QString id() const; + /** + * @brief Sets the id of the teamdrive. + * + * @param id + */ + void setId(const QString &id) const; + /** * @brief Returns the name of the teamdrive. */ @@ -301,16 +372,37 @@ */ QString themeId() const; + /** + * @brief Sets the themeId of the teamdrive. + * + * @param themeId + */ + void setThemeId(const QString &themeId) const; + /** * @brief Returns the colorRgb of the teamdrive. */ QString colorRgb() const; + /** + * @brief Sets the colorRgb of the teamdrive. + * + * @param colorRgb + */ + void setColorRgb(const QString &colorRgb) const; + /** * @brief Returns the image file and cropping parameters from which a background image for this Team Drive is set. */ BackgroundImageFilePtr backgroundImageFile() const; + /** + * @brief Sets the backgroundImageFile of the teamdrive. + * + * @param backgroundImageFile + */ + void setBackgroundImageFile(const BackgroundImageFilePtr &backgroundImageFile) const; + /** * @brief Returns the backgroundImageLink of the teamdrive. */ @@ -332,6 +424,13 @@ */ RestrictionsPtr restrictions() const; + /** + * @brief Sets the restrictions of the teamdrive. + * + * @param restrictions + */ + void setRestrictions(const RestrictionsPtr &restrictions) const; + static TeamdrivePtr fromJSON(const QByteArray &jsonData); static TeamdrivesList fromJSONFeed(const QByteArray &jsonData, FeedData &feedData); static QByteArray toJSON(const TeamdrivePtr &teamdrive); diff --git a/src/drive/teamdrive.cpp b/src/drive/teamdrive.cpp --- a/src/drive/teamdrive.cpp +++ b/src/drive/teamdrive.cpp @@ -113,21 +113,41 @@ return d->adminManagedRestrictions; } +void Teamdrive::Restrictions::setAdminManagedRestrictions(bool adminManagedRestrictions) const +{ + d->adminManagedRestrictions = adminManagedRestrictions; +} + bool Teamdrive::Restrictions::copyRequiresWriterPermission() const { return d->copyRequiresWriterPermission; } +void Teamdrive::Restrictions::setCopyRequiresWriterPermission(bool copyRequiresWriterPermission) const +{ + d->copyRequiresWriterPermission = copyRequiresWriterPermission; +} + bool Teamdrive::Restrictions::domainUsersOnly() const { return d->domainUsersOnly; } +void Teamdrive::Restrictions::setDomainUsersOnly(bool domainUsersOnly) const +{ + d->domainUsersOnly = domainUsersOnly; +} + bool Teamdrive::Restrictions::teamMembersOnly() const { return d->teamMembersOnly; } +void Teamdrive::Restrictions::setTeamMembersOnly(bool teamMembersOnly) const +{ + d->teamMembersOnly = teamMembersOnly; +} + ///// DriveTeamdrive::Capabilities class Q_DECL_HIDDEN Teamdrive::Capabilities::Private @@ -321,21 +341,41 @@ return d->id; } +void Teamdrive::BackgroundImageFile::setId(const QString &id) const +{ + d->id = id; +} + float Teamdrive::BackgroundImageFile::xCoordinate() const { return d->xCoordinate; } +void Teamdrive::BackgroundImageFile::setXCoordinate(const float xCoordinate) const +{ + d->xCoordinate = xCoordinate; +} + float Teamdrive::BackgroundImageFile::yCoordinate() const { return d->yCoordinate; } +void Teamdrive::BackgroundImageFile::setYCoordinate(const float yCoordinate) const +{ + d->yCoordinate = yCoordinate; +} + float Teamdrive::BackgroundImageFile::width() const { return d->width; } +void Teamdrive::BackgroundImageFile::setWidth(const float width) const +{ + d->width = width; +} + ///// DriveTeamdrive class Q_DECL_HIDDEN Teamdrive::Private @@ -468,6 +508,11 @@ return d->id; } +void Teamdrive::setId(const QString &id) const +{ + d->id = id; +} + QString Teamdrive::name() const { return d->name; @@ -483,16 +528,31 @@ return d->themeId; } +void Teamdrive::setThemeId(const QString &themeId) const +{ + d->themeId = themeId; +} + QString Teamdrive::colorRgb() const { return d->colorRgb; } +void Teamdrive::setColorRgb(const QString &colorRgb) const +{ + d->colorRgb = colorRgb; +} + Teamdrive::BackgroundImageFilePtr Teamdrive::backgroundImageFile() const { return d->backgroundImageFile; } +void Teamdrive::setBackgroundImageFile(const Teamdrive::BackgroundImageFilePtr &backgroundImageFile) const +{ + d->backgroundImageFile = backgroundImageFile; +} + QString Teamdrive::backgroundImageLink() const { return d->backgroundImageLink; @@ -508,6 +568,11 @@ return d->createdDate; } +void Teamdrive::setRestrictions(const Teamdrive::RestrictionsPtr &restrictions) const +{ + d->restrictions = restrictions; +} + Teamdrive::RestrictionsPtr Teamdrive::restrictions() const { return d->restrictions; diff --git a/src/drive/teamdrivecreatejob.h b/src/drive/teamdrivecreatejob.h --- a/src/drive/teamdrivecreatejob.h +++ b/src/drive/teamdrivecreatejob.h @@ -53,7 +53,7 @@ protected: void start() override; KGAPI2::ObjectsList handleReplyWithItems(const QNetworkReply *reply, - const QByteArray &rawData) override; + const QByteArray &rawData) override; private: class Private; diff --git a/src/drive/teamdrivemodifyjob.h b/src/drive/teamdrivemodifyjob.h new file mode 100644 --- /dev/null +++ b/src/drive/teamdrivemodifyjob.h @@ -0,0 +1,62 @@ +/* + * This file is part of LibKGAPI library + * + * Copyright (C) 2019 David Barchiesi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + + +#ifndef KGAPI2_DRIVETEAMDRIVEMODIFYJOB_H +#define KGAPI2_DRIVETEAMDRIVEMODIFYJOB_H + +#include "modifyjob.h" +#include "kgapidrive_export.h" + +namespace KGAPI2 +{ + +namespace Drive +{ + +class KGAPIDRIVE_EXPORT TeamdriveModifyJob : public KGAPI2::ModifyJob +{ + Q_OBJECT + + public: + explicit TeamdriveModifyJob(const TeamdrivePtr &teamdrive, + const AccountPtr &account, QObject *parent = nullptr); + explicit TeamdriveModifyJob(const TeamdrivesList &teamdrives, + const AccountPtr &account, QObject *parent = nullptr); + ~TeamdriveModifyJob() override; + + protected: + void start() override; + KGAPI2::ObjectsList handleReplyWithItems(const QNetworkReply *reply, + const QByteArray &rawData) override; + + private: + class Private; + QScopedPointer d; + friend class Private; +}; + +} // namespace Drive + +} // namespace KGAPI2 + +#endif // KGAPI2_DRIVETEAMDRIVEMODIFYJOB_H diff --git a/src/drive/teamdrivemodifyjob.cpp b/src/drive/teamdrivemodifyjob.cpp new file mode 100644 --- /dev/null +++ b/src/drive/teamdrivemodifyjob.cpp @@ -0,0 +1,116 @@ +/* + * This file is part of LibKGAPI library + * + * Copyright (C) 2019 David Barchiesi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + + +#include "teamdrivemodifyjob.h" +#include "account.h" +#include "driveservice.h" +#include "teamdrive.h" +#include "utils.h" + +#include +#include + + +using namespace KGAPI2; +using namespace KGAPI2::Drive; + +class Q_DECL_HIDDEN TeamdriveModifyJob::Private +{ + public: + Private(TeamdriveModifyJob *parent); + void processNext(); + + TeamdrivesList teamdrives; + + private: + TeamdriveModifyJob *const q; +}; + +TeamdriveModifyJob::Private::Private(TeamdriveModifyJob *parent): + q(parent) +{ +} + +void TeamdriveModifyJob::Private::processNext() +{ + if (teamdrives.isEmpty()) { + q->emitFinished(); + return; + } + + const TeamdrivePtr teamdrive = teamdrives.takeFirst(); + const QUrl url = DriveService::fetchTeamdriveUrl(teamdrive->id()); + + QNetworkRequest request(url); + request.setRawHeader("Authorization", "Bearer " + q->account()->accessToken().toLatin1()); + + const QByteArray rawData = Teamdrive::toJSON(teamdrive); + q->enqueueRequest(request, rawData, QStringLiteral("application/json")); +} + +TeamdriveModifyJob::TeamdriveModifyJob(const TeamdrivePtr &teamdrive, + const AccountPtr &account, + QObject *parent): + ModifyJob(account, parent), + d(new Private(this)) +{ + d->teamdrives << teamdrive; +} + +TeamdriveModifyJob::TeamdriveModifyJob(const TeamdrivesList &teamdrives, + const AccountPtr &account, + QObject *parent): + ModifyJob(account, parent), + d(new Private(this)) +{ + d->teamdrives << teamdrives; +} + +TeamdriveModifyJob::~TeamdriveModifyJob() = default; + +void TeamdriveModifyJob::start() +{ + d->processNext(); +} + +ObjectsList TeamdriveModifyJob::handleReplyWithItems(const QNetworkReply *reply, + const QByteArray &rawData) +{ + const QString contentType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); + ContentType ct = Utils::stringToContentType(contentType); + ObjectsList items; + if (ct == KGAPI2::JSON) { + items << Teamdrive::fromJSON(rawData); + } else { + setError(KGAPI2::InvalidResponse); + setErrorString(tr("Invalid response content type")); + emitFinished(); + } + + // Enqueue next item or finish + d->processNext(); + + return items; +} + +