Added Pushbullet notifications #8

This commit is contained in:
tidusjar 2016-03-17 14:34:55 +00:00
parent b9a886d5dc
commit f046c5d39b
20 changed files with 534 additions and 61 deletions

View file

@ -72,6 +72,7 @@
<DependentUpon>MockApiData.resx</DependentUpon>
</Compile>
<Compile Include="Mocks\MockSonarrApi.cs" />
<Compile Include="PushbulletApi.cs" />
<Compile Include="SonarrApi.cs" />
<Compile Include="CouchPotatoApi.cs" />
<Compile Include="MovieBase.cs" />

View file

@ -0,0 +1,63 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: PlexApi.cs
// Created By: Jamie Rees
//
// 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.
// ************************************************************************/
#endregion
using System;
using PlexRequests.Api.Interfaces;
using PlexRequests.Api.Models.Notifications;
using RestSharp;
namespace PlexRequests.Api
{
public class PushbulletApi : IPushbulletApi
{
public PushbulletResponse Push(string accessToken, string title, string message, string deviceIdentifier = default(string))
{
var request = new RestRequest
{
Method = Method.POST,
};
request.AddHeader("Access-Token", accessToken);
request.AddHeader("Content-Type", "application/json");
var push = new PushbulletPush { title = title, body = message, type = "note"};
if (!string.IsNullOrEmpty(deviceIdentifier))
{
push.device_iden = deviceIdentifier;
}
request.AddJsonBody(push);
var api = new ApiRequest();
return api.ExecuteJson<PushbulletResponse>(request, new Uri("https://api.pushbullet.com/v2/pushes"));
}
}
}

View file

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /></startup></configuration>