mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 05:13:18 -07:00
parent
457ea103d8
commit
da5a4b0641
20 changed files with 463 additions and 7 deletions
9
src/Ombi.Api.Pushbullet/IPushbulletApi.cs
Normal file
9
src/Ombi.Api.Pushbullet/IPushbulletApi.cs
Normal 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);
|
||||
}
|
||||
}
|
11
src/Ombi.Api.Pushbullet/Ombi.Api.Pushbullet.csproj
Normal file
11
src/Ombi.Api.Pushbullet/Ombi.Api.Pushbullet.csproj
Normal 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>
|
36
src/Ombi.Api.Pushbullet/PushbulletApi.cs
Normal file
36
src/Ombi.Api.Pushbullet/PushbulletApi.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue