Initial commit

This commit is contained in:
Stone_Red
2024-03-02 19:10:14 +01:00
commit e9927528e9
38 changed files with 1225 additions and 0 deletions
@@ -0,0 +1,63 @@
using StoneRed.NetificationApi.Client;
using StoneRed.NetificationApi.Client.Models;
using StoneRed.NetificationApi.Server;
using StoneRed.NetificationApi.Server.IdentifyUser;
using StoneRed.NetificationApi.Server.Send;
const string userId = "<UserId>";
const string notificationId = "<NotifcationId>";
const string clientId = "<ClientId>";
const string clientSecret = "<ClientSecret>";
Console.WriteLine("Start client");
NotificationApiClient notificationApiClient = new NotificationApiClient("test", clientId, clientSecret, false);
await notificationApiClient.Start();
Console.WriteLine("Client started");
notificationApiClient.RequestNotifications();
notificationApiClient.RequestedNotificationsReceived += (sender, args) =>
{
Console.WriteLine("Requested notifications received");
foreach (NotificationReceivedData notificationReceiveData in args.Notifications)
{
Console.WriteLine($"Notification received: {notificationReceiveData.Id}");
}
};
notificationApiClient.NewNotificationsReceived += (sender, args) =>
{
Console.WriteLine("New notifications received");
foreach (NotificationReceivedData notificationReceiveData in args.Notifications)
{
Console.WriteLine($"New Notification received: {notificationReceiveData.Id}");
}
};
NotificationApiServer notificationApiServer = new NotificationApiServer(clientId, clientSecret, false);
Console.WriteLine("Identify user");
await notificationApiServer.Identify(new IdentifyUserData
{
UserId = userId,
Email = "[email protected]"
});
Console.WriteLine("User identified");
Console.WriteLine("Send notification");
SendNotificationData sendNotificationData = new SendNotificationData
{
NotificationId = notificationId,
User = new NotificationUser
{
Id = userId
}
};
await notificationApiServer.Send(sendNotificationData);
Console.WriteLine("Notification sent");
Console.ReadLine();
Console.WriteLine("Stop client");
await notificationApiClient.Stop();
Console.WriteLine("Client stopped");
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\StoneRed.NetificationApi\StoneRed.NetificationApi.csproj" />
</ItemGroup>
</Project>