diff --git a/TwitchLib.Api.Helix.Models/Moderation/GetModeratedChannels/GetModeratedChannelsResponse.cs b/TwitchLib.Api.Helix.Models/Moderation/GetModeratedChannels/GetModeratedChannelsResponse.cs new file mode 100644 index 00000000..c258e8fa --- /dev/null +++ b/TwitchLib.Api.Helix.Models/Moderation/GetModeratedChannels/GetModeratedChannelsResponse.cs @@ -0,0 +1,26 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using TwitchLib.Api.Helix.Models.Common; +using TwitchLib.Api.Helix.Models.Moderation.GetModerators; + +namespace TwitchLib.Api.Helix.Models.Moderation.GetModeratedChannels +{ + /// + /// List of channels that the specified user has moderator privileges in. + /// + public class GetModeratedChannelsResponse + { + /// + /// The list of channels that the user has moderator privileges in. + /// + [JsonProperty(PropertyName = "data")] + public ModeratedChannel[] Data { get; protected set; } + /// + /// Contains the information used to page through the list of results. The object is empty if there are no more pages left to page through. + /// + [JsonProperty(PropertyName = "pagination")] + public Pagination Pagination { get; protected set; } + } +} diff --git a/TwitchLib.Api.Helix.Models/Moderation/GetModeratedChannels/ModeratedChannel.cs b/TwitchLib.Api.Helix.Models/Moderation/GetModeratedChannels/ModeratedChannel.cs new file mode 100644 index 00000000..010dde67 --- /dev/null +++ b/TwitchLib.Api.Helix.Models/Moderation/GetModeratedChannels/ModeratedChannel.cs @@ -0,0 +1,26 @@ +using Newtonsoft.Json; + +namespace TwitchLib.Api.Helix.Models.Moderation.GetModeratedChannels +{ + /// + /// Channel that the user has moderator privileges in. + /// + public class ModeratedChannel + { + /// + /// An ID that uniquely identifies the channel this user can moderate. + /// + [JsonProperty(PropertyName = "broadcaster_id")] + public string BroadcasterId { get; protected set; } + /// + /// The channel’s login name. + /// + [JsonProperty(PropertyName = "broadcaster_login")] + public string BroadcasterLogin { get; protected set; } + /// + /// The channels’ display name. + /// + [JsonProperty(PropertyName = "broadcaster_name")] + public string BroadcasterName { get; protected set; } + } +} diff --git a/TwitchLib.Api.Helix/Moderation.cs b/TwitchLib.Api.Helix/Moderation.cs index b01c818e..7ab85a9a 100644 --- a/TwitchLib.Api.Helix/Moderation.cs +++ b/TwitchLib.Api.Helix/Moderation.cs @@ -2,14 +2,12 @@ using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using TwitchLib.Api.Core; using TwitchLib.Api.Core.Enums; using TwitchLib.Api.Core.Exceptions; using TwitchLib.Api.Core.Interfaces; -using TwitchLib.Api.Helix.Models.Entitlements; using TwitchLib.Api.Helix.Models.Moderation.AutomodSettings; using TwitchLib.Api.Helix.Models.Moderation.BanUser; using TwitchLib.Api.Helix.Models.Moderation.BlockedTerms; @@ -17,12 +15,12 @@ using TwitchLib.Api.Helix.Models.Moderation.CheckAutoModStatus.Request; using TwitchLib.Api.Helix.Models.Moderation.GetBannedEvents; using TwitchLib.Api.Helix.Models.Moderation.GetBannedUsers; +using TwitchLib.Api.Helix.Models.Moderation.GetModeratedChannels; using TwitchLib.Api.Helix.Models.Moderation.GetModeratorEvents; using TwitchLib.Api.Helix.Models.Moderation.GetModerators; using TwitchLib.Api.Helix.Models.Moderation.ShieldModeStatus; using TwitchLib.Api.Helix.Models.Moderation.ShieldModeStatus.GetShieldModeStatus; using TwitchLib.Api.Helix.Models.Moderation.ShieldModeStatus.UpdateShieldModeStatus; -using TwitchLib.Api.Helix.Models.Moderation.UnbanRequests; using TwitchLib.Api.Helix.Models.Moderation.UnbanRequests.GetUnbanRequests; using TwitchLib.Api.Helix.Models.Moderation.UnbanRequests.ResolveUnbanRequests; @@ -776,5 +774,38 @@ public Task ResolveUnbanRequestsAsync(string broad #endregion #endregion + + #region GetModeratedChannels + /// + /// Gets a list of channels that the specified user has moderator privileges in. + /// Requires a user access token that includes the user:read:moderated_channels scope. + /// The ID in the broadcaster_id query parameter must match the user ID in the access token. + /// + /// Id of the user you want the list of channels that this user has moderator privileges in. + /// Maximum number of objects to return. Maximum: 100. Default: 20. + /// Cursor for forward pagination: tells the server where to start fetching the next set of results in a multi-page response. + /// optional access token to override the use of the stored one in the TwitchAPI instance + /// + /// + public Task GetModeratedChannelsAsync(string userId, int first = 20, string after = null, string accessToken = null) + { + if (string.IsNullOrWhiteSpace(userId)) + throw new BadParameterException("userId cannot be null/empty/whitespace"); + if (first > 100 || first < 1) + throw new BadParameterException("first must be greater than 0 and less than 101"); + + var getParams = new List> + { + new KeyValuePair("user_id", userId), + new KeyValuePair("first", first.ToString()) + }; + + if (!string.IsNullOrWhiteSpace(after)) + getParams.Add(new KeyValuePair("after", after)); + + return TwitchGetGenericAsync("/moderation/channels", ApiVersion.Helix, getParams, accessToken); + } + + #endregion } }