RdvQuery from PostIt

This commit is contained in:
Paul Schneider 2026-08-31 03:37:09 +01:00
commit 9d97994e76
Signed by: notazof
GPG key ID: 1DD5D838E5343B06
19 changed files with 912 additions and 8 deletions

View file

@ -0,0 +1,42 @@
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace Yavsc.Api.Client;
/// <summary>
/// HTTP client for posting commands to the business billing routes.
/// Uses absolute URLs so it can coexist with blog-targeting clients on
/// the same shared transport.
/// </summary>
public sealed class BillingApiClient
{
private const string PathPrefix = "billing";
private readonly IYavscApiClient _api;
private readonly Uri _baseAddress;
public BillingApiClient(IYavscApiClient api, string businessBaseAddress)
{
_api = api ?? throw new ArgumentNullException(nameof(api));
if (string.IsNullOrWhiteSpace(businessBaseAddress))
throw new ArgumentException("Base address is required.", nameof(businessBaseAddress));
_baseAddress = new Uri(businessBaseAddress, UriKind.Absolute);
}
public Task CreateAsync(string billingCode, object payload, CancellationToken ct = default)
{
if (string.IsNullOrWhiteSpace(billingCode))
throw new ArgumentException("Billing code is required.", nameof(billingCode));
return _api.CallAsync(
HttpMethod.Post,
Absolute($"{PathPrefix}/{Uri.EscapeDataString(billingCode)}"),
body: payload,
ct: ct);
}
private string Absolute(string relativePath) => new Uri(_baseAddress, relativePath).ToString();
}