Skip to content

Commit

Permalink
Merge pull request #23 from tidusjar/dev
Browse files Browse the repository at this point in the history
Release 1.3.0
  • Loading branch information
Jamie committed Mar 17, 2016
2 parents c626daf + 35b1f2b commit 2dee30b
Show file tree
Hide file tree
Showing 51 changed files with 1,454 additions and 119 deletions.
43 changes: 43 additions & 0 deletions PlexRequests.Api.Interfaces/IPushbulletApi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: IPushbulletApi.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 PlexRequests.Api.Models.Notifications;

namespace PlexRequests.Api.Interfaces
{
public interface IPushbulletApi
{
/// <summary>
/// Pushes the specified message.
/// </summary>
/// <param name="accessToken">The access token.</param>
/// <param name="title">The title.</param>
/// <param name="message">The message.</param>
/// <param name="deviceIdentifier">The device identifier.</param>
/// <returns></returns>
PushbulletResponse Push(string accessToken, string title, string message, string deviceIdentifier = default(string));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<Compile Include="IApiRequest.cs" />
<Compile Include="ICouchPotatoApi.cs" />
<Compile Include="IPlexApi.cs" />
<Compile Include="IPushbulletApi.cs" />
<Compile Include="ISonarrApi.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
112 changes: 56 additions & 56 deletions PlexRequests.Api.Models/Movie/CouchPotatoAdd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,65 +19,65 @@ public class Rating



public class Images
{
public List<object> disc_art { get; set; }
public List<string> poster { get; set; }
public List<object> extra_thumbs { get; set; }
public List<string> poster_original { get; set; }
public List<object> landscape { get; set; }
public string[] actors { get; set; }
public List<string> backdrop_original { get; set; }
public List<object> clear_art { get; set; }
public List<object> logo { get; set; }
public List<object> banner { get; set; }
public List<string> backdrop { get; set; }
public List<object> extra_fanart { get; set; }
}
public class Images
{
public List<object> disc_art { get; set; }
public List<string> poster { get; set; }
public List<object> extra_thumbs { get; set; }
public List<string> poster_original { get; set; }
public List<object> landscape { get; set; }
public string[] actors { get; set; }
public List<string> backdrop_original { get; set; }
public List<object> clear_art { get; set; }
public List<object> logo { get; set; }
public List<object> banner { get; set; }
public List<string> backdrop { get; set; }
public List<object> extra_fanart { get; set; }
}

public class Info
{
public Rating rating { get; set; }
public List<string> genres { get; set; }
public int tmdb_id { get; set; }
public string plot { get; set; }
public string tagline { get; set; }
public string original_title { get; set; }
public string[] actor_roles { get; set; }
public bool via_imdb { get; set; }
public string mpaa { get; set; }
public bool via_tmdb { get; set; }
public List<string> directors { get; set; }
public List<string> titles { get; set; }
public string imdb { get; set; }
public int year { get; set; }
public Images images { get; set; }
public List<string> actors { get; set; }
public List<string> writers { get; set; }
public int runtime { get; set; }
public string type { get; set; }
public string released { get; set; }
}
public class Info
{
public Rating rating { get; set; }
public List<string> genres { get; set; }
public int tmdb_id { get; set; }
public string plot { get; set; }
public string tagline { get; set; }
public string original_title { get; set; }
public string[] actor_roles { get; set; }
public bool via_imdb { get; set; }
public string mpaa { get; set; }
public bool via_tmdb { get; set; }
public List<string> directors { get; set; }
public List<string> titles { get; set; }
public string imdb { get; set; }
public int year { get; set; }
public Images images { get; set; }
public List<string> actors { get; set; }
public List<string> writers { get; set; }
public int runtime { get; set; }
public string type { get; set; }
public string released { get; set; }
}

public class Identifiers
{
public string imdb { get; set; }
}
public class Identifiers
{
public string imdb { get; set; }
}

public class Movie
{
public string status { get; set; }
public Info info { get; set; }
public string _t { get; set; }
public List<object> releases { get; set; }
public string title { get; set; }
public string _rev { get; set; }
public string profile_id { get; set; }
public string _id { get; set; }
public object category_id { get; set; }
public string type { get; set; }
public Identifiers identifiers { get; set; }
}
public class Movie
{
public string status { get; set; }
public Info info { get; set; }
public string _t { get; set; }
public List<object> releases { get; set; }
public string title { get; set; }
public string _rev { get; set; }
public string profile_id { get; set; }
public string _id { get; set; }
public object category_id { get; set; }
public string type { get; set; }
public Identifiers identifiers { get; set; }
}


}
38 changes: 38 additions & 0 deletions PlexRequests.Api.Models/Notifications/PushbulletPush.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: PushbulletPush.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 Newtonsoft.Json;

namespace PlexRequests.Api.Models.Notifications
{
public class PushbulletPush
{
public string body { get; set; }
public string title { get; set; }
public string type { get; set; }
public string device_iden { get; set; }
}
}
48 changes: 48 additions & 0 deletions PlexRequests.Api.Models/Notifications/PushbulletResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: PushbulletResponse.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
namespace PlexRequests.Api.Models.Notifications
{
public class PushbulletResponse
{
public bool active { get; set; }
public string iden { get; set; }
public double created { get; set; }
public double modified { get; set; }
public string type { get; set; }
public bool dismissed { get; set; }
public string direction { get; set; }
public string sender_iden { get; set; }
public string sender_email { get; set; }
public string sender_email_normalized { get; set; }
public string sender_name { get; set; }
public string receiver_iden { get; set; }
public string receiver_email { get; set; }
public string receiver_email_normalized { get; set; }
public string title { get; set; }
public string body { get; set; }
}
}
9 changes: 9 additions & 0 deletions PlexRequests.Api.Models/PlexRequests.Api.Models.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -43,6 +47,8 @@
<ItemGroup>
<Compile Include="Movie\CouchPotatoAdd.cs" />
<Compile Include="Movie\CouchPotatoStatus.cs" />
<Compile Include="Notifications\PushbulletPush.cs" />
<Compile Include="Notifications\PushbulletResponse.cs" />
<Compile Include="Plex\PlexAuthentication.cs" />
<Compile Include="Plex\PlexError.cs" />
<Compile Include="Plex\PlexFriends.cs" />
Expand All @@ -58,6 +64,9 @@
<Compile Include="Tv\TvShow.cs" />
<Compile Include="Tv\TvShowImages.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
4 changes: 4 additions & 0 deletions PlexRequests.Api.Models/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net46" />
</packages>
1 change: 1 addition & 0 deletions PlexRequests.Api/ApiRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#endregion
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
Expand Down
1 change: 1 addition & 0 deletions PlexRequests.Api/PlexRequests.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
63 changes: 63 additions & 0 deletions PlexRequests.Api/PushbulletApi.cs
Original file line number Diff line number Diff line change
@@ -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"));
}
}
}

8 changes: 4 additions & 4 deletions PlexRequests.Api/app.config
Original file line number Diff line number Diff line change
@@ -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>
Loading

0 comments on commit 2dee30b

Please sign in to comment.