using System; using System.Net.Http; using System.Threading; using System.Threading.Tasks; namespace Yavsc.Api.Client; /// /// Transport surface that the high-level clients /// (, , /// ) need to do their work. /// /// This is intentionally a thin, transport-only contract. It /// does not include the OIDC login / refresh / logout surface — /// that lives on the concrete YavscApiClient in the /// consuming application and is wired by the application /// composition root. Splitting the two keeps Yavsc.Api.Client /// usable from any host (a CLI, a unit test, a future iOS /// client) without dragging OIDC, identity, and a Settings /// POMVO everywhere. /// /// Implementations are expected to: /// /// Attach a Bearer access token to every outbound request. /// Silently refresh the token on a 401 and retry once. /// Serialise the request body as JSON and deserialise the /// response body with case-insensitive property matching. /// /// /// The exception contract on non-2xx responses is /// with a message that includes /// the response body (capped), so callers can surface the /// server-side validation problem to the UI without losing /// context. /// public interface IYavscApiClient : IAsyncDisposable { /// /// The configured . Clients set its /// BaseAddress in their constructors to point at the /// API host they target. /// HttpClient Http { get; } /// Call a JSON endpoint with a typed return value. /// HTTP verb. /// Path relative to . /// Optional request body, serialised as JSON. /// Cancellation token. Task CallAsync( HttpMethod method, string path, object? body = null, CancellationToken ct = default); /// Call a JSON endpoint that returns no useful body (DELETE, 204, etc.). Task CallAsync( HttpMethod method, string path, object? body = null, CancellationToken ct = default); }