Added code to request the api key for CouchPotato

This commit is contained in:
tidusjar 2016-07-08 13:46:56 +01:00
parent f9af1dc12b
commit ae64c11485
10 changed files with 670 additions and 484 deletions

View file

@ -171,6 +171,7 @@ namespace PlexRequests.UI.Modules
Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles();
Post["/cpprofiles", true] = async (x,ct) => await GetCpProfiles();
Post["/cpapikey", true] = async (x,ct) => await GetCpApiKey();
Get["/emailnotification"] = _ => EmailNotifications();
Post["/emailnotification"] = _ => SaveEmailNotifications();
@ -696,6 +697,20 @@ namespace PlexRequests.UI.Modules
return Response.AsJson(profiles);
}
private async Task<Response> GetCpApiKey()
{
var settings = this.Bind<CouchPotatoSettings>();
if (string.IsNullOrEmpty(settings.Username) || string.IsNullOrEmpty(settings.Password))
{
return Response.AsJson(new { Message = "Please enter a username and password to request the Api Key", Result = false });
}
var key = CpApi.GetApiKey(settings.FullUri, settings.Username, settings.Password);
return Response.AsJson(key);
}
private Negotiator Logs()
{
return View["Logs"];