mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-30 19:40:05 -07:00
Fixed the plex friends. Added some unit tests, moved the plex auth into it's own page
This commit is contained in:
parent
d6f3f7b750
commit
07beddc26a
22 changed files with 602 additions and 151 deletions
|
@ -25,8 +25,13 @@
|
|||
// ************************************************************************/
|
||||
#endregion
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
using PlexRequests.Api.Interfaces;
|
||||
using PlexRequests.Api.Models;
|
||||
|
||||
using RestSharp;
|
||||
|
||||
|
@ -57,5 +62,29 @@ namespace PlexRequests.Api
|
|||
return response.Data;
|
||||
|
||||
}
|
||||
|
||||
public T ExecuteXml<T>(IRestRequest request, Uri baseUri) where T : class
|
||||
{
|
||||
var client = new RestClient { BaseUrl = baseUri };
|
||||
|
||||
var response = client.Execute(request);
|
||||
|
||||
if (response.ErrorException != null)
|
||||
{
|
||||
var message = "Error retrieving response. Check inner details for more info.";
|
||||
throw new ApplicationException(message, response.ErrorException);
|
||||
}
|
||||
|
||||
return Deserialize<T>(response.Content);
|
||||
}
|
||||
|
||||
public T Deserialize<T>(string input)
|
||||
where T : class
|
||||
{
|
||||
var ser = new XmlSerializer(typeof(T));
|
||||
|
||||
using (var sr = new StringReader(input))
|
||||
return (T)ser.Deserialize(sr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue