diff --git a/src/rocketchatrestapi-qt5/autotests/restapimethodtest.cpp b/src/rocketchatrestapi-qt5/autotests/restapimethodtest.cpp index 205bec6e..f5ebb053 100644 --- a/src/rocketchatrestapi-qt5/autotests/restapimethodtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/restapimethodtest.cpp @@ -1,167 +1,169 @@ /* Copyright (c) 2018 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "restapimethodtest.h" #include "restapimethod.h" #include QTEST_GUILESS_MAIN(RestApiMethodTest) using namespace RocketChatRestApi; RestApiMethodTest::RestApiMethodTest(QObject *parent) : QObject(parent) { } void RestApiMethodTest::shouldHaveDefaultValue() { RestApiMethod rest; QVERIFY(rest.serverUrl().isEmpty()); } void RestApiMethodTest::shouldAssignDefaultValue() { RestApiMethod rest; QString newUrl = QStringLiteral("http://www.kde.org"); rest.setServerUrl(newUrl); QCOMPARE(rest.serverUrl(), newUrl); } void RestApiMethodTest::shouldGenerateUrl() { RestApiMethod rest; //If server url is empty return null url QVERIFY(!rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsList).isValid()); rest.setServerUrl(QStringLiteral("http://www.kde.org")); QVERIFY(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsList).isValid()); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::Login), QUrl(QStringLiteral("http://www.kde.org/api/v1/login"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::Logout), QUrl(QStringLiteral("http://www.kde.org/api/v1/logout"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::Me), QUrl(QStringLiteral("http://www.kde.org/api/v1/me"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersCreate), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.create"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersCreateToken), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.createToken"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersGetPresence), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.getPresence"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersInfo), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.info"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersList), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.list"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersDelete), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.delete"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersRegister), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.register"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersGetAvatar), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.getAvatar"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersResetAvatar), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.resetAvatar"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersSetAvatar), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.setAvatar"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersUpdate), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.update"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersGetUsernameSuggestion), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.getUsernameSuggestion"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatDelete), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.delete"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatGetMessage), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.getMessage"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatPinMessage), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.pinMessage"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatPostMessage), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.postMessage"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatReact), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.react"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatIgnoreUser), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.ignoreUser"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatStarMessage), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.starMessage"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatUnPinMessage), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.unPinMessage"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatUnStarMessage), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.unStarMessage"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatUpdate), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.update"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatSearch), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.search"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatReportMessage), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.reportMessage"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsAddAll), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.addAll"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsAddModerator), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.addModerator"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsAddOwner), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.addOwner"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsArchive), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.archive"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsCleanHistory), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.cleanHistory"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsClose), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.close"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsCreate), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.create"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsGetIntegrations), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.getIntegrations"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsHistory), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.history"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsInfo), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.info"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsInvite), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.invite"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsKick), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.kick"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsLeave), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.leave"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsList), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.list"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsListJoined), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.list.joined"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsOpen), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.open"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsJoin), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.join"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsRemoveModerator), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.removeModerator"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsRemoveOwner), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.removeOwner"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsRename), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.rename"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsSetDescription), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.setDescription"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsSetJoinCode), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.setJoinCode"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsRoles), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.roles"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsSetPurpose), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.setPurpose"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsSetReadOnly), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.setReadOnly"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsSetTopic), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.setTopic"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsSetType), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.setType"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsUnarchive), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.unarchive"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsSetAnnouncement), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.setAnnouncement"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsFiles), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.files"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsMembers), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.members"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsCounters), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.counters"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsAddAll), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.addAll"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsAddModerator), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.addModerator"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsAddOwner), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.addOwner"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsArchive), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.archive"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsClose), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.close"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsCreate), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.create"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsGetIntegrations), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.getIntegrations"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsHistory), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.history"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsInfo), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.info"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsInvite), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.invite"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsKick), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.kick"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsLeave), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.leave"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsList), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.list"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsOpen), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.open"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsRemoveModerator), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.removeModerator"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupRemoveOwner), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.removeOwner"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsRename), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.rename"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsSetDescription), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.setDescription"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsSetPurpose), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.setPurpose"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsSetReadOnly), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.setReadOnly"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsSetTopic), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.setTopic"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsSetType), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.setType"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsUnarchive), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.unarchive"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsSetAnnouncement), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.setAnnouncement"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsRoles), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.roles"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsCounters), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.counters"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ServerInfo), QUrl(QStringLiteral("http://www.kde.org/api/v1/info"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::Settings), QUrl(QStringLiteral("http://www.kde.org/api/v1/settings"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::SettingsPublic), QUrl(QStringLiteral("http://www.kde.org/api/v1/settings.public"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::RoomsUpload), QUrl(QStringLiteral("http://www.kde.org/api/v1/rooms.upload"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::Spotlight), QUrl(QStringLiteral("http://www.kde.org/api/v1/spotlight"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ImClose), QUrl(QStringLiteral("http://www.kde.org/api/v1/im.close"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ImCreate), QUrl(QStringLiteral("http://www.kde.org/api/v1/im.create"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ImHistory), QUrl(QStringLiteral("http://www.kde.org/api/v1/im.history"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::LoadEmojiCustom), QUrl(QStringLiteral("http://www.kde.org/api/v1/emoji-custom"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::RoomsSaveNotification), QUrl(QStringLiteral("http://www.kde.org/api/v1/rooms.saveNotification"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::SubscriptionsRead), QUrl(QStringLiteral("http://www.kde.org/api/v1/subscriptions.read"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::SubscriptionsUnRead), QUrl(QStringLiteral("http://www.kde.org/api/v1/subscriptions.unread"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::SettingsOauth), QUrl(QStringLiteral("http://www.kde.org/api/v1/settings.oauth"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::RoomsGet), QUrl(QStringLiteral("http://www.kde.org/api/v1/rooms.get"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::RoomsFavorite), QUrl(QStringLiteral("http://www.kde.org/api/v1/rooms.favorite"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::RoomscleanHistory), QUrl(QStringLiteral("http://www.kde.org/api/v1/rooms.cleanHistory"))); + QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::RoomsInfo), QUrl(QStringLiteral("http://www.kde.org/api/v1/rooms.info"))); + QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::RoomsLeave), QUrl(QStringLiteral("http://www.kde.org/api/v1/rooms.leave"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ForgotPassword), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.forgotPassword"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::PermissionsList), QUrl(QStringLiteral("http://www.kde.org/api/v1/permissions.list"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::CommandsList), QUrl(QStringLiteral("http://www.kde.org/api/v1/commands.list"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::E2EfetchMyKeys), QUrl(QStringLiteral("http://www.kde.org/api/v1/e2e.fetchMyKeys"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::E2EupdateGroupKey), QUrl(QStringLiteral("http://www.kde.org/api/v1/e2e.updateGroupE2EKey"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::E2ESetRoomKeyID), QUrl(QStringLiteral("http://www.kde.org/api/v1/e2e.setRoomKeyID"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::E2ESetUserPublicAndPrivateKeys), QUrl(QStringLiteral("http://www.kde.org/api/v1/e2e.setUserPublicAndPivateKeys"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::RolesList), QUrl(QStringLiteral("http://www.kde.org/api/v1/roles.list"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::RolesCreate), QUrl(QStringLiteral("http://www.kde.org/api/v1/roles.create"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::RolesAddUserToRole), QUrl(QStringLiteral("http://www.kde.org/api/v1/roles.addUserToRole"))); } diff --git a/src/rocketchatrestapi-qt5/restapiutil.cpp b/src/rocketchatrestapi-qt5/restapiutil.cpp index 0bd8f64e..8a82b69e 100644 --- a/src/rocketchatrestapi-qt5/restapiutil.cpp +++ b/src/rocketchatrestapi-qt5/restapiutil.cpp @@ -1,279 +1,285 @@ /* Copyright (c) 2017-2018 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "restapiutil.h" #include "rocketchatqtrestapi_debug.h" QString RestApiUtil::adaptUrl(const QString &url) { if (url.isEmpty()) { return url; } //Avoid to add more https:// :) if (url.startsWith(QLatin1String("https://")) || url.startsWith(QLatin1String("http://"))) { return url; } else { //Default to https return QStringLiteral("https://") + url; } } QString RestApiUtil::apiUri() { return QStringLiteral("/api/v1/"); } QString RestApiUtil::restUrl(RestApiUtil::RestApiUrlType type) { switch (type) { case RestApiUtil::RestApiUrlType::Login: return QStringLiteral("login"); case RestApiUtil::RestApiUrlType::Logout: return QStringLiteral("logout"); case RestApiUtil::RestApiUrlType::Me: return QStringLiteral("me"); case RestApiUtil::RestApiUrlType::UsersGetAvatar: return QStringLiteral("users.getAvatar"); case RestApiUtil::RestApiUrlType::UsersDelete: return QStringLiteral("users.delete"); case RestApiUtil::RestApiUrlType::UsersCreate: return QStringLiteral("users.create"); case RestApiUtil::RestApiUrlType::UsersCreateToken: return QStringLiteral("users.createToken"); case RestApiUtil::RestApiUrlType::UsersGetPresence: return QStringLiteral("users.getPresence"); case RestApiUtil::RestApiUrlType::UsersInfo: return QStringLiteral("users.info"); case RestApiUtil::RestApiUrlType::UsersList: return QStringLiteral("users.list"); case RestApiUtil::RestApiUrlType::UsersRegister: return QStringLiteral("users.register"); case RestApiUtil::RestApiUrlType::UsersResetAvatar: return QStringLiteral("users.resetAvatar"); case RestApiUtil::RestApiUrlType::UsersSetAvatar: return QStringLiteral("users.setAvatar"); case RestApiUtil::RestApiUrlType::UsersUpdate: return QStringLiteral("users.update"); case RestApiUtil::RestApiUrlType::UsersGetUsernameSuggestion: return QStringLiteral("users.getUsernameSuggestion"); case RestApiUtil::RestApiUrlType::ChatDelete: return QStringLiteral("chat.delete"); case RestApiUtil::RestApiUrlType::ChatGetMessage: return QStringLiteral("chat.getMessage"); case RestApiUtil::RestApiUrlType::ChatPinMessage: return QStringLiteral("chat.pinMessage"); case RestApiUtil::RestApiUrlType::ChatPostMessage: return QStringLiteral("chat.postMessage"); case RestApiUtil::RestApiUrlType::ChatReact: return QStringLiteral("chat.react"); case RestApiUtil::RestApiUrlType::ChatStarMessage: return QStringLiteral("chat.starMessage"); case RestApiUtil::RestApiUrlType::ChatUnPinMessage: return QStringLiteral("chat.unPinMessage"); case RestApiUtil::RestApiUrlType::ChatUnStarMessage: return QStringLiteral("chat.unStarMessage"); case RestApiUtil::RestApiUrlType::ChatUpdate: return QStringLiteral("chat.update"); case RestApiUtil::RestApiUrlType::ChatSearch: return QStringLiteral("chat.search"); case RestApiUtil::RestApiUrlType::ChatIgnoreUser: return QStringLiteral("chat.ignoreUser"); case RestApiUtil::RestApiUrlType::ChatReportMessage: return QStringLiteral("chat.reportMessage"); case RestApiUtil::RestApiUrlType::ChannelsAddAll: return QStringLiteral("channels.addAll"); case RestApiUtil::RestApiUrlType::ChannelsAddModerator: return QStringLiteral("channels.addModerator"); case RestApiUtil::RestApiUrlType::ChannelsAddOwner: return QStringLiteral("channels.addOwner"); case RestApiUtil::RestApiUrlType::ChannelsArchive: return QStringLiteral("channels.archive"); case RestApiUtil::RestApiUrlType::ChannelsCleanHistory: return QStringLiteral("channels.cleanHistory"); case RestApiUtil::RestApiUrlType::ChannelsClose: return QStringLiteral("channels.close"); case RestApiUtil::RestApiUrlType::ChannelsCreate: return QStringLiteral("channels.create"); case RestApiUtil::RestApiUrlType::ChannelsGetIntegrations: return QStringLiteral("channels.getIntegrations"); case RestApiUtil::RestApiUrlType::ChannelsHistory: return QStringLiteral("channels.history"); case RestApiUtil::RestApiUrlType::ChannelsInfo: return QStringLiteral("channels.info"); case RestApiUtil::RestApiUrlType::ChannelsInvite: return QStringLiteral("channels.invite"); case RestApiUtil::RestApiUrlType::ChannelsKick: return QStringLiteral("channels.kick"); case RestApiUtil::RestApiUrlType::ChannelsLeave: return QStringLiteral("channels.leave"); case RestApiUtil::RestApiUrlType::ChannelsList: return QStringLiteral("channels.list"); case RestApiUtil::RestApiUrlType::ChannelsListJoined: return QStringLiteral("channels.list.joined"); case RestApiUtil::RestApiUrlType::ChannelsOpen: return QStringLiteral("channels.open"); case RestApiUtil::RestApiUrlType::ChannelsRemoveModerator: return QStringLiteral("channels.removeModerator"); case RestApiUtil::RestApiUrlType::ChannelsRemoveOwner: return QStringLiteral("channels.removeOwner"); case RestApiUtil::RestApiUrlType::ChannelsRename: return QStringLiteral("channels.rename"); case RestApiUtil::RestApiUrlType::ChannelsSetDescription: return QStringLiteral("channels.setDescription"); case RestApiUtil::RestApiUrlType::ChannelsSetJoinCode: return QStringLiteral("channels.setJoinCode"); case RestApiUtil::RestApiUrlType::ChannelsSetPurpose: return QStringLiteral("channels.setPurpose"); case RestApiUtil::RestApiUrlType::ChannelsSetReadOnly: return QStringLiteral("channels.setReadOnly"); case RestApiUtil::RestApiUrlType::ChannelsSetTopic: return QStringLiteral("channels.setTopic"); case RestApiUtil::RestApiUrlType::ChannelsSetAnnouncement: return QStringLiteral("channels.setAnnouncement"); case RestApiUtil::RestApiUrlType::ChannelsFiles: return QStringLiteral("channels.files"); case RestApiUtil::RestApiUrlType::ChannelsSetType: return QStringLiteral("channels.setType"); case RestApiUtil::RestApiUrlType::ChannelsUnarchive: return QStringLiteral("channels.unarchive"); case RestApiUtil::RestApiUrlType::ChannelsRoles: return QStringLiteral("channels.roles"); case RestApiUtil::RestApiUrlType::ChannelsCounters: return QStringLiteral("channels.counters"); case RestApiUtil::RestApiUrlType::ChannelsJoin: return QStringLiteral("channels.join"); case RestApiUtil::RestApiUrlType::ChannelsMembers: return QStringLiteral("channels.members"); case RestApiUtil::RestApiUrlType::GroupsAddAll: return QStringLiteral("groups.addAll"); case RestApiUtil::RestApiUrlType::GroupsAddModerator: return QStringLiteral("groups.addModerator"); case RestApiUtil::RestApiUrlType::GroupsAddOwner: return QStringLiteral("groups.addOwner"); case RestApiUtil::RestApiUrlType::GroupsArchive: return QStringLiteral("groups.archive"); case RestApiUtil::RestApiUrlType::GroupsClose: return QStringLiteral("groups.close"); case RestApiUtil::RestApiUrlType::GroupsCreate: return QStringLiteral("groups.create"); case RestApiUtil::RestApiUrlType::GroupsGetIntegrations: return QStringLiteral("groups.getIntegrations"); case RestApiUtil::RestApiUrlType::GroupsHistory: return QStringLiteral("groups.history"); case RestApiUtil::RestApiUrlType::GroupsInfo: return QStringLiteral("groups.info"); case RestApiUtil::RestApiUrlType::GroupsInvite: return QStringLiteral("groups.invite"); case RestApiUtil::RestApiUrlType::GroupsKick: return QStringLiteral("groups.kick"); case RestApiUtil::RestApiUrlType::GroupsLeave: return QStringLiteral("groups.leave"); case RestApiUtil::RestApiUrlType::GroupsList: return QStringLiteral("groups.list"); case RestApiUtil::RestApiUrlType::GroupsOpen: return QStringLiteral("groups.open"); case RestApiUtil::RestApiUrlType::GroupsRemoveModerator: return QStringLiteral("groups.removeModerator"); case RestApiUtil::RestApiUrlType::GroupRemoveOwner: return QStringLiteral("groups.removeOwner"); case RestApiUtil::RestApiUrlType::GroupsRename: return QStringLiteral("groups.rename"); case RestApiUtil::RestApiUrlType::GroupsSetDescription: return QStringLiteral("groups.setDescription"); case RestApiUtil::RestApiUrlType::GroupsSetPurpose: return QStringLiteral("groups.setPurpose"); case RestApiUtil::RestApiUrlType::GroupsSetReadOnly: return QStringLiteral("groups.setReadOnly"); case RestApiUtil::RestApiUrlType::GroupsSetTopic: return QStringLiteral("groups.setTopic"); case RestApiUtil::RestApiUrlType::GroupsSetType: return QStringLiteral("groups.setType"); case RestApiUtil::RestApiUrlType::GroupsUnarchive: return QStringLiteral("groups.unarchive"); case RestApiUtil::RestApiUrlType::GroupsSetAnnouncement: return QStringLiteral("groups.setAnnouncement"); case RestApiUtil::RestApiUrlType::GroupsFiles: return QStringLiteral("groups.files"); case RestApiUtil::RestApiUrlType::GroupsRoles: return QStringLiteral("groups.roles"); case RestApiUtil::RestApiUrlType::GroupsCounters: return QStringLiteral("groups.counters"); case RestApiUtil::RestApiUrlType::ServerInfo: return QStringLiteral("info"); case RestApiUtil::RestApiUrlType::Settings: return QStringLiteral("settings"); case RestApiUtil::RestApiUrlType::SettingsPublic: return QStringLiteral("settings.public"); case RestApiUtil::RestApiUrlType::RoomsUpload: return QStringLiteral("rooms.upload"); case RestApiUtil::RestApiUrlType::RoomsSaveNotification: return QStringLiteral("rooms.saveNotification"); case RestApiUtil::RestApiUrlType::Spotlight: return QStringLiteral("spotlight"); case RestApiUtil::RestApiUrlType::ImClose: return QStringLiteral("im.close"); case RestApiUtil::RestApiUrlType::ImCreate: return QStringLiteral("im.create"); case RestApiUtil::RestApiUrlType::ImHistory: return QStringLiteral("im.history"); case RestApiUtil::RestApiUrlType::ImFiles: return QStringLiteral("im.files"); case RestApiUtil::RestApiUrlType::LoadEmojiCustom: return QStringLiteral("emoji-custom"); case RestApiUtil::RestApiUrlType::SubscriptionsRead: return QStringLiteral("subscriptions.read"); case RestApiUtil::RestApiUrlType::SubscriptionsUnRead: return QStringLiteral("subscriptions.unread"); case RestApiUtil::RestApiUrlType::SettingsOauth: return QStringLiteral("settings.oauth"); case RestApiUtil::RestApiUrlType::RoomsGet: return QStringLiteral("rooms.get"); case RestApiUtil::RestApiUrlType::RoomsFavorite: return QStringLiteral("rooms.favorite"); case RestApiUtil::RestApiUrlType::RoomscleanHistory: return QStringLiteral("rooms.cleanHistory"); + //since 0.72 ? Need to implement it + case RestApiUtil::RestApiUrlType::RoomsInfo: + return QStringLiteral("rooms.info"); + case RestApiUtil::RestApiUrlType::RoomsLeave: + return QStringLiteral("rooms.leave"); + // case RestApiUtil::RestApiUrlType::ForgotPassword: return QStringLiteral("users.forgotPassword"); case RestApiUtil::RestApiUrlType::PermissionsList: return QStringLiteral("permissions.list"); case RestApiUtil::RestApiUrlType::CommandsList: return QStringLiteral("commands.list"); case RestApiUtil::RestApiUrlType::E2EfetchMyKeys: return QStringLiteral("e2e.fetchMyKeys"); case RestApiUtil::RestApiUrlType::E2EupdateGroupKey: return QStringLiteral("e2e.updateGroupE2EKey"); case RestApiUtil::RestApiUrlType::E2ESetRoomKeyID: return QStringLiteral("e2e.setRoomKeyID"); case RestApiUtil::RestApiUrlType::E2ESetUserPublicAndPrivateKeys: return QStringLiteral("e2e.setUserPublicAndPivateKeys"); case RestApiUtil::RestApiUrlType::E2EGetUsersOfRoomWithoutKey: return QStringLiteral("e2e.getUsersOfRoomWithoutKey"); case RestApiUtil::RestApiUrlType::RolesList: return QStringLiteral("roles.list"); case RestApiUtil::RestApiUrlType::RolesCreate: return QStringLiteral("roles.create"); case RestApiUtil::RestApiUrlType::RolesAddUserToRole: return QStringLiteral("roles.addUserToRole"); } qCWarning(ROCKETCHATQTRESTAPI_LOG) << "Unknown RestApiUtil::RestApiUrlType " << static_cast(type); return {}; } diff --git a/src/rocketchatrestapi-qt5/restapiutil.h b/src/rocketchatrestapi-qt5/restapiutil.h index 673e08f8..a76f0f63 100644 --- a/src/rocketchatrestapi-qt5/restapiutil.h +++ b/src/rocketchatrestapi-qt5/restapiutil.h @@ -1,152 +1,154 @@ /* Copyright (c) 2017-2018 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef RESTAPIUTIL_H #define RESTAPIUTIL_H #include #include "librestapi_private_export.h" namespace RestApiUtil { enum class RestApiUrlType { Login, Logout, Me, UsersCreate, UsersDelete, UsersCreateToken, UsersGetPresence, UsersInfo, UsersList, UsersRegister, UsersGetAvatar, UsersResetAvatar, UsersSetAvatar, UsersUpdate, UsersGetUsernameSuggestion, ChatDelete, ChatGetMessage, ChatPinMessage, ChatPostMessage, ChatReact, ChatSearch, ChatStarMessage, ChatUnPinMessage, ChatUnStarMessage, ChatUpdate, ChatIgnoreUser, ChatReportMessage, ChannelsAddAll, ChannelsAddModerator, ChannelsAddOwner, ChannelsArchive, ChannelsCleanHistory, ChannelsClose, ChannelsCreate, ChannelsGetIntegrations, ChannelsHistory, ChannelsInfo, ChannelsInvite, ChannelsKick, ChannelsLeave, ChannelsList, ChannelsListJoined, ChannelsOpen, ChannelsRemoveModerator, ChannelsRemoveOwner, ChannelsRename, ChannelsSetDescription, ChannelsSetJoinCode, ChannelsSetPurpose, ChannelsSetReadOnly, ChannelsSetTopic, ChannelsSetType, ChannelsSetAnnouncement, ChannelsFiles, ChannelsUnarchive, ChannelsCounters, ChannelsMembers, ChannelsJoin, //since 0.65 ChannelsRoles, GroupsAddAll, GroupsAddModerator, GroupsAddOwner, GroupsArchive, GroupsClose, GroupsCreate, GroupsGetIntegrations, GroupsHistory, GroupsInfo, GroupsInvite, GroupsKick, GroupsLeave, GroupsList, GroupsOpen, GroupsRemoveModerator, GroupRemoveOwner, GroupsRename, GroupsSetDescription, GroupsSetPurpose, GroupsSetReadOnly, GroupsSetTopic, GroupsSetType, GroupsUnarchive, GroupsSetAnnouncement, GroupsFiles, //Since 0.65 GroupsRoles, GroupsCounters, ServerInfo, Settings, SettingsPublic, Spotlight, LoadEmojiCustom, RoomsUpload, RoomsSaveNotification, ImClose, ImCreate, ImHistory, ImFiles, SubscriptionsRead, SubscriptionsUnRead, SettingsOauth, RoomsGet, RoomsFavorite, RoomscleanHistory, + RoomsInfo, + RoomsLeave, ForgotPassword, PermissionsList, CommandsList, //since 0.70 E2ESetRoomKeyID, E2EfetchMyKeys, E2EupdateGroupKey, E2ESetUserPublicAndPrivateKeys, E2EGetUsersOfRoomWithoutKey, RolesList, RolesCreate, RolesAddUserToRole, }; LIBROCKETCHATRESTAPI_QT5_TESTS_EXPORT QString adaptUrl(const QString &url); LIBROCKETCHATRESTAPI_QT5_TESTS_EXPORT QString restUrl(RestApiUtil::RestApiUrlType type); LIBROCKETCHATRESTAPI_QT5_TESTS_EXPORT QString apiUri(); } #endif // RESTAPIUTIL_H