diff --git a/TwitchLib.PubSub/Models/Responses/Messages/LowTrustUsers.cs b/TwitchLib.PubSub/Models/Responses/Messages/LowTrustUsers.cs index c1b6260..75a4da2 100644 --- a/TwitchLib.PubSub/Models/Responses/Messages/LowTrustUsers.cs +++ b/TwitchLib.PubSub/Models/Responses/Messages/LowTrustUsers.cs @@ -1,12 +1,91 @@ -namespace TwitchLib.PubSub.Models.Responses.Messages +using System; +using System.Linq; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using TwitchLib.PubSub.Extensions; + +namespace TwitchLib.PubSub.Models.Responses.Messages { public class LowTrustUsers : MessageData { - public string RawData { get; private set; } + /// + /// An ID for the suspicious user entry, which is a combination of the channel ID where the treatment was updated and the user ID of the suspicious user. + /// + public string LowTrustId { get; protected set; } + /// + /// ID of the channel where the suspicious user was present + /// + public string ChannelId { get; protected set; } + /// + /// Information about the moderator who made any update for the suspicious user. + /// + public UpdatedBy UpdatedBy { get; protected set; } + /// + /// DateTime of when the treatment was updated for the suspicious user. + /// + public DateTime? UpdatedAt { get; protected set; } + /// + /// User ID of the suspicious user. + /// + public string TargetUserId { get; protected set; } + /// + /// Login of the suspicious user. + /// + public string TargetUser { get; protected set; } + /// + /// The treatment set for the suspicious user, can be “NO_TREATMENT”, “ACTIVE_MONITORING”, or “RESTRICTED” + /// + public string Treatment { get; protected set; } + /// + /// User types (if any) that apply to the suspicious user, can be “UNKNOWN_TYPE”, “MANUALLY_ADDED”, “DETECTED_BAN_EVADER”, or “BANNED_IN_SHARED_CHANNEL” + /// + public string[] Types { get; protected set; } + /// + /// A ban evasion likelihood value (if any) that as been applied to the user automatically by Twitch, can be “UNKNOWN_EVADER”, “UNLIKELY_EVADER”, “LIKELY_EVADER”, or “POSSIBLE_EVADER” + /// + public string BanEvasionEvaluation { get; protected set; } + /// + /// If applicable, an DateTime timestamp for the first time the suspicious user was automatically evaluated by Twitch. + /// + public DateTime? EvaluatedAt { get; protected set; } + + public LowTrustUsers(string jsonStr) + { + JToken json = JObject.Parse(jsonStr); + var data = json.SelectToken("data"); + LowTrustId = data.SelectToken("low_trust_id")?.ToString(); + ChannelId = data.SelectToken("channel_id")?.ToString(); + UpdatedBy = new UpdatedBy(data.SelectToken("updated_by")); + UpdatedAt = (data.SelectToken("updated_at").IsEmpty()) ? (DateTime?) null : DateTime.Parse(data.SelectToken("updated_at").ToString()); + TargetUserId = data.SelectToken("target_user")?.ToString(); + TargetUser = data.SelectToken("target_user")?.ToString(); + Treatment = data.SelectToken("treatment")?.ToString(); + Types = data.SelectToken("types")?.ToObject(); + BanEvasionEvaluation = data.SelectToken("ban_evasion_evaluation")?.ToString(); + EvaluatedAt = (data.SelectToken("evaluated_at").IsEmpty()) ? (DateTime?) null : DateTime.Parse(data.SelectToken("evaluated_at").ToString()); + } + } + + public class UpdatedBy + { + /// + /// User ID of the moderator. + /// + public string Id { get; protected set; } + /// + /// Login of the moderator. + /// + public string Login { get; protected set; } + /// + /// Display name of the moderator. + /// + public string DisplayName { get; protected set; } - public LowTrustUsers(string jsonString) + public UpdatedBy(JToken? json) { - RawData = jsonString; + Id = json?.SelectToken("id")?.ToString(); + Login = json?.SelectToken("login")?.ToString(); + DisplayName = json?.SelectToken("display_name")?.ToString(); } } } \ No newline at end of file