public static string getScopeString(TwitchScope scopes) { string _result = ""; bool isFirst = true; if (scopes.HasFlag(TwitchScope.ANALYTICS_READ_EXTENSIONS)) { _result += (isFirst ? "" : " ") + "analytics:read:extensions"; isFirst = false; } if (scopes.HasFlag(TwitchScope.ANALYTICS_READ_GAMES)) { _result += (isFirst ? "" : " ") + "analytics:read:games"; isFirst = false; } if (scopes.HasFlag(TwitchScope.BITS_READ)) { _result += (isFirst ? "" : " ") + "bits:read"; isFirst = false; } if (scopes.HasFlag(TwitchScope.CHANNEL_EDIT_COMMERCIAL)) { _result += (isFirst ? "" : " ") + "channel:edit:commercial"; isFirst = false; } if (scopes.HasFlag(TwitchScope.CHANNEL_MANAGE_BROADCAST)) { _result += (isFirst ? "" : " ") + "channel:manage:broadcast"; isFirst = false; } if (scopes.HasFlag(TwitchScope.CHANNEL_MANAGE_EXTENSIONS)) { _result += (isFirst ? "" : " ") + "channel:manage:extensions"; isFirst = false; } if (scopes.HasFlag(TwitchScope.CHANNEL_MANAGE_REDEMPTIONS)) { _result += (isFirst ? "" : " ") + "channel:manage:redemptions"; isFirst = false; } if (scopes.HasFlag(TwitchScope.CHANNEL_MANAGE_VIDEOS)) { _result += (isFirst ? "" : " ") + "channel:manage:videos"; isFirst = false; } if (scopes.HasFlag(TwitchScope.CHANNEL_READ_EDITORS)) { _result += (isFirst ? "" : " ") + "channel:read:editors"; isFirst = false; } if (scopes.HasFlag(TwitchScope.CHANNEL_READ_HYPETRAIN)) { _result += (isFirst ? "" : " ") + "channel:read:hype_train"; isFirst = false; } if (scopes.HasFlag(TwitchScope.CHANNEL_READ_REDEMPTIONS)) { _result += (isFirst ? "" : " ") + "channel:read:redemptions"; isFirst = false; } if (scopes.HasFlag(TwitchScope.CHANNEL_READ_STREAMKEY)) { _result += (isFirst ? "" : " ") + "channel:read:stream_key"; isFirst = false; } if (scopes.HasFlag(TwitchScope.CHANNEL_READ_SUBSCRIPTIONS)) { _result += (isFirst ? "" : " ") + "channel:read:subscriptions"; isFirst = false; } if (scopes.HasFlag(TwitchScope.CLIPS_EDIT)) { _result += (isFirst ? "" : " ") + "clips:edit"; isFirst = false; } if (scopes.HasFlag(TwitchScope.MODERATION_READ)) { _result += (isFirst ? "" : " ") + "moderation:read"; isFirst = false; } if (scopes.HasFlag(TwitchScope.USER_EDIT)) { _result += (isFirst ? "" : " ") + "user:edit"; isFirst = false; } if (scopes.HasFlag(TwitchScope.USER_EDIT_FOLLOWS)) { _result += (isFirst ? "" : " ") + "user:edit:follows"; isFirst = false; } if (scopes.HasFlag(TwitchScope.USER_MANAGE_BLOCKEDUSERS)) { _result += (isFirst ? "" : " ") + "user:manage:blocked_users"; isFirst = false; } if (scopes.HasFlag(TwitchScope.USER_READ_BLOCKEDUSERS)) { _result += (isFirst ? "" : " ") + "user:read:blocked_users"; isFirst = false; } if (scopes.HasFlag(TwitchScope.USER_READ_BROADCAST)) { _result += (isFirst ? "" : " ") + "user:read:broadcast"; isFirst = false; } if (scopes.HasFlag(TwitchScope.USER_READ_FOLLOWS)) { _result += (isFirst ? "" : " ") + "user:read:follows"; isFirst = false; } if (scopes.HasFlag(TwitchScope.USER_READ_SUBSCRIPTIONS)) { _result += (isFirst ? "" : " ") + "user:read:subscriptions"; isFirst = false; } if (scopes.HasFlag(TwitchScope.CHANNEL_MODERATE)) { _result += (isFirst ? "" : " ") + "channel:moderate"; isFirst = false; } if (scopes.HasFlag(TwitchScope.CHAT_EDIT)) { _result += (isFirst ? "" : " ") + "chat:edit"; isFirst = false; } if (scopes.HasFlag(TwitchScope.CHAT_READ)) { _result += (isFirst ? "" : " ") + "chat:read"; isFirst = false; } if (scopes.HasFlag(TwitchScope.WHISPERS_READ)) { _result += (isFirst ? "" : " ") + "whispers:read"; isFirst = false; } if (scopes.HasFlag(TwitchScope.WHISPERS_EDIT)) { _result += (isFirst ? "" : " ") + "whispers:edit"; isFirst = false; } if (scopes.HasFlag(TwitchScope.USER_READ_EMAIL)) { _result += (isFirst ? "" : " ") + "user:read:email"; isFirst = false; } return(_result); }
public UserDetails(JToken jsonData, TwitchScope scope) { string?curr = jsonData.Value <string>("id"); ID = (curr == null) ? "" : curr; curr = jsonData.Value <string>("login"); Login = (curr == null) ? "" : curr; curr = jsonData.Value <string>("display_name"); DisplayName = (curr == null) ? "" : curr; curr = jsonData.Value <string>("broadcaster_type"); if (curr == null) { curr = ""; } if (curr.Equals("partner")) { Broadcaster = BroadcasterType.PARTNER; } else if (curr.Equals("affiliate")) { Broadcaster = BroadcasterType.AFFILIATE; } else { Broadcaster = BroadcasterType.NORMAL; } curr = jsonData.Value <string>("description"); Description = (curr == null) ? "" : curr; curr = jsonData.Value <string>("offline_image_url"); OfflineImageURL = (curr == null) ? "" : curr; curr = jsonData.Value <string>("profile_image_url"); ProfileImageURL = (curr == null) ? "" : curr; curr = jsonData.Value <string>("type"); if (curr == null) { curr = ""; } if (curr.Equals("staff")) { Type = UserType.STAFF; } else if (curr.Equals("admin")) { Type = UserType.ADMIN; } else if (curr.Equals("global_mod")) { Type = UserType.GLOBAL_MOD; } else { Type = UserType.USER; } ViewCount = jsonData.Value <int>("view_count"); curr = jsonData.Value <string>("created_at"); CreatedAt = (curr == null) ? "" : curr; if (scope.HasFlag(TwitchScope.USER_READ_EMAIL)) { curr = jsonData.Value <string>("email"); EMail = (curr == null) ? "" : curr; } }
public static List <TwitchScope> getIndividualScopes(TwitchScope scopes) { List <TwitchScope> _result = new List <TwitchScope>(); if (scopes.HasFlag(TwitchScope.ANALYTICS_READ_EXTENSIONS)) { _result.Add(TwitchScope.ANALYTICS_READ_EXTENSIONS); } if (scopes.HasFlag(TwitchScope.ANALYTICS_READ_GAMES)) { _result.Add(TwitchScope.ANALYTICS_READ_GAMES); } if (scopes.HasFlag(TwitchScope.BITS_READ)) { _result.Add(TwitchScope.BITS_READ); } if (scopes.HasFlag(TwitchScope.CHANNEL_EDIT_COMMERCIAL)) { _result.Add(TwitchScope.CHANNEL_EDIT_COMMERCIAL); } if (scopes.HasFlag(TwitchScope.CHANNEL_MANAGE_BROADCAST)) { _result.Add(TwitchScope.CHANNEL_MANAGE_BROADCAST); } if (scopes.HasFlag(TwitchScope.CHANNEL_MANAGE_EXTENSIONS)) { _result.Add(TwitchScope.CHANNEL_MANAGE_EXTENSIONS); } if (scopes.HasFlag(TwitchScope.CHANNEL_MANAGE_REDEMPTIONS)) { _result.Add(TwitchScope.CHANNEL_MANAGE_REDEMPTIONS); } if (scopes.HasFlag(TwitchScope.CHANNEL_MANAGE_VIDEOS)) { _result.Add(TwitchScope.CHANNEL_MANAGE_VIDEOS); } if (scopes.HasFlag(TwitchScope.CHANNEL_READ_EDITORS)) { _result.Add(TwitchScope.CHANNEL_READ_EDITORS); } if (scopes.HasFlag(TwitchScope.CHANNEL_READ_HYPETRAIN)) { _result.Add(TwitchScope.CHANNEL_READ_HYPETRAIN); } if (scopes.HasFlag(TwitchScope.CHANNEL_READ_REDEMPTIONS)) { _result.Add(TwitchScope.CHANNEL_READ_REDEMPTIONS); } if (scopes.HasFlag(TwitchScope.CHANNEL_READ_STREAMKEY)) { _result.Add(TwitchScope.CHANNEL_READ_STREAMKEY); } if (scopes.HasFlag(TwitchScope.CHANNEL_READ_SUBSCRIPTIONS)) { _result.Add(TwitchScope.CHANNEL_READ_SUBSCRIPTIONS); } if (scopes.HasFlag(TwitchScope.CLIPS_EDIT)) { _result.Add(TwitchScope.CLIPS_EDIT); } if (scopes.HasFlag(TwitchScope.MODERATION_READ)) { _result.Add(TwitchScope.MODERATION_READ); } if (scopes.HasFlag(TwitchScope.USER_EDIT)) { _result.Add(TwitchScope.USER_EDIT); } if (scopes.HasFlag(TwitchScope.USER_EDIT_FOLLOWS)) { _result.Add(TwitchScope.USER_EDIT_FOLLOWS); } if (scopes.HasFlag(TwitchScope.USER_MANAGE_BLOCKEDUSERS)) { _result.Add(TwitchScope.USER_MANAGE_BLOCKEDUSERS); } if (scopes.HasFlag(TwitchScope.USER_READ_BLOCKEDUSERS)) { _result.Add(TwitchScope.USER_READ_BLOCKEDUSERS); } if (scopes.HasFlag(TwitchScope.USER_READ_BROADCAST)) { _result.Add(TwitchScope.USER_READ_BROADCAST); } if (scopes.HasFlag(TwitchScope.USER_READ_FOLLOWS)) { _result.Add(TwitchScope.USER_READ_FOLLOWS); } if (scopes.HasFlag(TwitchScope.USER_READ_SUBSCRIPTIONS)) { _result.Add(TwitchScope.USER_READ_SUBSCRIPTIONS); } if (scopes.HasFlag(TwitchScope.CHANNEL_MODERATE)) { _result.Add(TwitchScope.CHANNEL_MODERATE); } if (scopes.HasFlag(TwitchScope.CHAT_EDIT)) { _result.Add(TwitchScope.CHAT_EDIT); } if (scopes.HasFlag(TwitchScope.CHAT_READ)) { _result.Add(TwitchScope.CHAT_READ); } if (scopes.HasFlag(TwitchScope.WHISPERS_READ)) { _result.Add(TwitchScope.WHISPERS_READ); } if (scopes.HasFlag(TwitchScope.WHISPERS_EDIT)) { _result.Add(TwitchScope.WHISPERS_EDIT); } if (scopes.HasFlag(TwitchScope.USER_READ_EMAIL)) { _result.Add(TwitchScope.USER_READ_EMAIL); } return(_result); }