Skip to content

Commit

Permalink
Add initial files
Browse files Browse the repository at this point in the history
  • Loading branch information
uuksu committed Mar 15, 2022
0 parents commit 8bbc8cf
Show file tree
Hide file tree
Showing 10 changed files with 393 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
*.swp
*.*~
project.lock.json
.DS_Store
*.pyc
nupkg/

# Visual Studio Code
.vscode

# Rider
.idea

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
msbuild.log
msbuild.err
msbuild.wrn

# Visual Studio 2015
.vs/

AppriseApiClient.cs
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/apprise-api"]
path = lib/apprise-api
url = [email protected]:caronc/apprise-api.git
21 changes: 21 additions & 0 deletions LICENSE.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [2022] [Mikko Uuksulainen]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
94 changes: 94 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# NApprise

![CI](https://github.com/uuksu/napprise/workflows/CI/badge.svg)
[![NuGet](https://img.shields.io/nuget/dt/napprise.svg)](https://www.nuget.org/packages/mediatr)
[![NuGet](https://img.shields.io/nuget/vpre/napprise.svg)](https://www.nuget.org/packages/mediatr)

Simple .NET Client for great [Apprise](https://github.com/caronc/apprise) powered by OpenAPI/NSwag.

Uses [Apprise API](https://github.com/caronc/apprise-api) as a target service.

NApprise targets .NET Standard 2.0.

## Installing NApprise

You should install NApprise with NuGet:

Install-Package NApprise

Or by using the .NET CLI:

dotnet add package NApprise

## Requirements

You should have a instance of Apprise API running. Refer [installation guide](https://github.com/caronc/apprise-api#installation) found in the original repository.

## Usage

### Stateless

In staless mode nothing is stored on the server side. This can be also described as a ad hoc.

``` csharp
using NApprise;

var statelessClient = new AppriseStatelessClient("http://localhost:8000", new HttpClient());

// Send stateless notification
await statelessClient.SendNotificationAsync(new StatelessNotificationRequest() {
Urls = new List<string> { "mailto:///example:[email protected]" },
Body = "# Hello World, with Markdown",
Title = "Hello from header",
Type = NotificationType.Info,
Format = NotificationFormat.Markdown
});

```

### Persistent

In persistent mode, preconfigured services can be stored, managed and called.

``` csharp

using NApprise;

var persistentClient = new ApprisePersistentClient("http://localhost:8000", new HttpClient());

// Add urls for configuration
await persistentClient.AddConfigurationAsync("mykey", new AddConfigurationRequest() {
Urls = new List<string> { "mailto:///example:[email protected]", "tgram://123456789:abcdefg_hijklmnop/12315544/" },
});

// Or add configuration text
await persistentClient.AddConfigurationAsync("mykey", new AddConfigurationRequest() {
Config = "me=mailto:///example:[email protected]\nfamily,me=tgram://123456789:abcdefg_hijklmnop/12315544/",
Format = AddConfigurationRequestFormat.Text
});

// Get configuration text
var configurationResult = await persistentClient.GetConfigurationAsync("mykey");

// Get urls and tags for configuration
var urlsResult = await persistentClient.GetUrlsAsync("mykey", Privacy.HideSecrets, "family");

// Send notification with stored configuration
await persistentClient.SendNotificationAsync("mykey", new PersistentNotificationRequest() {
Body = "# Hello World, with Markdown",
Title = "Hello from header",
Type = NotificationType.Info,
Format = NotificationFormat.Markdown,
Tag = "family"
});

// Remove configuration
await persistentClient.RemoveConfigurationAsync("mykey");
```
1 change: 1 addition & 0 deletions lib/apprise-api
Submodule apprise-api added at cb7281
14 changes: 14 additions & 0 deletions samples/NApprise.Sample.Console/NApprise.Sample.Console.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\..\src\NApprise\NApprise.csproj" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
53 changes: 53 additions & 0 deletions samples/NApprise.Sample.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// See https://aka.ms/new-console-template for more information
using NApprise;

// Send stateless notification

var statelessClient = new AppriseStatelessClient("http://localhost:8000", new HttpClient());

await statelessClient.SendNotificationAsync(new StatelessNotificationRequest() {
Urls = new List<string> { "mailto:///example:[email protected]" },
Body = "# Hello World, with Markdown",
Title = "Hello from header",
Type = NotificationType.Info,
Format = NotificationFormat.Markdown
});

var persistentClient = new ApprisePersistentClient("http://localhost:8000", new HttpClient());

// Add urls for configuration

await persistentClient.AddConfigurationAsync("mykey", new AddConfigurationRequest() {
Urls = new List<string> { "mailto:///example:[email protected]", "tgram://123456789:abcdefg_hijklmnop/12315544/" },
});

// Or add configuration text

await persistentClient.AddConfigurationAsync("mykey", new AddConfigurationRequest() {
Config = "me=mailto:///example:[email protected]\nfamily,me=tgram://123456789:abcdefg_hijklmnop/12315544/",
Format = AddConfigurationRequestFormat.Text
});

// Get configuration text

var configurationResult = await persistentClient.GetConfigurationAsync("mykey");

// Get urls and tags for configuration

var urlsResult = await persistentClient.GetUrlsAsync("mykey", Privacy.HideSecrets, "family");

// Send notification with stored configuration

await persistentClient.SendNotificationAsync("mykey", new PersistentNotificationRequest() {
Body = "# Hello World, with Markdown",
Title = "Hello from header",
Type = NotificationType.Info,
Format = NotificationFormat.Markdown,
Tag = "family"
});

// Remove configuration

await persistentClient.RemoveConfigurationAsync("mykey");

Console.ReadKey();
28 changes: 28 additions & 0 deletions src/NApprise.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NApprise", "NApprise\NApprise.csproj", "{1F7684AC-3E45-4BEB-BCDC-416554E1A5E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NApprise.Sample.Console", "..\samples\NApprise.Sample.Console\NApprise.Sample.Console.csproj", "{C2721557-D405-46CE-B28E-117A94819B82}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1F7684AC-3E45-4BEB-BCDC-416554E1A5E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F7684AC-3E45-4BEB-BCDC-416554E1A5E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F7684AC-3E45-4BEB-BCDC-416554E1A5E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F7684AC-3E45-4BEB-BCDC-416554E1A5E2}.Release|Any CPU.Build.0 = Release|Any CPU
{C2721557-D405-46CE-B28E-117A94819B82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2721557-D405-46CE-B28E-117A94819B82}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2721557-D405-46CE-B28E-117A94819B82}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2721557-D405-46CE-B28E-117A94819B82}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
48 changes: 48 additions & 0 deletions src/NApprise/NApprise.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<PropertyGroup>
<Title>Simple .NET Client for great Apprise powered by OpenAPI/NSwag</Title>
<PackageId>NApprise</PackageId>
<Product>NApprise</Product>
<AssemblyName>NApprise</AssemblyName>
<IsPackable>true</IsPackable>
<Authors>Mikko Uuksulainen</Authors>
<PackageTags>Apprise;Client;Notification</PackageTags>
<Description>Simple .NET Client for great Apprise powered by OpenAPI/NSwag</Description>
<PackageDescription>Simple .NET Client for great Apprise powered by OpenAPI/NSwag</PackageDescription>
<PackageProjectUrl>https://github.com/uuksu/NApprise</PackageProjectUrl>
<RepositoryUrl>https://github.com/uuksu/NApprise</RepositoryUrl>
<MinVerMinimumMajorMinor>1.0</MinVerMinimumMajorMinor>
<Readme>../../README.MD</Readme>
<Copyright>©2022 Mikko Uuksulainen</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MinVer" Version="3.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NSwag.MSBuild" Version="13.15.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<Target Name="NSwag" BeforeTargets="BeforeBuild">
<Copy SourceFiles="@(Reference)" DestinationFolder="$(OutDir)References" />
<Exec Command="$(NSwagExe_Net60) run nswag.json /variables:Configuration=$(Configuration)" />
<RemoveDir Directories="$(OutDir)References" />
</Target>

</Project>
Loading

0 comments on commit 8bbc8cf

Please sign in to comment.