|
| 1 | +using System.Collections.Generic; |
| 2 | +using System.Net; |
| 3 | +using System.Threading.Tasks; |
| 4 | +using StreamChat.Models; |
| 5 | +using StreamChat.Rest; |
| 6 | + |
| 7 | +namespace StreamChat.Clients |
| 8 | +{ |
| 9 | + /// <summary> |
| 10 | + /// Convenience methods for updating a channel's filter tags. |
| 11 | + /// </summary> |
| 12 | + public partial class ChannelClient |
| 13 | + { |
| 14 | + /// <summary> |
| 15 | + /// Adds one or more filter tags to the channel. |
| 16 | + /// </summary> |
| 17 | + public Task<UpdateChannelResponse> AddFilterTagsAsync(string channelType, string channelId, |
| 18 | + params string[] filterTags) => AddFilterTagsAsync(channelType, channelId, (IEnumerable<string>)filterTags); |
| 19 | + |
| 20 | + /// <summary> |
| 21 | + /// Adds filter tags to the channel. |
| 22 | + /// </summary> |
| 23 | + public async Task<UpdateChannelResponse> AddFilterTagsAsync(string channelType, string channelId, |
| 24 | + IEnumerable<string> filterTags, MessageRequest msg = null) => await ExecuteRequestAsync<UpdateChannelResponse>( |
| 25 | + $"channels/{channelType}/{channelId}", |
| 26 | + HttpMethod.POST, |
| 27 | + HttpStatusCode.Created, |
| 28 | + new ChannelUpdateRequest |
| 29 | + { |
| 30 | + AddFilterTags = filterTags, |
| 31 | + Message = msg, |
| 32 | + }); |
| 33 | + |
| 34 | + /// <summary> |
| 35 | + /// Removes one or more filter tags from the channel. |
| 36 | + /// </summary> |
| 37 | + public Task<ApiResponse> RemoveFilterTagsAsync(string channelType, string channelId, |
| 38 | + params string[] filterTags) => RemoveFilterTagsAsync(channelType, channelId, (IEnumerable<string>)filterTags); |
| 39 | + |
| 40 | + /// <summary> |
| 41 | + /// Removes filter tags from the channel. |
| 42 | + /// </summary> |
| 43 | + public async Task<ApiResponse> RemoveFilterTagsAsync(string channelType, string channelId, |
| 44 | + IEnumerable<string> filterTags, MessageRequest msg = null) => await ExecuteRequestAsync<ApiResponse>( |
| 45 | + $"channels/{channelType}/{channelId}", |
| 46 | + HttpMethod.POST, |
| 47 | + HttpStatusCode.Created, |
| 48 | + new ChannelUpdateRequest |
| 49 | + { |
| 50 | + RemoveFilterTags = filterTags, |
| 51 | + Message = msg, |
| 52 | + }); |
| 53 | + } |
| 54 | +} |
0 commit comments