|
| 1 | +// Licensed to the Symphony Software Foundation (SSF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The SSF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +namespace SymphonyOSS.RestApiClient.Api.PodApi |
| 19 | +{ |
| 20 | + using Authentication; |
| 21 | + using Generated.OpenApi.PodApi.Client; |
| 22 | + using Generated.OpenApi.PodApi.Model; |
| 23 | + |
| 24 | + /// <summary> |
| 25 | + /// Provides methods for operating over multy party chats |
| 26 | + /// and chat rooms, by encapsulating <see cref="Generated.OpenApi.PodApi.Api.RoomMembershipApi"/>, |
| 27 | + /// adding authentication token management and a custom execution strategy. |
| 28 | + /// </summary> |
| 29 | + public class RoomMembershipApi |
| 30 | + { |
| 31 | + private readonly Generated.OpenApi.PodApi.Api.IRoomMembershipApi _roomMembershipApi; |
| 32 | + |
| 33 | + private readonly IAuthTokens _authTokens; |
| 34 | + |
| 35 | + private readonly IApiExecutor _apiExecutor; |
| 36 | + |
| 37 | + /// <summary> |
| 38 | + /// Initializes a new instance of the <see cref="RoomMembershipApi" /> class. |
| 39 | + /// See <see cref="Factories.PodApiFactory"/> for conveniently constructing |
| 40 | + /// an instance. |
| 41 | + /// </summary> |
| 42 | + /// <param name="authTokens">Authentication tokens.</param> |
| 43 | + /// <param name="configuration">Api configuration.</param> |
| 44 | + /// <param name="apiExecutor">Execution strategy.</param> |
| 45 | + public RoomMembershipApi(IAuthTokens authTokens, Configuration configuration, IApiExecutor apiExecutor) |
| 46 | + { |
| 47 | + _roomMembershipApi = new Generated.OpenApi.PodApi.Api.RoomMembershipApi(configuration); |
| 48 | + _authTokens = authTokens; |
| 49 | + _apiExecutor = apiExecutor; |
| 50 | + } |
| 51 | + |
| 52 | + /// <summary> |
| 53 | + /// Adds a member to an existing room. |
| 54 | + /// </summary> |
| 55 | + /// <param name="roomId">The id of the room.</param> |
| 56 | + /// <param name="userId">The id of the user to add to the room.</param> |
| 57 | + /// <returns></returns> |
| 58 | + public SuccessResponse AddMemberToRoom(string roomId, long? userId) |
| 59 | + { |
| 60 | + return _apiExecutor.Execute(_roomMembershipApi.V1RoomIdMembershipAddPost, roomId, new UserId(userId), _authTokens.SessionToken); |
| 61 | + } |
| 62 | + |
| 63 | + /// <summary> |
| 64 | + /// Removes a member from an existing room. |
| 65 | + /// </summary> |
| 66 | + /// <param name="roomId">The id of the room.</param> |
| 67 | + /// <param name="userId">The id of the user to add to the room.</param> |
| 68 | + /// <returns></returns> |
| 69 | + public SuccessResponse RemoveMemberFromRoom(string roomId, long? userId) |
| 70 | + { |
| 71 | + return _apiExecutor.Execute(_roomMembershipApi.V1RoomIdMembershipRemovePost, roomId, new UserId(userId), _authTokens.SessionToken); |
| 72 | + } |
| 73 | + |
| 74 | + /// <summary> |
| 75 | + /// Promotes a user to owner of the room. |
| 76 | + /// </summary> |
| 77 | + /// <param name="roomId">The id of the room.</param> |
| 78 | + /// <param name="userId">The id of the user to add to the room.</param> |
| 79 | + /// <returns></returns> |
| 80 | + public SuccessResponse PromoteUserToRoomOwner(string roomId, long? userId) |
| 81 | + { |
| 82 | + return _apiExecutor.Execute(_roomMembershipApi.V1RoomIdMembershipPromoteOwnerPost, roomId, new UserId(userId), _authTokens.SessionToken); |
| 83 | + } |
| 84 | + |
| 85 | + /// <summary> |
| 86 | + /// Demotes a user from owner of a room. |
| 87 | + /// </summary> |
| 88 | + /// <param name="roomId">The id of the room.</param> |
| 89 | + /// <param name="userId">The id of the user to add to the room.</param> |
| 90 | + /// <returns></returns> |
| 91 | + public SuccessResponse DemoteRoomOwner(string roomId, long? userId) |
| 92 | + { |
| 93 | + return _apiExecutor.Execute(_roomMembershipApi.V1RoomIdMembershipDemoteOwnerPost, roomId, new UserId(userId), _authTokens.SessionToken); |
| 94 | + } |
| 95 | + |
| 96 | + /// <summary> |
| 97 | + /// Gets the members of a room. |
| 98 | + /// </summary> |
| 99 | + /// <param name="roomId">The id of the room.</param> |
| 100 | + /// <returns></returns> |
| 101 | + public MembershipList GetRoomMembers(string roomId) |
| 102 | + { |
| 103 | + return _apiExecutor.Execute(_roomMembershipApi.V1RoomIdMembershipListGet, roomId, _authTokens.SessionToken); |
| 104 | + } |
| 105 | + } |
| 106 | +} |
0 commit comments