refactor(api-client): introduce IYavscApiClient abstraction in Yavsc.Api.Client
Yavsc.Api.Client is the new home for high-level HTTP clients (BlogApiClient, CircleApiClient, BlogAclApiClient, etc.). It depends on the host application's transport layer, but the host (PostIt) is a UI app with OIDC, settings, and an ApplicationData directory — none of which the abstract client library should know about. The IYavscApiClient interface captures just the transport surface those clients need: - HttpClient (so the client can configure BaseAddress) - CallAsync<T> and CallAsync (the JSON over HTTP verb) It deliberately leaves out LoginAsync / TrySilentLoginAsync / CurrentAccessToken / HasValidSession / Settings — those are authentication and configuration concerns, not transport. They stay on the concrete YavscApiClient in PostIt.Services. The concrete YavscApiClient now implements IYavscApiClient; the existing public surface is unchanged (no breaking changes for existing call sites in PostIt or the tests). This commit only lays the foundation. The actual high-level clients (Blog/Circle/BlogAcl) land in a follow-up commit that re-uses this interface, so this one stays a small, reviewable refactor.
This commit is contained in:
parent
0e95e28327
commit
ab40af8ef1
4 changed files with 94 additions and 1 deletions
|
|
@ -25,6 +25,7 @@
|
|||
<PackageReference Include="IdentityModel.OidcClient" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
|
||||
<ProjectReference Include="../../Yavsc.Abstract/Yavsc.Abstract.csproj" />
|
||||
<ProjectReference Include="../../Yavsc.Api.Client/Yavsc.Api.Client.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="postit-settings.json">
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using IdentityModel.OidcClient;
|
||||
using PostIt.ViewModels;
|
||||
using Yavsc.Api.Client;
|
||||
|
||||
namespace PostIt.Services;
|
||||
|
||||
|
|
@ -24,7 +25,7 @@ namespace PostIt.Services;
|
|||
/// <see cref="BearerTokenHandler"/> only refreshes once even if many
|
||||
/// concurrent requests are in flight.
|
||||
/// </summary>
|
||||
public class YavscApiClient : IAsyncDisposable
|
||||
public class YavscApiClient : IYavscApiClient, IAsyncDisposable
|
||||
{
|
||||
// 60s of slack before the access_token's nominal expiry. Covers
|
||||
// network latency + JWT validation on the server side.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue