Novu 0.1.9

There is a newer version of this package available.
See the version list below for details.
dotnet add package Novu --version 0.1.9
NuGet\Install-Package Novu -Version 0.1.9
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.1.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Novu --version 0.1.9
#r "nuget: Novu, 0.1.9"
#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.1.9

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

<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

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 net7.0 is compatible.  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. 
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