Files
sbox-public/engine/Sandbox.Engine/Platform/Stream/Twitch/TwitchAPI.Users.cs
Garry Newman 62feec4b64 Twitch Api (#5016)
Engine: reworks Twitch IRC parsing/client + Streamer event surface (viewers roster, chat/sub/gift/raid messages) and removes older/broken Twitch API features.

Menu/Editor: adds service linking/stream-connect UI (new Services modal; pause/game modal + editor title button) gated by a project setting.

Services/utilities: introduces helper APIs for linking/listing services; adds unit tests for the IRC parser and subscription tier parsing.
2026-06-06 21:46:13 +01:00

53 lines
1.3 KiB
C#

using System.Text.Json.Serialization;
namespace Sandbox.Twitch;
internal partial class TwitchAPI
{
public class UserResponse
{
[JsonPropertyName( "id" )]
public string Id { get; set; }
[JsonPropertyName( "login" )]
public string Login { get; set; }
[JsonPropertyName( "display_name" )]
public string DisplayName { get; set; }
[JsonPropertyName( "type" )]
public string UserType { get; set; }
[JsonPropertyName( "broadcaster_type" )]
public string BroadcasterType { get; set; }
[JsonPropertyName( "description" )]
public string Description { get; set; }
[JsonPropertyName( "profile_image_url" )]
public string ProfileImageUrl { get; set; }
[JsonPropertyName( "offline_image_url" )]
public string OfflineImageUrl { get; set; }
[JsonPropertyName( "view_count" )]
public int ViewCount { get; set; }
[JsonPropertyName( "email" )]
public string Email { get; set; }
[JsonPropertyName( "created_at" )]
public DateTimeOffset CreatedAt { get; set; }
}
public async Task<UserResponse> GetUser( string username = null )
{
var response = await Get<DataResponse<UserResponse>>( string.IsNullOrEmpty( username ) ?
$"/users" :
$"/users?login={System.Uri.EscapeDataString( username )}" );
return response?.FirstOrDefault();
}
}