|
|
@ -43,7 +43,7 @@ namespace PlexRequests.UI.Modules
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public ApplicationTesterModule(ICouchPotatoApi cpApi, ISonarrApi sonarrApi, IPlexApi plexApi,
|
|
|
|
public ApplicationTesterModule(ICouchPotatoApi cpApi, ISonarrApi sonarrApi, IPlexApi plexApi,
|
|
|
|
ISettingsService<AuthenticationSettings> authSettings, ISickRageApi srApi) : base("test")
|
|
|
|
ISettingsService<AuthenticationSettings> authSettings, ISickRageApi srApi, IHeadphonesApi hpApi) : base("test")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.RequiresAuthentication();
|
|
|
|
this.RequiresAuthentication();
|
|
|
|
|
|
|
|
|
|
|
@ -52,6 +52,7 @@ namespace PlexRequests.UI.Modules
|
|
|
|
PlexApi = plexApi;
|
|
|
|
PlexApi = plexApi;
|
|
|
|
AuthSettings = authSettings;
|
|
|
|
AuthSettings = authSettings;
|
|
|
|
SickRageApi = srApi;
|
|
|
|
SickRageApi = srApi;
|
|
|
|
|
|
|
|
HeadphonesApi = hpApi;
|
|
|
|
|
|
|
|
|
|
|
|
Post["/cp"] = _ => CouchPotatoTest();
|
|
|
|
Post["/cp"] = _ => CouchPotatoTest();
|
|
|
|
Post["/sonarr"] = _ => SonarrTest();
|
|
|
|
Post["/sonarr"] = _ => SonarrTest();
|
|
|
@ -66,6 +67,7 @@ namespace PlexRequests.UI.Modules
|
|
|
|
private ICouchPotatoApi CpApi { get; }
|
|
|
|
private ICouchPotatoApi CpApi { get; }
|
|
|
|
private IPlexApi PlexApi { get; }
|
|
|
|
private IPlexApi PlexApi { get; }
|
|
|
|
private ISickRageApi SickRageApi { get; }
|
|
|
|
private ISickRageApi SickRageApi { get; }
|
|
|
|
|
|
|
|
private IHeadphonesApi HeadphonesApi { get; }
|
|
|
|
private ISettingsService<AuthenticationSettings> AuthSettings { get; }
|
|
|
|
private ISettingsService<AuthenticationSettings> AuthSettings { get; }
|
|
|
|
|
|
|
|
|
|
|
|
private Response CouchPotatoTest()
|
|
|
|
private Response CouchPotatoTest()
|
|
|
@ -172,7 +174,32 @@ namespace PlexRequests.UI.Modules
|
|
|
|
|
|
|
|
|
|
|
|
private Response HeadphonesTest()
|
|
|
|
private Response HeadphonesTest()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException(); //TODO
|
|
|
|
var settings = this.Bind<HeadphonesSettings>();
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var result = HeadphonesApi.GetVersion(settings.ApiKey, settings.FullUri);
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(result.latest_version))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
Response.AsJson(new JsonResponseModel
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Result = true,
|
|
|
|
|
|
|
|
Message = "Connected to Headphones successfully!"
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Headphones, please check your settings." });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (ApplicationException e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Warn("Exception thrown when attempting to get Headphones's status: ");
|
|
|
|
|
|
|
|
Log.Warn(e);
|
|
|
|
|
|
|
|
var message = $"Could not connect to Headphones, please check your settings. <strong>Exception Message:</strong> {e.Message}";
|
|
|
|
|
|
|
|
if (e.InnerException != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
message = $"Could not connect to Headphones, please check your settings. <strong>Exception Message:</strong> {e.InnerException.Message}";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = message }); ;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|