diff --git a/Pushbullet/Api/ServerApiEntryPoints.cs b/Pushbullet/Api/PushbulletNotificationsController.cs
similarity index 60%
rename from Pushbullet/Api/ServerApiEntryPoints.cs
rename to Pushbullet/Api/PushbulletNotificationsController.cs
index c2a86fd..a7c3dc0 100644
--- a/Pushbullet/Api/ServerApiEntryPoints.cs
+++ b/Pushbullet/Api/PushbulletNotificationsController.cs
@@ -1,58 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net.Mime;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Serialization;
-using MediaBrowser.Model.Services;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
using Pushbullet.Configuration;
namespace Pushbullet.Api
{
///
- /// API endpoints.
+ /// Pushbullet notifications controller.
///
- public class ServerApiEntryPoints : IService
+ [ApiController]
+ [Route("Notification/Pushbullet")]
+ [Produces(MediaTypeNames.Application.Json)]
+ public class PushbulletNotificationsController : ControllerBase
{
private readonly IHttpClient _httpClient;
private readonly IJsonSerializer _jsonSerializer;
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// Instance of the interface.
/// Instance of the interface.
- public ServerApiEntryPoints(IJsonSerializer jsonSerializer, IHttpClient httpClient)
+ public PushbulletNotificationsController(IJsonSerializer jsonSerializer, IHttpClient httpClient)
{
_jsonSerializer = jsonSerializer;
_httpClient = httpClient;
}
- private static PushbulletOptions GetOptions(string userId)
- {
- return Plugin.Instance!.Configuration.GetOptions()
- .FirstOrDefault(i => string.Equals(i.UserId, userId, StringComparison.OrdinalIgnoreCase));
- }
-
///
- /// Send test notification.
+ /// Send Pushbullet test notification.
///
- /// Request to send.
- public void Post(TestNotification request)
+ /// The user id of the Jellyfin user.
+ /// Test notification successfully sent.
+ /// A indicating success.
+ [HttpPost("Test/{userId}")]
+ [ProducesResponseType(StatusCodes.Status204NoContent)]
+ public async Task PostAsync([FromRoute] string userId)
{
- PostAsync(request)
- .GetAwaiter()
- .GetResult();
- }
-
- ///
- /// Send test notification.
- ///
- /// Request to send.
- /// A .
- public async Task PostAsync(TestNotification request)
- {
- var options = GetOptions(request.UserId!);
+ var options = Plugin.Instance!.Configuration.GetOptions()
+ .FirstOrDefault(i => string.Equals(i.UserId, userId, StringComparison.OrdinalIgnoreCase));
var parameters = new Dictionary
{
@@ -71,6 +63,8 @@ public async Task PostAsync(TestNotification request)
};
await _httpClient.Post(requestOptions).ConfigureAwait(false);
+
+ return NoContent();
}
}
}
\ No newline at end of file
diff --git a/Pushbullet/Api/TestNotification.cs b/Pushbullet/Api/TestNotification.cs
deleted file mode 100644
index fa8594e..0000000
--- a/Pushbullet/Api/TestNotification.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using MediaBrowser.Model.Services;
-
-namespace Pushbullet.Api
-{
- ///
- /// Test notification request.
- ///
- [Route("/Notification/Pushbullet/Test/{UserId}", "POST", Summary = "Tests Pushbullet")]
- public class TestNotification : IReturnVoid
- {
- ///
- /// Gets or sets user Id to test.
- ///
- [ApiMember(
- Name = "UserId",
- Description = "User Id",
- IsRequired = true,
- DataType = "string",
- ParameterType = "path",
- Verb = "GET")]
- public string? UserId { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Pushbullet/Pushbullet.csproj b/Pushbullet/Pushbullet.csproj
index 30baa5f..b5ec413 100644
--- a/Pushbullet/Pushbullet.csproj
+++ b/Pushbullet/Pushbullet.csproj
@@ -23,6 +23,7 @@
+