Skip to content

Commit

Permalink
Add missing GetSharedChatSession endpoint & ContentClassificationLabe…
Browse files Browse the repository at this point in the history
…lEnum (#412)

* Add politics or sensitive social issues ContentClassificationLabelEnum

* Add GetSharedChatSession endpoint
  • Loading branch information
iryis authored Dec 17, 2024
1 parent 796c294 commit 1df3d8e
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 0 deletions.
6 changes: 6 additions & 0 deletions TwitchLib.Api.Core.Enums/ContentClassificationLabelEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
/// </summary>
public enum ContentClassificationLabelEnum
{
/// <summary>
/// <para>Content Classification Label for broadcasts with discussions or debates about politics
/// or sensitive social issues such as elections, civic integrity, military conflict, and civil rights.</para>
/// </summary>
DebatedSocialIssuesAndPolitics,

/// <summary>
/// <para>Content Classification Label for broadcasts with excessive tobacco glorification or promotion,
/// any marijuana consumption/use, legal drug and alcohol induced intoxication, discussions of illegal drugs.</para>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json;
using TwitchLib.Api.Helix.Models.GuestStar;

namespace TwitchLib.Api.Helix.Models.SharedChat.GetSharedChatSession;

/// <summary>
/// Get shared chat session response object.
/// </summary>
public class GetSharedChatSessionResponse
{
/// <summary>
/// <para>A list that contains the channels shared chat sessions</para>
/// </summary>
[JsonProperty(PropertyName = "data")]
public SharedChatSession[] Data { get; protected set; }
}
15 changes: 15 additions & 0 deletions TwitchLib.Api.Helix.Models/SharedChat/SharedChatParticipant.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.SharedChat;

/// <summary>
/// A participant in the shared chat session.
/// </summary>
public class SharedChatParticipant
{
/// <summary>
/// The User ID of the participant's channel.
/// </summary>
[JsonProperty(PropertyName = "broadcaster_id")]
public string BroadcasterId { get; protected set; }
}
39 changes: 39 additions & 0 deletions TwitchLib.Api.Helix.Models/SharedChat/SharedChatSession.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.SharedChat;

/// <summary>
/// The shared chat session details
/// </summary>
public class SharedChatSession
{
/// <summary>
/// The unique identifier for the shared chat session.
/// </summary>
[JsonProperty(PropertyName = "session_id")]
public string SessionId { get; protected set; }

/// <summary>
/// The User ID of the host channel.
/// </summary>
[JsonProperty(PropertyName = "host_broadcaster_id")]
public string HostBroadcasterId { get; protected set; }

/// <summary>
/// The list of participants in the session.
/// </summary>
[JsonProperty(PropertyName = "participants")]
public SharedChatParticipant[] Participants { get; protected set; }

/// <summary>
/// The UTC date and time (in RFC3339 format) for when the session was created.
/// </summary>
[JsonProperty(PropertyName = "created_at")]
public string CreatedAt { get; protected set; }

/// <summary>
/// The UTC date and time (in RFC3339 format) for when the session was last updated.
/// </summary>
[JsonProperty(PropertyName = "updated_at")]
public string UpdatedAt { get; protected set; }
}
51 changes: 51 additions & 0 deletions TwitchLib.Api.Helix/SharedChat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Newtonsoft.Json;
using TwitchLib.Api.Core;
using TwitchLib.Api.Core.Enums;
using TwitchLib.Api.Core.Exceptions;
using TwitchLib.Api.Core.Interfaces;
using TwitchLib.Api.Helix.Models.GuestStar.CreateGuestStarSession;
using TwitchLib.Api.Helix.Models.GuestStar.GetChannelGuestStarSettings;
using TwitchLib.Api.Helix.Models.GuestStar.GetGuestStarInvites;
using TwitchLib.Api.Helix.Models.GuestStar.GetGuestStarSession;
using TwitchLib.Api.Helix.Models.GuestStar.UpdateChannelGuestStarSettings;
using TwitchLib.Api.Helix.Models.SharedChat.GetSharedChatSession;

namespace TwitchLib.Api.Helix;

/// <summary>
/// Shared Chat related APIs
/// </summary>
public class SharedChat : ApiBase
{
public SharedChat(IApiSettings settings, IRateLimiter rateLimiter, IHttpCallHandler http) : base(settings,
rateLimiter, http)
{}

#region GetSharedChatSession

/// <summary>
/// <para><see href="https://dev.twitch.tv/docs/api/reference/#get-shared-chat-session">
/// Twitch Docs: Get Shared Chat Session</see></para>
/// <para>Retrieves the active shared chat session for a channel.</para>
/// </summary>
/// <param name="broadcasterId">The User ID of the channel broadcaster.</param>
/// <param name="accessToken">Optional access token to override the use of the stored one in the TwitchAPI instance</param>
/// <returns cref="GetChannelGuestStarSettingsResponse"></returns>
/// <exception cref="BadParameterException"></exception>
public Task<GetSharedChatSessionResponse> GetSharedChatSessionAsync(string broadcasterId, string accessToken = null)
{
if (string.IsNullOrWhiteSpace(broadcasterId))
throw new BadParameterException("broadcasterId must be set");

var getParams = new List<KeyValuePair<string, string>>
{
new("broadcaster_id", broadcasterId)
};

return TwitchGetGenericAsync<GetSharedChatSessionResponse>("/shared_chat/session", ApiVersion.Helix, getParams, accessToken);
}

#endregion
}

0 comments on commit 1df3d8e

Please sign in to comment.