Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/Models/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ public enum AuthType
Resource,
}

[JsonConverter(typeof(StringEnumConverter))]
public enum Product
{
/// <summary>Stream Chat product</summary>
[EnumMember(Value = "chat")]
Chat,

/// <summary>Stream Video product</summary>
[EnumMember(Value = "video")]
Video,

/// <summary>Stream Moderation product</summary>
[EnumMember(Value = "moderation")]
Moderation,

/// <summary>Stream Feeds product</summary>
[EnumMember(Value = "feeds")]
Feeds,

/// <summary>All Stream products (default)</summary>
[EnumMember(Value = "all")]
All,
}

[JsonConverter(typeof(StringEnumConverter))]
public enum CallbackMode
{
Expand Down Expand Up @@ -109,6 +133,9 @@ public class EventHook
/// <summary>Whether this event hook is currently active</summary>
public bool Enabled { get; set; }

/// <summary>Product scope for this event hook</summary>
public Product? Product { get; set; }

/// <summary>List of event types this hook will respond to</summary>
public List<string> EventTypes { get; set; }

Expand Down
20 changes: 16 additions & 4 deletions tests/AppClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,27 @@ public async Task TestEventHooksAsync()
Id = "95fa9371-38d8-4ddb-b099-d9ed86e7c9bc",
HookType = HookType.Webhook,
Enabled = true,
Product = Product.All,
EventTypes = new List<string> { "message.new", "message.updated" },
WebhookUrl = "https://example.com/webhook",
};

var chatWebhookHook = new EventHook
{
Id = "c3eff852-1194-47c2-8e1c-42a0b1dc1151",
HookType = HookType.Webhook,
Enabled = true,
Product = Product.Chat,
EventTypes = new List<string> { "message.new", "message.updated" },
WebhookUrl = "https://example.com/webhook-chat",
};

var sqsHook = new EventHook
{
Id = "4eaa795f-77d2-4b72-8f7e-11de0327121c",
HookType = HookType.SQS,
Enabled = true,
Product = Product.All,
EventTypes = new List<string> { "user.updated" },
SqsQueueUrl = "https://sqs.region.amazonaws.com/123456789012/queue-name",
SqsRegion = "us-east-1",
Expand All @@ -184,19 +196,19 @@ public async Task TestEventHooksAsync()
Id = "7b2c6590-7b61-490a-8987-96c5f8a353ca",
HookType = HookType.SNS,
Enabled = true,
Product = Product.All,
EventTypes = new List<string> { "channel.updated" },
SnsTopicArn = "arn:aws:sns:us-east-1:123456789012:topic-name",
SnsRegion = "us-east-1",
SnsAuthType = AuthType.Resource,
};

var eventHooks = new List<EventHook> { webhookHook, sqsHook, snsHook };

await _appClient.UpdateAppSettingsAsync(new AppSettingsRequest { EventHooks = eventHooks });
var eventHooks = new List<EventHook> { webhookHook, chatWebhookHook, sqsHook, snsHook };

var updateResponse = await _appClient.UpdateAppSettingsAsync(new AppSettingsRequest { EventHooks = eventHooks });
var getAppResponse = await _appClient.GetAppSettingsAsync();
getAppResponse.App.EventHooks.Should().NotBeNull();
getAppResponse.App.EventHooks.Should().HaveCount(3);
getAppResponse.App.EventHooks.Should().HaveCount(4);
getAppResponse.App.EventHooks.Should().BeEquivalentTo(eventHooks, options => options.Excluding(e => e.CreatedAt).Excluding(e => e.UpdatedAt));
}
}
Expand Down
Loading