Added Pushbullet notifications #1459 #865

This commit is contained in:
Jamie.Rees 2017-08-03 15:01:45 +01:00
commit da5a4b0641
20 changed files with 463 additions and 7 deletions

View file

@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace Ombi.Api.Pushbullet
{
public interface IPushbulletApi
{
Task Push(string accessToken, string subject, string body, string channelTag);
}
}

View file

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,36 @@
using System.Net.Http;
using System.Threading.Tasks;
namespace Ombi.Api.Pushbullet
{
public class PushbulletApi : IPushbulletApi
{
public PushbulletApi(IApi api)
{
Api = api;
}
private IApi Api { get; }
private const string BaseUrl = "https://api.pushbullet.com/v2";
public async Task Push(string accessToken, string subject, string body, string channelTag)
{
var request = new Request("/pushes", BaseUrl, HttpMethod.Post);
request.AddHeader("Access-Token", accessToken);
request.ApplicationJsonContentType();
var jsonBody = new
{
type = "note",
body = body,
title = subject,
channel_tag = channelTag
};
request.AddJsonBody(jsonBody);
await Api.Request(request);
}
}
}