Novu 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Novu --version 0.2.0
NuGet\Install-Package Novu -Version 0.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Novu" Version="0.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Novu --version 0.2.0
#r "nuget: Novu, 0.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Novu as a Cake Addin
#addin nuget:?package=Novu&version=0.2.0

// Install Novu as a Cake Tool
#tool nuget:?package=Novu&version=0.2.0

<div align="center"> <a href="https://novu.co" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/2233092/213641039-220ac15f-f367-4d13-9eaf-56e79433b8c1.png"> <img src="https://user-images.githubusercontent.com/2233092/213641043-3bbb3f21-3c53-4e67-afe5-755aeb222159.png" width="280" alt="Logo"/> </picture> </a> </div>

novu-dotnet

NuGet NuGet Deploy to Nuget

.NET SDK for Novu - The open-source notification infrastructure for engineers. 🚀

novu-dotnet targets .NET Standard 2.0 and is compatible with .NET Core 2.0+ and .NET Framework 4.6.1+.

Installation

dotnet add package Novu
using Novu.DTO;
using Novu.Models;
using Novu;
...

 var novuConfiguration = new NovuClientConfiguration
{
    // Defaults to https://api.novu.co/v1
    Url = "https://novu-api.my-domain.com/v1",
    ApiKey = "12345",
};

var novu = new NovuClient(novuConfiguration);

var subscribers = await novu.Subscribers.GetSubscribers();

Examples

Novu Client


using Novu.DTO;
using Novu.Models;
using Novu;
...

var config = new NovuClientConfiguration
{
  ApiKey = "my-key",
};

var client = new NovuClient(config);

Subscribers

Get Subscribers


using Novu.DTO;
using Novu.Models;
using Novu;
...

var subscribers = await client.Subscriber.GetSubscribers()


Get Subscriber


using Novu.DTO;
using Novu.Models;
using Novu;
...

var subscriber = await client.Subscriber.GetSubscriber("subscriberId");


Create Subscriber

using Novu.DTO;
using Novu.Models;
using Novu;
...

var additionalData = new List<AdditionalDataDto>
{
  new AdditionalDataDto
  {
    Key = "External ID",
    Value = "1122334455"
  },
  {
    Key = "SMS_PREFERENCE",
    Value = "EMERGENT_ONLY"
  }
};

var newSubscriberDto = new CreateSubscriberDto
{
  SubscriberId = Guid.NewGuid().ToString(),
  FirstName = "John",
  LastName = "Doe",
  Avatar = "https://unslpash.com/random",
  Email = "jdoe@novu.co",
  Locale = "en-US",
  Phone = "+11112223333",
  Data = additionalData
};

var subscriber = await client.Subcriber.CreateSubscriber()


Update Subscriber


using Novu.DTO;
using Novu.Models;
using Novu;
...

var subscriber = client.Subscriber.GetSubscriber("subscriberId");

subscriber.FirstName = "Updated";
subscriber.LastName = "Subscriber";

var updatedSubscriber = await client.Subscriber.UpdateSubscriber(subscriber);


Delete Subscriber


using Novu.DTO;
using Novu.Models;
using Novu;
...

var deleted = await client.Subscriber.DeleteSubscriber("subscriberId");


Update Online Status


using Novu.DTO;
using Novu.Models;
using Novu;
...

var onlineDto = new SubscriberOnlineDto
{
  IsOnline = true
};

var online = await client.Subscriber.UpdateOnlineStatus("subscriberId", onlineDto);

Events

Trigger

using Novu.DTO; using Novu.Models; using Novu; ...


// OnboardEventPayload.cs
public class OnboardEventPayload
{
  [JsonProperty("username")]
  public string Username { get; set; }

  [JsonProperty("welcomeMessage")]
  public string WelcomeMessage { get; set; }
}

// MyFile.cs
var onboardingMessage = new OnboardEventPayload
{
  Username = "jdoe",
  WelcomeMessage = "Welcome to novu-dotnet"
};

var payload = new EventTriggerDataDto()
{
  EventName = "onboarding",
  To = { SubscriberId = "subscriberId" },
  Payload = onboardingMessage
};

var trigger = await client.Event.Trigger(payload);

if (trigger.TriggerResponsePayloadDto.Acknowledged)
{
  Console.WriteLine("Trigger has been created.");
}

Trigger Bulk


using Novu.DTO;
using Novu.Models;
using Novu;
...

var payload = new List<EventTriggerDataDto>()
{
    new()
    {
        EventName = "test",
        To = { SubscriberId = subscriber.SubscriberId},
        Payload = new TestRecord(){ Message = "Hello"}
    },
    new()
    {
        EventName = "test",
        To = { SubscriberId = subscriber.SubscriberId},
        Payload = new TestRecord(){ Message = "World"}
    },
};

var trigger = await client.Event.TriggerBulkAsync(payload);

Broadcast Trigger


using Novu.DTO;
using Novu.Models;
using Novu;
...

var testRecord = new TestRecord
{
    Message = "This is a test message"
};

var dto = new EventTriggerDataDto()
{
    EventName = "test",
    To =
    {
        SubscriberId = subscriber.SubscriberId
    },
    Payload = testRecord
};

var trigger = await client.Event.TriggerBroadcastAsync(dto);

Cancel Trigger


using Novu.DTO;
using Novu.Models;
using Novu;
...

var cancelled = await client.Event.TriggerCancelAsync("triggerTransactionId");

Topics


// Get Topic

var result = await client.Topic.GetTopicAsync("my-topic");

// Get Topics

var results = await client.Topic.GetTopicsAsync();

// Create Topic
var topicRequest = new TopicCreateDto
{
    Key = $"test:topic:{Guid.NewGuid().ToString()}",
    Name = "Test Topic",
    
};

var topic = await client.Topic.CreateTopicAsync(topicRequest);


// Add Subscriber to Topic
var subscriberList = new TopicSubscriberUpdateDto
{
    Keys = new List<string>
    {
        "test:subscriber:1",
    }
};

var result = await client.Topic.AddSubscriberAsync(topic.Data.Key, subscriberList);

// Remove Subscriber from Topic

var subscriberList = new TopicSubscriberUpdateDto
{
    Keys = new List<string>
    {
        "test:subscriber:1",
    }
};

var result = await client.Topic.RemoveSubscriberAsync(topic.Data.Key, subscriberList);

// Delete Topic

await client.Topic.DeleteTopicAsync("my-topic");

// Rename Topic

var topicRequest = new TopicRenameDto
{
    Name = "New Name"
};

var result = await client.Topic.RenameTopicAsync("my-topic", topicRequest);

Repository Overview

All code is located under the src directory and this will service as the project root.

Novu is the main SDK with Novu.Tests housing all unit tests.

novu-dotnet

  • Clients directory holds all clients that house the actual implementation of the various API calls.
  • DTO directory holds all Data Transfer Objects
  • Exceptions directory holds the custom exception creations
  • Interfaces directory holds all interfaces that are inteded to outline how a class should be structured.
  • Models directory holds various models
  • Utilities directory holds various utility functions used around the project.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Novu:

Package Downloads
Novu.Extensions

Novu .NET SDK

Novu.Sync

Novu .NET SDK

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.3 25,110 9/15/2023
0.3.2 372 8/28/2023
0.3.0 788 8/25/2023
0.2.2 2,355 7/10/2023
0.2.1 4,557 6/2/2023
0.2.0 362 5/9/2023
0.1.9 123 5/5/2023
0.1.8 128 5/5/2023
0.1.3 124 5/1/2023
0.1.2 133 5/1/2023
0.1.1 138 5/1/2023
0.1.0 118 5/1/2023