diff --git a/src/Novu.Extensions/IocNovuRegistrationExtensions.cs b/src/Novu.Extensions/IocNovuRegistrationExtensions.cs index 1253578..9914464 100644 --- a/src/Novu.Extensions/IocNovuRegistrationExtensions.cs +++ b/src/Novu.Extensions/IocNovuRegistrationExtensions.cs @@ -3,7 +3,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Novu.Interfaces; -using Novu.NotificationTemplates; using Refit; namespace Novu.Extensions; @@ -19,7 +18,6 @@ public static IServiceCollection RegisterNovuClients( RefitSettings refitSettings = null) { var novuConfiguration = configuration.GetNovuClientConfiguration(); - services.AddTransient(_ => novuConfiguration); Action configureClient = c => { @@ -42,7 +40,6 @@ public static IServiceCollection RegisterNovuClients( services.AddRefitClient(settings).ConfigureHttpClient(configureClient); services.AddRefitClient(settings).ConfigureHttpClient(configureClient); services.AddRefitClient(settings).ConfigureHttpClient(configureClient); - services.AddRefitClient(settings).ConfigureHttpClient(configureClient); services.AddRefitClient(settings).ConfigureHttpClient(configureClient); services.AddRefitClient(settings).ConfigureHttpClient(configureClient); services.AddRefitClient(settings).ConfigureHttpClient(configureClient); @@ -51,6 +48,7 @@ public static IServiceCollection RegisterNovuClients( services.AddRefitClient(settings).ConfigureHttpClient(configureClient); return services + .AddTransient(_ => novuConfiguration) .AddTransient(); } } \ No newline at end of file diff --git a/src/Novu.Tests/IntegrationTests/BaseIntegrationTest.cs b/src/Novu.Tests/IntegrationTests/BaseIntegrationTest.cs index d169e70..d7dbd4a 100644 --- a/src/Novu.Tests/IntegrationTests/BaseIntegrationTest.cs +++ b/src/Novu.Tests/IntegrationTests/BaseIntegrationTest.cs @@ -20,7 +20,6 @@ using Novu.Models.Subscribers; using Novu.Models.Workflows; using Novu.Models.Workflows.Step.Message; -using Novu.NotificationTemplates; using Novu.Sync; using ParkSquare.Testing.Generators; using Refit; @@ -62,7 +61,6 @@ protected BaseIntegrationTest(ITestOutputHelper output) protected IEventClient Event => Get(); protected ITopicClient Topic => Get(); protected IWorkflowGroupClient WorkflowGroup => Get(); - protected INotificationTemplatesClient NotificationTemplates => Get(); protected IWorkflowClient Workflow => Get(); protected ILayoutClient Layout => Get(); protected IIntegrationClient Integration => Get(); diff --git a/src/Novu.Tests/IntegrationTests/NotificationTemplatesTests.cs b/src/Novu.Tests/IntegrationTests/NotificationTemplatesTests.cs deleted file mode 100644 index b54a741..0000000 --- a/src/Novu.Tests/IntegrationTests/NotificationTemplatesTests.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Linq; -using System.Threading.Tasks; -using FluentAssertions; -using Novu.NotificationTemplates; -using Xunit; -using Xunit.Abstractions; - -namespace Novu.Tests.IntegrationTests; - -public class NotificationTemplatesTests : BaseIntegrationTest -{ - public NotificationTemplatesTests(ITestOutputHelper output) : base(output) - { - } - - [Fact(Skip = "Interface is deprecated")] - public async Task Should_Get_Notification_Templates() - { - var templates = await NotificationTemplates.GetTemplates(); - templates.Should().NotBeNull(); - templates.Page.Should().Be(0); - templates.Data.Should().NotBeEmpty(); - } - - [Fact(Skip = "Interface is deprecated")] - public async Task Should_SetStatus() - { - var templates = await NotificationTemplates.GetTemplates(); - var template = templates.Data.First(); - var result = await NotificationTemplates.UpdateStatus(template.Id, - new UpdateTemplateStatusRequest - { - Active = !template.Active, - }); - result.Data.Should().NotBeNull(); - result.Data.Active.Should().Be(!template.Active); - } -} \ No newline at end of file diff --git a/src/Novu/Interfaces/INovuClient.cs b/src/Novu/Interfaces/INovuClient.cs index 4936e02..68d61ba 100644 --- a/src/Novu/Interfaces/INovuClient.cs +++ b/src/Novu/Interfaces/INovuClient.cs @@ -1,16 +1,11 @@ -using Novu.NotificationTemplates; - -namespace Novu.Interfaces; +namespace Novu.Interfaces; public interface INovuClient { - public ISubscriberClient Subscriber { get; } - - public IEventClient Event { get; } - - public ITopicClient Topic { get; } - public INotificationTemplatesClient NotificationTemplates { get; } - public IWorkflowGroupClient WorkflowGroup { get; } + ISubscriberClient Subscriber { get; } + IEventClient Event { get; } + ITopicClient Topic { get; } + IWorkflowGroupClient WorkflowGroup { get; } IWorkflowClient Workflow { get; } ILayoutClient Layout { get; } IIntegrationClient Integration { get; } diff --git a/src/Novu/NotificationTemplates/Child.cs b/src/Novu/NotificationTemplates/Child.cs deleted file mode 100644 index e1ae5cc..0000000 --- a/src/Novu/NotificationTemplates/Child.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Newtonsoft.Json; - -namespace Novu.NotificationTemplates; - -public class Child -{ - [JsonProperty("field")] public string Field { get; set; } - - [JsonProperty("value")] public string Value { get; set; } - - [JsonProperty("operator")] public string Operator { get; set; } - - [JsonProperty("on")] public string On { get; set; } -} \ No newline at end of file diff --git a/src/Novu/NotificationTemplates/Filter.cs b/src/Novu/NotificationTemplates/Filter.cs deleted file mode 100644 index 8d62c8d..0000000 --- a/src/Novu/NotificationTemplates/Filter.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Newtonsoft.Json; - -namespace Novu.NotificationTemplates; - -public class Filter -{ - [JsonProperty("isNegated")] public bool IsNegated { get; set; } - - [JsonProperty("type")] public string Type { get; set; } - - [JsonProperty("value")] public string Value { get; set; } - - [JsonProperty("children")] public Child[] Children { get; set; } -} \ No newline at end of file diff --git a/src/Novu/NotificationTemplates/INotificationTemplatesClient.cs b/src/Novu/NotificationTemplates/INotificationTemplatesClient.cs deleted file mode 100644 index 7f37e9a..0000000 --- a/src/Novu/NotificationTemplates/INotificationTemplatesClient.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Novu.DTO; -using Refit; - -namespace Novu.NotificationTemplates; - -/// -/// see https://docs.novu.co/api/get-notification-templates/ -/// -[Obsolete("Notification templates have been renamed to Workflows, Please use the new workflows controller")] -public interface INotificationTemplatesClient -{ - [Get("/notification-templates")] - public Task> GetTemplates([Query] int page = 0, [Query] int limit = 10); - - [Delete("/notification-templates/{templateId}")] - public Task DeleteTemplate(string templateId); - - [Get("/notification-templates/{templateId}")] - public Task> GetTemplate(string templateId); - - [Put("/notification-templates/{templateId}/status")] - public Task> UpdateStatus( - string templateId, - [Body] UpdateTemplateStatusRequest request); -} \ No newline at end of file diff --git a/src/Novu/NotificationTemplates/NotificationGroup.cs b/src/Novu/NotificationTemplates/NotificationGroup.cs deleted file mode 100644 index 13faf1c..0000000 --- a/src/Novu/NotificationTemplates/NotificationGroup.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Newtonsoft.Json; - -namespace Novu.NotificationTemplates; - -public class NotificationGroup -{ - [JsonProperty("_id")] public string Id { get; set; } - - [JsonProperty("_organizationId")] public string OrganizationId { get; set; } - - [JsonProperty("_environmentId")] public string EnvironmentId { get; set; } - - [JsonProperty("_parentId")] public string ParentId { get; set; } - - [JsonProperty("name")] public string Name { get; set; } -} \ No newline at end of file diff --git a/src/Novu/NotificationTemplates/NotificationTemplate.cs b/src/Novu/NotificationTemplates/NotificationTemplate.cs deleted file mode 100644 index 2855e6a..0000000 --- a/src/Novu/NotificationTemplates/NotificationTemplate.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Newtonsoft.Json; - -namespace Novu.NotificationTemplates; - -public class NotificationTemplate -{ - [JsonProperty("_id")] public string Id { get; set; } - - [JsonProperty("_organizationId")] public string OrganizationId { get; set; } - - [JsonProperty("_creatorId")] public string CreatorId { get; set; } - - [JsonProperty("_environmentId")] public string EnvironmentId { get; set; } - - [JsonProperty("_notificationGroupId")] public string NotificationGroupId { get; set; } - - [JsonProperty("_parentId")] public string ParentId { get; set; } - - [JsonProperty("name")] public string Name { get; set; } - - [JsonProperty("description")] public string Description { get; set; } - - [JsonProperty("active")] public bool Active { get; set; } - - [JsonProperty("draft")] public bool Draft { get; set; } - - [JsonProperty("critical")] public bool Critical { get; set; } - - [JsonProperty("tags")] public string[] Tags { get; set; } - - [JsonProperty("preferenceSettings")] public PreferenceSettings PreferenceSettings { get; set; } - - [JsonProperty("steps")] public Step[] Steps { get; set; } - - [JsonProperty("triggers")] public Trigger[] Triggers { get; set; } - - [JsonProperty("deleted")] public bool Deleted { get; set; } - - [JsonProperty("deletedAt")] public DateTime DeletedAt { get; set; } - - [JsonProperty("deletedBy")] public string DeletedBy { get; set; } - - [JsonProperty("notificationGroup")] public NotificationGroup NotificationGroup { get; set; } -} \ No newline at end of file diff --git a/src/Novu/NotificationTemplates/PreferenceSettings.cs b/src/Novu/NotificationTemplates/PreferenceSettings.cs deleted file mode 100644 index 5557410..0000000 --- a/src/Novu/NotificationTemplates/PreferenceSettings.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Newtonsoft.Json; - -namespace Novu.NotificationTemplates; - -public class PreferenceSettings -{ - [JsonProperty("email")] public bool Email { get; set; } - - [JsonProperty("sms")] public bool Sms { get; set; } - - [JsonProperty("chat")] public bool Chat { get; set; } - - [JsonProperty("push")] public bool Push { get; set; } - - [JsonProperty("in_app")] public bool InApp { get; set; } -} \ No newline at end of file diff --git a/src/Novu/NotificationTemplates/Step.cs b/src/Novu/NotificationTemplates/Step.cs deleted file mode 100644 index 1eb0614..0000000 --- a/src/Novu/NotificationTemplates/Step.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Newtonsoft.Json; - -namespace Novu.NotificationTemplates; - -public class Step -{ - [JsonProperty("_id")] public string Id { get; set; } - - [JsonProperty("name")] public string Name { get; set; } - - [JsonProperty("_templateId")] public string TemplateId { get; set; } - - [JsonProperty("active")] public bool Active { get; set; } - - [JsonProperty("shouldStopOnFail")] public bool ShouldStopOnFail { get; set; } - - [JsonProperty("template")] public object Template { get; set; } - - [JsonProperty("filters")] public Filter[] Filters { get; set; } - - [JsonProperty("_parentId")] public string ParentId { get; set; } - - [JsonProperty("metadata")] public object Metadata { get; set; } - - [JsonProperty("replyCallback")] public object ReplyCallback { get; set; } -} \ No newline at end of file diff --git a/src/Novu/NotificationTemplates/Trigger.cs b/src/Novu/NotificationTemplates/Trigger.cs deleted file mode 100644 index 7b2b4aa..0000000 --- a/src/Novu/NotificationTemplates/Trigger.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Newtonsoft.Json; - -namespace Novu.NotificationTemplates; - -public class Trigger -{ - [JsonProperty("type")] public string Type { get; set; } - - [JsonProperty("identifier")] public string Identifier { get; set; } - - [JsonProperty("variables")] public Variable[] Variables { get; set; } - - [JsonProperty("subscriberVariables")] public Variable[] SubscriberVariables { get; set; } -} \ No newline at end of file diff --git a/src/Novu/NotificationTemplates/UpdateTemplateStatusRequest.cs b/src/Novu/NotificationTemplates/UpdateTemplateStatusRequest.cs deleted file mode 100644 index 7cee2d3..0000000 --- a/src/Novu/NotificationTemplates/UpdateTemplateStatusRequest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Newtonsoft.Json; - -namespace Novu.NotificationTemplates; - -public class UpdateTemplateStatusRequest -{ - [JsonProperty("active")] public bool Active { get; set; } -} \ No newline at end of file diff --git a/src/Novu/NotificationTemplates/Variable.cs b/src/Novu/NotificationTemplates/Variable.cs deleted file mode 100644 index a9dcca5..0000000 --- a/src/Novu/NotificationTemplates/Variable.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Newtonsoft.Json; - -namespace Novu.NotificationTemplates; - -public class Variable -{ - [JsonProperty("name")] public string Name { get; set; } -} \ No newline at end of file diff --git a/src/Novu/Novu.csproj b/src/Novu/Novu.csproj index 30453a8..e2ea49f 100644 --- a/src/Novu/Novu.csproj +++ b/src/Novu/Novu.csproj @@ -38,6 +38,10 @@ + + + + diff --git a/src/Novu/NovuClient.cs b/src/Novu/NovuClient.cs index a20cda3..9ecd412 100644 --- a/src/Novu/NovuClient.cs +++ b/src/Novu/NovuClient.cs @@ -2,7 +2,6 @@ using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; using Novu.Interfaces; -using Novu.NotificationTemplates; using Refit; namespace Novu; @@ -24,34 +23,6 @@ public class NovuClient : INovuClient }, }; - public NovuClient(INovuClientConfiguration configuration) : this(configuration, default) - { - } - - public NovuClient( - ISubscriberClient subscriber, - IEventClient @event, - ITopicClient topic, - INotificationTemplatesClient notificationTemplates, - IWorkflowClient workflow, - IWorkflowGroupClient workflowGroup, - IIntegrationClient integration, - INotificationsClient notifications, - IMessageClient message, - ILayoutClient layout) - { - Subscriber = subscriber; - Event = @event; - Topic = topic; - NotificationTemplates = notificationTemplates; - Workflow = workflow; - WorkflowGroup = workflowGroup; - Integration = integration; - Notifications = notifications; - Message = message; - Layout = layout; - } - public NovuClient( INovuClientConfiguration configuration, HttpClient? client = default, @@ -69,7 +40,6 @@ public NovuClient( Subscriber = RestService.For(httpClient, refitSettings); Event = RestService.For(httpClient, refitSettings); Topic = RestService.For(httpClient, refitSettings); - NotificationTemplates = RestService.For(httpClient, refitSettings); WorkflowGroup = RestService.For(httpClient, refitSettings); Workflow = RestService.For(httpClient, refitSettings); Layout = RestService.For(httpClient, refitSettings); @@ -89,6 +59,5 @@ public NovuClient( public ISubscriberClient Subscriber { get; } public IEventClient Event { get; } public ITopicClient Topic { get; } - public INotificationTemplatesClient NotificationTemplates { get; } public IWorkflowGroupClient WorkflowGroup { get; } } \ No newline at end of file