diff --git a/CsuChhs.WebComponents.RestTools/CsuChhs.WebComponents.RestTools.csproj b/CsuChhs.WebComponents.RestTools/CsuChhs.WebComponents.RestTools.csproj index a517a34..b65bbfb 100644 --- a/CsuChhs.WebComponents.RestTools/CsuChhs.WebComponents.RestTools.csproj +++ b/CsuChhs.WebComponents.RestTools/CsuChhs.WebComponents.RestTools.csproj @@ -6,7 +6,7 @@ enable true CHHS Application Development Team - 1.0.1 + 1.0.2 https://github.com/csu-chhs/CsuChhs.WebComponents.RestTools College of Health and Human Sciences CsuChhs.WebComponents.RestTools diff --git a/CsuChhs.WebComponents.RestTools/Extensions/RestExtensions.cs b/CsuChhs.WebComponents.RestTools/Extensions/RestExtensions.cs new file mode 100644 index 0000000..ff79c37 --- /dev/null +++ b/CsuChhs.WebComponents.RestTools/Extensions/RestExtensions.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; +using CsuChhs.WebComponents.RestTools.ResourceModels; + +namespace CsuChhs.WebComponents.RestTools.Extensions; + +public static class RestExtensions +{ + /// + /// Given response.Data it attempts to deserialize into + /// the ProblemDetails object. + /// + /// + /// + public static ProblemDetails? ToProbleDetails(this string content) + { + return JsonConvert + .DeserializeObject(content); + } +} \ No newline at end of file diff --git a/CsuChhs.WebComponents.RestTools/ResourceModels/ProblemDetails.cs b/CsuChhs.WebComponents.RestTools/ResourceModels/ProblemDetails.cs new file mode 100644 index 0000000..1a10a5d --- /dev/null +++ b/CsuChhs.WebComponents.RestTools/ResourceModels/ProblemDetails.cs @@ -0,0 +1,10 @@ +namespace CsuChhs.WebComponents.RestTools.ResourceModels; + +public class ProblemDetails +{ + public string Type { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public int? Status { get; set; } + public string Detail { get; set; } = string.Empty; + public string Instance { get; set; } = string.Empty; +} \ No newline at end of file