Skip to content

Commit

Permalink
Conduit support (#389)
Browse files Browse the repository at this point in the history
Adds conduit support in EventSub: GetConduits, CreateConduit, UpdateConduit, DeleteConduit, GetConduitShards, UpdateConduitShards
  • Loading branch information
swiftyspiffy authored Apr 2, 2024
1 parent 97052d8 commit 42dbe49
Show file tree
Hide file tree
Showing 15 changed files with 378 additions and 0 deletions.
17 changes: 17 additions & 0 deletions TwitchLib.Api.Helix.Models/EventSub/Conduits/Conduit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.EventSub.Conduits;

public class Conduit
{
/// <summary>
/// <para>Conduit ID.</para>
/// </summary>
[JsonProperty(PropertyName = "id")]
public string Id { get; protected set; }
/// <summary>
/// <para>Number of shards associated with this conduit.</para>
/// </summary>
[JsonProperty(PropertyName = "shard_count")]
public int ShardCount { get; protected set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.EventSub.Conduits.CreateConduits;

public class CreateConduitsRequest
{
/// <summary>
/// <para>The number of shards to create for this conduit.</para>
/// </summary>
[JsonProperty(PropertyName = "shard_count")]
public int ShardCount { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.EventSub.Conduits.CreateConduits;

public class CreateConduitsResponse
{
/// <summary>
/// <para>List of information about the client’s conduits.</para>
/// </summary>
[JsonProperty(PropertyName = "data")]
public Conduit[] Data { get; protected set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.EventSub.Conduits.GetConduits;

public class GetConduitsResponse
{
/// <summary>
/// <para>List of information about the client’s conduits.</para>
/// </summary>
[JsonProperty(PropertyName = "data")]
public Conduit[] Data { get; protected set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Newtonsoft.Json;
using TwitchLib.Api.Helix.Models.Common;

namespace TwitchLib.Api.Helix.Models.EventSub.Conduits.Shards.GetConduitShards;

public class GetConduitShardsResponse
{
/// <summary>
/// <para>List of information about a conduit's shards.</para>
/// </summary>
[JsonProperty(PropertyName = "data")]
public Shard[] Shards { get; protected set; }
/// <summary>
/// <para>Contains information used to page through a list of results. The object is empty if there are no more pages left to page through.</para>
/// </summary>
[JsonProperty(PropertyName = "pagination")]
public Pagination Pagination { get; protected set; }
}
18 changes: 18 additions & 0 deletions TwitchLib.Api.Helix.Models/EventSub/Conduits/Shards/Shard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.EventSub.Conduits.Shards;

public class Shard
{
/// <summary>
/// <para>Shard ID.</para>
/// </summary>
[JsonProperty(PropertyName = "id")]
public string Id { get; protected set; }
/// <summary>
/// <para>The shard status. The subscriber receives events only for enabled shards. Possible values are: </para>
/// <para>enabled, webhook_callback_verification_pending, webhook_callback_verification_failed, notification_failures_exceeded, websocket_disconnected, websocket_failed_ping_pong, websocket_received_inbound_traffic, websocket_internal_error, websocket_network_timeout, websocket_network_error</para>
/// </summary>
[JsonProperty(PropertyName = "status")]
public string Status { get; protected set; }
}
33 changes: 33 additions & 0 deletions TwitchLib.Api.Helix.Models/EventSub/Conduits/Shards/Transport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.EventSub.Conduits.Shards;

public class Transport
{
/// <summary>
/// <para>The transport method. Possible values are:</para>
/// <para>webhook, websocket</para>
/// </summary>
[JsonProperty(PropertyName = "method")]
public string Method { get; protected set; }
/// <summary>
/// <para>The callback URL where the notifications are sent. Included only if method is set to webhook.</para>
/// </summary>
[JsonProperty(PropertyName = "callback")]
public string Callback { get; protected set; }
/// <summary>
/// <para>An ID that identifies the WebSocket that notifications are sent to. Included only if method is set to websocket.</para>
/// </summary>
[JsonProperty(PropertyName = "session_id")]
public string SessionId { get; protected set; }
/// <summary>
/// <para>The UTC date and time that the WebSocket connection was established. Included only if method is set to websocket.</para>
/// </summary>
[JsonProperty(PropertyName = "connected_at")]
public string ConnectedAt { get; protected set; }
/// <summary>
/// <para>The UTC date and time that the WebSocket connection was lost. Included only if method is set to websocket.</para>
/// </summary>
[JsonProperty(PropertyName = "disconnected_at")]
public string DisconnectedAt { get; protected set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.EventSub.Conduits.Shards.UpdateConduitShards;

public class Error
{
/// <summary>
/// <para>Shard ID.</para>
/// </summary>
[JsonProperty(PropertyName = "id")]
public string Id { get; protected set; }
/// <summary>
/// <para>The error that occurred while updating the shard.</para>
/// </summary>
[JsonProperty(PropertyName = "message")]
public string Message { get; protected set; }
/// <summary>
/// <para>Error codes used to represent a specific error condition while attempting to update shards.</para>
/// </summary>
[JsonProperty(PropertyName = "code")]
public string Code { get; protected set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.EventSub.Conduits.Shards.UpdateConduitShards;

public class ShardUpdate
{
/// <summary>
/// <para>Shard ID.</para>
/// </summary>
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
/// <summary>
/// <para>The transport details that you want Twitch to use when sending you notifications.</para>
/// </summary>
[JsonProperty(PropertyName = "transport")]
public TransportUpdate Transport { get; set; }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.EventSub.Conduits.Shards.UpdateConduitShards;

public class TransportUpdate
{
/// <summary>
/// <para>The transport method. Possible values are:</para>
/// <para>webhook, websocket</para>
/// </summary>
[JsonProperty(PropertyName = "method")]
public string Method { get; set; }
/// <summary>
/// <para>The callback URL where the notifications are sent. The URL must use the HTTPS protocol and port 443. See Processing an event.Specify this field only if method is set to webhook.NOTE: Redirects are not followed.</para>
/// </summary>
[JsonProperty(PropertyName = "callback", NullValueHandling = NullValueHandling.Ignore)]
public string Callback { get; set; }
/// <summary>
/// <para>The secret used to verify the signature. The secret must be an ASCII string that’s a minimum of 10 characters long and a maximum of 100 characters long. For information about how the secret is used, see Verifying the event message.Specify this field only if method is set to webhook.</para>
/// </summary>
[JsonProperty(PropertyName = "secret", NullValueHandling = NullValueHandling.Ignore)]
public string Secret { get; set; }
/// <summary>
/// <para>An ID that identifies the WebSocket to send notifications to. When you connect to EventSub using WebSockets, the server returns the ID in the Welcome message.Specify this field only if method is set to websocket.</para>
/// </summary>
[JsonProperty(PropertyName = "session_id", NullValueHandling = NullValueHandling.Ignore)]
public string SessionId { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.EventSub.Conduits.Shards.UpdateConduitShards;

public class UpdateConduitShardsRequest
{
/// <summary>
/// <para>Conduit ID.</para>
/// </summary>
[JsonProperty(PropertyName = "conduit_id")]
public string ConduitId { get; set; }
/// <summary>
/// <para>List of shards to update.</para>
/// </summary>
[JsonProperty(PropertyName = "shards")]
public ShardUpdate[] Shards { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.EventSub.Conduits.Shards.UpdateConduitShards;

public class UpdateConduitShardsResponse
{
/// <summary>
/// <para>List of successful shard updates.</para>
/// </summary>
[JsonProperty(PropertyName = "data")]
public Shard[] Shards { get; protected set; }
/// <summary>
/// <para>List of unsuccessful updates.</para>
/// </summary>
[JsonProperty(PropertyName = "errors")]
public Error[] Errors { get; protected set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.EventSub.Conduits.UpdateConduits;

public class UpdateConduitsRequest
{
/// <summary>
/// <para>Conduit ID.</para>
/// </summary>
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
/// <summary>
/// <para>The new number of shards for this conduit.</para>
/// </summary>
[JsonProperty(PropertyName = "shard_count")]
public int ShardCount { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Newtonsoft.Json;

namespace TwitchLib.Api.Helix.Models.EventSub.Conduits.UpdateConduits;

public class UpdateConduitsResponse
{
/// <summary>
/// <para>List of information about the client’s conduits.</para>
/// </summary>
[JsonProperty(PropertyName = "data")]
public Conduit[] Data { get; protected set; }
}
Loading

0 comments on commit 42dbe49

Please sign in to comment.