Configuration
The PoliPageClient constructor accepts a PoliPageClientOptions record. Every property is optional except ApiKey. Defaults match the canonical SDK behaviour shared by every Poli Page SDK.
Available options
Section titled “Available options”ApiKey(required) — yourpp_test_orpp_live_key. ThrowsArgumentExceptionif null/empty/whitespace.BaseUrl— override the API endpoint. Defaults tohttps://api.poli.page.RequestTimeout— per-request timeout. Defaults toTimeSpan.FromSeconds(60). Must be> TimeSpan.Zero.MaxRetries— maximum retry attempts for retryable errors. Defaults to2(three total attempts). Must be>= 0.RetryDelay— initial backoff delay. Defaults toTimeSpan.FromMilliseconds(500). Doubles each attempt with jitter.HttpClient— externally-managedHttpClientto share across requests. Caller retains ownership.Logger—ILogger<PoliPageClient>for SDK diagnostics. Defaults to a no-op logger.OnRetry/OnError— observability callbacks. Synchronous, exception-safe.
Injecting an HttpClient
Section titled “Injecting an HttpClient”When HttpClient is supplied via PoliPageClientOptions.HttpClient, the caller retains ownership and the SDK never disposes it. The client ignores the supplied instance’s BaseAddress — it builds absolute URIs from BaseUrl instead — so the same HttpClient can safely be shared with non-Poli-Page traffic.
var client = new PoliPageClient(new PoliPageClientOptions{ ApiKey = Environment.GetEnvironmentVariable("POLI_PAGE_API_KEY")!, HttpClient = httpClientFactory.CreateClient("poli-page"),});Example
Section titled “Example”using Microsoft.Extensions.Logging;using PoliPage;
var loggerFactory = LoggerFactory.Create(b => b.AddConsole());
var client = new PoliPageClient(new PoliPageClientOptions{ ApiKey = Environment.GetEnvironmentVariable("POLI_PAGE_API_KEY")!, RequestTimeout = TimeSpan.FromSeconds(30), MaxRetries = 3, RetryDelay = TimeSpan.FromMilliseconds(250), Logger = loggerFactory.CreateLogger<PoliPageClient>(), OnRetry = evt => Console.WriteLine($"retry attempt={evt.Attempt} delay={evt.Delay}"), OnError = ex => Console.Error.WriteLine($"terminal failure: {ex.Message}"),});