5MInnov.Tools.WebhookNotification.Ports 1.0.2

dotnet add package 5MInnov.Tools.WebhookNotification.Ports --version 1.0.2
                    
NuGet\Install-Package 5MInnov.Tools.WebhookNotification.Ports -Version 1.0.2
                    
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="5MInnov.Tools.WebhookNotification.Ports" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="5MInnov.Tools.WebhookNotification.Ports" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="5MInnov.Tools.WebhookNotification.Ports" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add 5MInnov.Tools.WebhookNotification.Ports --version 1.0.2
                    
#r "nuget: 5MInnov.Tools.WebhookNotification.Ports, 1.0.2"
                    
#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.
#:package 5MInnov.Tools.WebhookNotification.Ports@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=5MInnov.Tools.WebhookNotification.Ports&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=5MInnov.Tools.WebhookNotification.Ports&version=1.0.2
                    
Install as a Cake Tool

5M Innov Webhook Notification Ports

Description

5M Innov Webhook Notification Ports allows you to create your own adapter and use it within 5MInnov.Tools.WebhookNotification.Domain by injecting it.

Prerequisites

  • .NET 8.0 or later

Installation

You can install this package via the NuGet Package Manager Console:

Install-Package 5MInnov.Tools.WebhookNotification.Ports

or via the .NET CLI:

dotnet add package 5MInnov.Tools.WebhookNotification.Ports

Example of Use

Here is a basic example :

using _5MInnov.Tools.WebhookNotification.Enums;
using _5MInnov.Tools.WebhookNotification.Ports;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System.Net.Http.Headers;

namespace CustomWebhook.Adapters
{
    // Defines a class for sending notifications to webhooks.
    public class CustomWebhookNotification : IWebhookNotification
    {
        #region Public Properties
        // Logger instance for logging errors or critical information.
        public readonly ILogger? Logger;
        #endregion

        #region Constructors
        /// <summary>
        /// Initializes a new instance of the CustomWebhookNotification class with a logger.
        /// </summary>
        /// <param name="logger">The logger to use for logging information or errors.</param>
        public CustomWebhookNotification(ILogger<CustomWebhookNotification> logger)
        {
            Logger = logger;
        }
        #endregion

        #region Public Methods
        /// <summary>
        /// Asynchronously posts a notification message to a webhook.
        /// </summary>
        /// <param name="webHookUri">The URI of the webhook.</param>
        /// <param name="message">The message to post, encapsulated in an IMessage interface.</param>
        /// <param name="raiseError">Indicates whether to throw an exception on failure.</param>
        /// <returns>A task that represents the asynchronous operation, containing a boolean indicating success or failure.</returns>
        public async Task<bool> PostNotificationAsync(Uri webHookUri, IMessage message, bool raiseError)
        {
            //To implements
        }

        /// <summary>
        /// Overload of PostNotificationAsync that constructs a CustomNotification object from provided parameters and posts it.
        /// </summary>
        /// <param name="webHookUri">The URI of the webhook.</param>
        /// <param name="notificationType">The type of notification.</param>
        /// <param name="title">The title of the notification.</param>
        /// <param name="message">The message body of the notification.</param>
        /// <param name="subject">Optional subject of the notification.</param>
        /// <param name="description">Optional description of the notification.</param>
        /// <param name="themeColor">Optional theme color of the notification card.</param>
        /// <param name="icon">Optional URI of an icon for the notification.</param>
        /// <param name="informationLink">Optional URI for more information related to the notification.</param>
        /// <param name="raiseError">Indicates whether to throw an exception on failure.</param>
        /// <returns>A task that represents the asynchronous operation, containing a boolean indicating success or failure.</returns>
        public async Task<bool> PostNotificationAsync(Uri webHookUri, NotificationType notificationType, string title, string message, string? subject = null, string? description = null, string? themeColor = null, Uri? icon = null, Uri? informationLink = null, bool raiseError = false)
        {
            // Create a notification object and post it
            CustomNotification notification = new CustomNotification(notificationType, title, message, subject, description, themeColor, icon, informationLink);
            bool result = await PostNotificationAsync(webHookUri, notification, raiseError);
            return result;
        }
        #endregion
    }
}

Contributors

License

This project is licensed under 5M Innov.

Other Relevant Information

For any questions or suggestions, please contact mtrezieres@5minnov.fr.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on 5MInnov.Tools.WebhookNotification.Ports:

Package Downloads
5MInnov.Tools.WebhookNotification.Domain

Allow to push webhook notification

5MInnov.Tools.WebhookNotification.MicrosoftTeams.Adapters

Microsoft Teams adapter to use with 5MInnov.Tools.WebhookNotification.Domain

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 195 6/18/2024
1.0.1 157 6/18/2024
1.0.0 135 6/18/2024

Fix webhook settings