using System.Net; using Microsoft.AspNetCore.Mvc; namespace StellaOps.Policy.Gateway.Clients; internal sealed class PolicyEngineResponse { private PolicyEngineResponse(HttpStatusCode statusCode, TSuccess? value, ProblemDetails? problem, string? location) { StatusCode = statusCode; Value = value; Problem = problem; Location = location; } public HttpStatusCode StatusCode { get; } public TSuccess? Value { get; } public ProblemDetails? Problem { get; } public string? Location { get; } public bool IsSuccess => Problem is null && StatusCode is >= HttpStatusCode.OK and < HttpStatusCode.MultipleChoices; public static PolicyEngineResponse Success(HttpStatusCode statusCode, TSuccess? value, string? location) => new(statusCode, value, problem: null, location); public static PolicyEngineResponse Failure(HttpStatusCode statusCode, ProblemDetails? problem) => new(statusCode, value: default, problem, location: null); }