NetworkClient
Coroutine-based HTTP client built on Ktor + OkHttp. The Kotlin counterpart of SwiftyNetwork's NetworkClient.
Responsibilities, per request:
Resolve authorization (endpoint-level, else the configured AuthorizationProvider).
Execute the call.
On
401, refresh the credential and retry up to NetworkClientConfiguration.maxAuthRefreshAttempts.Map non-2xx and transport failures to NetworkError.
Decode the success body into the requested type.
Thread-safe: the mutable configuration/client pair is guarded by a Mutex, and the active client is reference-counted so updateConfiguration never closes a client mid-request.
This class owns orchestration only (lifecycle, retry, auth). Engine construction lives in HttpClientFactory.kt, response validation/decoding and exception mapping in ResponseHandling.kt, and telemetry event construction in NetworkTelemetry.kt.
Functions
Executes endpoint, discarding any response body.
Executes endpoint, optionally sending body (described by bodyType), and decodes the response into responseType.
Swaps in a new NetworkClientConfiguration, rebuilding the underlying engine. The previous client is closed only once its in-flight requests complete, so reconfiguring mid-request is safe.