diff --git a/src/rocketchatrestapi-qt5/autotests/restapimethodtest.cpp b/src/rocketchatrestapi-qt5/autotests/restapimethodtest.cpp index 7b47f3f2..908f5000 100644 --- a/src/rocketchatrestapi-qt5/autotests/restapimethodtest.cpp +++ b/src/rocketchatrestapi-qt5/autotests/restapimethodtest.cpp @@ -1,211 +1,215 @@ /* Copyright (c) 2018-2019 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::UsersRemovePersonalAccessToken), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.removePersonalAccessToken"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersGeneratePersonalAccessToken), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.generatePersonalAccessToken"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersUpdateOwnBasicInfo), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.updateOwnBasicInfo"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersRegeneratePersonalAccessToken), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.regeneratePersonalAccessToken"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UsersPresence), QUrl(QStringLiteral("http://www.kde.org/api/v1/users.presence"))); 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::ChatFollowMessage), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.followMessage"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatUnFollowMessage), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.unfollowMessage"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatGetThreadsList), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.getThreadsList"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatSyncThreadMessages), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.syncThreadMessages"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatGetThreadMessages), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.getThreadMessages"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatSyncThreadsList), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.syncThreadsList"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatGetDeletedMessage), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.getDeletedMessages"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatSendMessage), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.sendMessage"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChatMessageReadReceipts), QUrl(QStringLiteral("http://www.kde.org/api/v1/chat.getMessageReadReceipts"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsAddAll), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.addAll"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsAddLeader), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.addLeader"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsRemoveLeader), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.removeLeader"))); 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::ChannelsModerators), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.moderators"))); 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::ChannelsDelete), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.delete"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsGetAllUserMentionsByChannel), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.getAllUserMentionsByChannel"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsSetEncrypted), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.setEncrypted"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ChannelsOnline), QUrl(QStringLiteral("http://www.kde.org/api/v1/channels.online"))); 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::GroupsListAll), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.listAll"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsMembers), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.members"))); 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::GroupRemoveLeader), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.removeLeader"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsAddLeader), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.addLeader"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsDelete), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.delete"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::GroupsSetEncrypted), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.setEncrypted"))); 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::ImMessages), QUrl(QStringLiteral("http://www.kde.org/api/v1/im.messages"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ImMembers), QUrl(QStringLiteral("http://www.kde.org/api/v1/im.members"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ImOpen), QUrl(QStringLiteral("http://www.kde.org/api/v1/im.open"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::ImSetTopic), QUrl(QStringLiteral("http://www.kde.org/api/v1/im.setTopic"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::LoadEmojiCustom), QUrl(QStringLiteral("http://www.kde.org/api/v1/emoji-custom.list"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::DeleteEmojiCustom), QUrl(QStringLiteral("http://www.kde.org/api/v1/emoji-custom.delete"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::CreateEmojiCustom), QUrl(QStringLiteral("http://www.kde.org/api/v1/emoji-custom.create"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::UpdateEmojiCustom), QUrl(QStringLiteral("http://www.kde.org/api/v1/emoji-custom.update"))); 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::RoomsCreateDiscussion), QUrl(QStringLiteral("http://www.kde.org/api/v1/rooms.createDiscussion"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::RoomsGetDiscussions), QUrl(QStringLiteral("http://www.kde.org/api/v1/rooms.getDiscussions"))); 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.updateGroupKey"))); 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::E2ERequestSubscriptionKeys), QUrl(QStringLiteral("http://www.kde.org/api/v1/e2e.requestSubscriptionKeys"))); 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"))); QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::VideoConfJitsi), QUrl(QStringLiteral("http://www.kde.org/api/v1/video-conference/jitsi.update-timeout"))); + + QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::AutoTranslateGetSupportedLanguages), QUrl(QStringLiteral("http://www.kde.org/api/v1/autotranslate.getSupportedLanguages"))); + QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::AutoTranslateSaveSettings), QUrl(QStringLiteral("http://www.kde.org/api/v1/autotranslate.saveSettings"))); + QCOMPARE(rest.generateUrl(RestApiUtil::RestApiUrlType::AutoTranslateTranslateMessage), QUrl(QStringLiteral("http://www.kde.org/api/v1/autotranslate.translateMessage"))); } diff --git a/src/rocketchatrestapi-qt5/restapiutil.cpp b/src/rocketchatrestapi-qt5/restapiutil.cpp index 05993c8f..bda87f62 100644 --- a/src/rocketchatrestapi-qt5/restapiutil.cpp +++ b/src/rocketchatrestapi-qt5/restapiutil.cpp @@ -1,364 +1,371 @@ /* Copyright (c) 2017-2019 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::UsersRemovePersonalAccessToken: return QStringLiteral("users.removePersonalAccessToken"); case RestApiUtil::RestApiUrlType::UsersGeneratePersonalAccessToken: return QStringLiteral("users.generatePersonalAccessToken"); case RestApiUtil::RestApiUrlType::UsersPresence: return QStringLiteral("users.presence"); case RestApiUtil::RestApiUrlType::UsersUpdateOwnBasicInfo: return QStringLiteral("users.updateOwnBasicInfo"); case RestApiUtil::RestApiUrlType::UsersRegeneratePersonalAccessToken: return QStringLiteral("users.regeneratePersonalAccessToken"); 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::ChatFollowMessage: return QStringLiteral("chat.followMessage"); case RestApiUtil::RestApiUrlType::ChatUnFollowMessage: return QStringLiteral("chat.unfollowMessage"); case RestApiUtil::RestApiUrlType::ChatGetDeletedMessage: return QStringLiteral("chat.getDeletedMessages"); case RestApiUtil::RestApiUrlType::ChatMessageReadReceipts: return QStringLiteral("chat.getMessageReadReceipts"); case RestApiUtil::RestApiUrlType::ChatSyncThreadsList: return QStringLiteral("chat.syncThreadsList"); case RestApiUtil::RestApiUrlType::ChatGetThreadsList: return QStringLiteral("chat.getThreadsList"); case RestApiUtil::RestApiUrlType::ChatSyncThreadMessages: return QStringLiteral("chat.syncThreadMessages"); case RestApiUtil::RestApiUrlType::ChatGetThreadMessages: return QStringLiteral("chat.getThreadMessages"); case RestApiUtil::RestApiUrlType::ChatSendMessage: return QStringLiteral("chat.sendMessage"); 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::ChannelsAddLeader: return QStringLiteral("channels.addLeader"); case RestApiUtil::RestApiUrlType::ChannelsArchive: return QStringLiteral("channels.archive"); case RestApiUtil::RestApiUrlType::ChannelsModerators: return QStringLiteral("channels.moderators"); 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::ChannelsRemoveLeader: return QStringLiteral("channels.removeLeader"); 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::ChannelsDelete: return QStringLiteral("channels.delete"); case RestApiUtil::RestApiUrlType::ChannelsOnline: return QStringLiteral("channels.online"); case RestApiUtil::RestApiUrlType::ChannelsGetAllUserMentionsByChannel: return QStringLiteral("channels.getAllUserMentionsByChannel"); case RestApiUtil::RestApiUrlType::ChannelsSetEncrypted: return QStringLiteral("channels.setEncrypted"); 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::GroupRemoveLeader: return QStringLiteral("groups.removeLeader"); case RestApiUtil::RestApiUrlType::GroupsAddLeader: return QStringLiteral("groups.addLeader"); case RestApiUtil::RestApiUrlType::GroupsDelete: return QStringLiteral("groups.delete"); case RestApiUtil::RestApiUrlType::GroupsListAll: return QStringLiteral("groups.listAll"); case RestApiUtil::RestApiUrlType::GroupsMembers: return QStringLiteral("groups.members"); case RestApiUtil::RestApiUrlType::GroupsSetEncrypted: return QStringLiteral("groups.setEncrypted"); 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::ImOpen: return QStringLiteral("im.open"); case RestApiUtil::RestApiUrlType::ImSetTopic: return QStringLiteral("im.setTopic"); case RestApiUtil::RestApiUrlType::ImHistory: return QStringLiteral("im.history"); case RestApiUtil::RestApiUrlType::ImFiles: return QStringLiteral("im.files"); case RestApiUtil::RestApiUrlType::ImMessages: return QStringLiteral("im.messages"); case RestApiUtil::RestApiUrlType::ImMembers: return QStringLiteral("im.members"); case RestApiUtil::RestApiUrlType::LoadEmojiCustom: return QStringLiteral("emoji-custom.list"); case RestApiUtil::RestApiUrlType::DeleteEmojiCustom: return QStringLiteral("emoji-custom.delete"); case RestApiUtil::RestApiUrlType::CreateEmojiCustom: return QStringLiteral("emoji-custom.create"); case RestApiUtil::RestApiUrlType::UpdateEmojiCustom: return QStringLiteral("emoji-custom.update"); 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 1.0.0 case RestApiUtil::RestApiUrlType::RoomsCreateDiscussion: return QStringLiteral("rooms.createDiscussion"); case RestApiUtil::RestApiUrlType::RoomsGetDiscussions: return QStringLiteral("rooms.getDiscussions"); //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.updateGroupKey"); 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::E2ERequestSubscriptionKeys: return QStringLiteral("e2e.requestSubscriptionKeys"); case RestApiUtil::RestApiUrlType::RolesList: return QStringLiteral("roles.list"); case RestApiUtil::RestApiUrlType::RolesCreate: return QStringLiteral("roles.create"); case RestApiUtil::RestApiUrlType::RolesAddUserToRole: return QStringLiteral("roles.addUserToRole"); case RestApiUtil::RestApiUrlType::VideoConfJitsi: return QStringLiteral("video-conference/jitsi.update-timeout"); + + case RestApiUtil::RestApiUrlType::AutoTranslateGetSupportedLanguages: + return QStringLiteral("autotranslate.getSupportedLanguages"); + case RestApiUtil::RestApiUrlType::AutoTranslateSaveSettings: + return QStringLiteral("autotranslate.saveSettings"); + case RestApiUtil::RestApiUrlType::AutoTranslateTranslateMessage: + return QStringLiteral("autotranslate.translateMessage"); } 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 0af1259f..a1580ea2 100644 --- a/src/rocketchatrestapi-qt5/restapiutil.h +++ b/src/rocketchatrestapi-qt5/restapiutil.h @@ -1,203 +1,209 @@ /* Copyright (c) 2017-2019 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, UsersPresence, /*since 1.1.0*/ UsersUpdateOwnBasicInfo, UsersRegeneratePersonalAccessToken, UsersGetUsernameSuggestion, UsersRemovePersonalAccessToken, UsersGeneratePersonalAccessToken, ChatDelete, ChatGetMessage, ChatPinMessage, ChatPostMessage, ChatReact, ChatSearch, ChatStarMessage, ChatUnPinMessage, ChatUnStarMessage, ChatUpdate, ChatIgnoreUser, ChatReportMessage, //Since 1.0.0 ChatFollowMessage, ChatUnFollowMessage, ChatGetThreadsList, ChatSyncThreadMessages, ChatGetThreadMessages, ChatSyncThreadsList, ChatGetDeletedMessage, ChatSendMessage, ChatMessageReadReceipts, ChannelsAddAll, //@since 0.75 ChannelsAddLeader, ChannelsAddModerator, ChannelsAddOwner, ChannelsArchive, ChannelsCleanHistory, ChannelsClose, ChannelsCreate, ChannelsGetIntegrations, ChannelsHistory, ChannelsInfo, ChannelsInvite, ChannelsKick, ChannelsLeave, ChannelsList, ChannelsListJoined, ChannelsOpen, ChannelsRemoveModerator, ChannelsRemoveOwner, //@since 0.75 ChannelsRemoveLeader, ChannelsRename, ChannelsSetDescription, ChannelsSetJoinCode, ChannelsSetPurpose, ChannelsSetReadOnly, ChannelsSetTopic, ChannelsSetType, ChannelsSetAnnouncement, ChannelsFiles, ChannelsUnarchive, ChannelsCounters, ChannelsMembers, ChannelsJoin, ChannelsOnline, //since 0.70 ChannelsModerators, //Since 0.71 ChannelsDelete, //since 0.65 ChannelsRoles, //since 0.63 ChannelsGetAllUserMentionsByChannel, ChannelsSetEncrypted, GroupsAddAll, GroupsAddModerator, GroupsAddOwner, GroupsAddLeader, GroupsArchive, GroupsClose, GroupsCreate, //since 0.70 GroupsDelete, GroupsGetIntegrations, GroupsHistory, GroupsInfo, GroupsInvite, GroupsKick, GroupsLeave, GroupsList, GroupsOpen, GroupsRemoveModerator, GroupRemoveOwner, GroupRemoveLeader, GroupsRename, GroupsSetDescription, GroupsSetPurpose, GroupsSetReadOnly, GroupsSetTopic, GroupsSetType, GroupsUnarchive, GroupsSetAnnouncement, GroupsFiles, GroupsListAll, GroupsMembers, //Since 0.65 GroupsRoles, GroupsCounters, GroupsSetEncrypted, ServerInfo, Settings, SettingsPublic, Spotlight, LoadEmojiCustom, DeleteEmojiCustom, CreateEmojiCustom, UpdateEmojiCustom, RoomsUpload, RoomsSaveNotification, ImClose, ImCreate, ImHistory, ImFiles, ImOpen, ImMessages, //Since 0.59 ImMembers, ImSetTopic, SubscriptionsRead, SubscriptionsUnRead, SettingsOauth, RoomsGet, RoomsFavorite, RoomscleanHistory, RoomsInfo, RoomsLeave, RoomsCreateDiscussion, RoomsGetDiscussions, ForgotPassword, PermissionsList, CommandsList, //since 0.70 E2ESetRoomKeyID, E2EfetchMyKeys, E2EupdateGroupKey, E2ESetUserPublicAndPrivateKeys, E2EGetUsersOfRoomWithoutKey, E2ERequestSubscriptionKeys, RolesList, RolesCreate, RolesAddUserToRole, //since 0.74 VideoConfJitsi, + + //Autotranslate @since 1.3 + AutoTranslateGetSupportedLanguages, + AutoTranslateSaveSettings, + AutoTranslateTranslateMessage, + }; 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