Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/post 0.3.0 followups #61

Merged
merged 18 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ novu-dotnet targets .NET Standard 2.0 and is compatible with .NET Core 2.0+ and
|-------------|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 0.2.2 | <= 0.17 | Singleton client with Refit's use of RestService |
| 0.3.0 | >= 0.18 | 0.3.0 is not compatible with 0.2.2 and requires upgrade to code. Also 0.18 introduced a breaking change only found in 0.3.0. All 0.2.2 must be upgraded if used against the production system. HttpClient can now be used and injected. |
| 0.3.1 | >= 0.18 | [BREAKING} Obsolete Notification Templates has been removed. Service registration separation of single client and each client. Novu.Extension and Novu.Sync released as packages. |

## Installation

Expand Down Expand Up @@ -135,3 +136,23 @@ The key folders to look into:
- [Interfaces](https://github.com/novuhq/novu-dotnet/tree/main/src/Novu/Interfaces) directory holds all interfaces that are intended to outline how a class should be structured
- [Models](https://github.com/novuhq/novu-dotnet/tree/main/src/Novu/Models) directory holds various models that are sub-resources inside the DTOs

### Major changes

Github issues closed

#### 0.3.1
- #57
- #58
- #59
- #60
- #55
#### 0.3.0
- #19
- #20
- #21
- #34
- #48
- #49
- #50
- #47
- #45
6 changes: 6 additions & 0 deletions src/Novu.Extensions/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public static NovuClientConfiguration GetNovuClientConfiguration(this IConfigura
novuConfiguration.Url = novuConfigurationUrl;
}

var novuConfigurationApiKey = Environment.GetEnvironmentVariable("NOVU_API_KEY");
if (novuConfigurationApiKey is not null)
{
novuConfiguration.ApiKey = novuConfigurationApiKey;
}

return novuConfiguration;
}
}
39 changes: 27 additions & 12 deletions src/Novu.Extensions/IocNovuRegistrationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Novu.Interfaces;
using Novu.NotificationTemplates;
using Refit;

namespace Novu.Extensions;
Expand All @@ -20,28 +19,24 @@ public static IServiceCollection RegisterNovuClients(
{
var novuConfiguration = configuration.GetNovuClientConfiguration();

Action<HttpClient> configureClient = c =>
Action<HttpClient> configureClient = client =>
{
c.BaseAddress = new Uri(novuConfiguration.Url);
client.BaseAddress = new Uri(novuConfiguration.Url);

// allow for multiple registrations—authorization cannot have multiple entries
if (c.DefaultRequestHeaders.Contains("Authorization"))
if (client.DefaultRequestHeaders.Contains("Authorization"))
{
c.DefaultRequestHeaders.Remove("Authorization");
client.DefaultRequestHeaders.Remove("Authorization");
}

c.DefaultRequestHeaders.Add("Authorization", $"ApiKey {novuConfiguration.ApiKey}");
};
var settings = refitSettings ?? new RefitSettings
{
ContentSerializer = new NewtonsoftJsonContentSerializer(NovuClient.DefaultSerializerSettings),
client.DefaultRequestHeaders.Add("Authorization", $"ApiKey {novuConfiguration.ApiKey}");
};
var settings = RefitSettings(refitSettings);

services.AddRefitClient<ISubscriberClient>(settings).ConfigureHttpClient(configureClient);
services.AddRefitClient<IEventClient>(settings).ConfigureHttpClient(configureClient);
services.AddRefitClient<ITopicClient>(settings).ConfigureHttpClient(configureClient);
services.AddRefitClient<IWorkflowGroupClient>(settings).ConfigureHttpClient(configureClient);
services.AddRefitClient<INotificationTemplatesClient>(settings).ConfigureHttpClient(configureClient);
services.AddRefitClient<IWorkflowClient>(settings).ConfigureHttpClient(configureClient);
services.AddRefitClient<ILayoutClient>(settings).ConfigureHttpClient(configureClient);
services.AddRefitClient<IIntegrationClient>(settings).ConfigureHttpClient(configureClient);
Expand All @@ -50,6 +45,26 @@ public static IServiceCollection RegisterNovuClients(
services.AddRefitClient<IExecutionDetailsClient>(settings).ConfigureHttpClient(configureClient);

return services
.AddTransient<INovuClient, NovuClient>();
.AddTransient<INovuClientConfiguration>(_ => novuConfiguration);
}


public static IServiceCollection RegisterNovuClient(
this IServiceCollection services,
IConfiguration configuration,
RefitSettings refitSettings = null)
{
return services
.AddTransient<INovuClient>(_ => new NovuClient(
configuration.GetNovuClientConfiguration(),
refitSettings: RefitSettings(refitSettings)));
}

private static RefitSettings RefitSettings(RefitSettings refitSettings)
{
return refitSettings ?? new RefitSettings
{
ContentSerializer = new NewtonsoftJsonContentSerializer(NovuClient.DefaultSerializerSettings),
};
}
}
2 changes: 1 addition & 1 deletion src/Novu.Extensions/Novu.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- Nuget Settings -->
<PropertyGroup>
<PackageId>Novu.Extensions</PackageId>
<Version>0.3.0</Version>
<Version>0.3.1</Version>
<ProductName>Novu</ProductName>
<Description>Novu .NET SDK</Description>
<RepositoryType>git</RepositoryType>
Expand Down
2 changes: 1 addition & 1 deletion src/Novu.Sync/Novu.Sync.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- Nuget Settings -->
<PropertyGroup>
<PackageId>Novu.Extensions</PackageId>
<Version>0.3.0</Version>
<Version>0.3.1</Version>
<ProductName>Novu</ProductName>
<Description>Novu .NET SDK</Description>
<RepositoryType>git</RepositoryType>
Expand Down
2 changes: 0 additions & 2 deletions src/Novu.Tests/IntegrationTests/BaseIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,7 +61,6 @@ protected BaseIntegrationTest(ITestOutputHelper output)
protected IEventClient Event => Get<IEventClient>();
protected ITopicClient Topic => Get<ITopicClient>();
protected IWorkflowGroupClient WorkflowGroup => Get<IWorkflowGroupClient>();
protected INotificationTemplatesClient NotificationTemplates => Get<INotificationTemplatesClient>();
protected IWorkflowClient Workflow => Get<IWorkflowClient>();
protected ILayoutClient Layout => Get<ILayoutClient>();
protected IIntegrationClient Integration => Get<IIntegrationClient>();
Expand Down
38 changes: 0 additions & 38 deletions src/Novu.Tests/IntegrationTests/NotificationTemplatesTests.cs

This file was deleted.

1 change: 1 addition & 0 deletions src/Novu.Tests/Novu.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<RootNamespace>Novu.Tests</RootNamespace>
<Version>0.3.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
15 changes: 5 additions & 10 deletions src/Novu/Interfaces/INovuClient.cs
Original file line number Diff line number Diff line change
@@ -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; }
Expand Down
14 changes: 0 additions & 14 deletions src/Novu/NotificationTemplates/Child.cs

This file was deleted.

14 changes: 0 additions & 14 deletions src/Novu/NotificationTemplates/Filter.cs

This file was deleted.

25 changes: 0 additions & 25 deletions src/Novu/NotificationTemplates/INotificationTemplatesClient.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/Novu/NotificationTemplates/NotificationGroup.cs

This file was deleted.

44 changes: 0 additions & 44 deletions src/Novu/NotificationTemplates/NotificationTemplate.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/Novu/NotificationTemplates/PreferenceSettings.cs

This file was deleted.

26 changes: 0 additions & 26 deletions src/Novu/NotificationTemplates/Step.cs

This file was deleted.

Loading
Loading