Package-level declarations

Types

Link copied to clipboard

Default LogSink writing to Android's Logcat under the kenwork.<category> tag.

Link copied to clipboard
interface ApiClient

The minimal request contract. Mirrors SwiftyNetwork's APIClient.

Link copied to clipboard

Supplies (and refreshes) the authorization applied to requests that don't carry their own. Mirrors SwiftyNetwork's AuthorizationProvider.

Link copied to clipboard
sealed interface AuthorizationType

How an outgoing request is authorized. Mirrors SwiftyNetwork's AuthorizationType.

Link copied to clipboard
class DefaultRetryPolicy(val maxRetries: Int = DEFAULT_MAX_RETRIES, val retryNonIdempotent: Boolean = false, val backoffBaseMillis: Long = DEFAULT_BACKOFF_BASE_MILLIS, val backoffMaxMillis: Long = DEFAULT_BACKOFF_MAX_MILLIS, val isRetryableStatus: (Int) -> Boolean = { it == STATUS_TOO_MANY_REQUESTS || it >= STATUS_SERVER_ERROR }, random: Random = Random.Default) : RetryPolicy

The default RetryPolicy: retries transient failures — timeouts, lost connectivity, 429, and 5xx — with exponential backoff and full jitter, honoring a server Retry-After hint when present. Non-idempotent methods (POST/PATCH) are not retried unless retryNonIdempotent.

Link copied to clipboard
@Serializable
data object EmptyResponse

A decodable placeholder for endpoints that return no meaningful body (e.g. 204 No Content). Mirrors SwiftyNetwork's EmptyResponse.

Link copied to clipboard

HTTP request methods supported by NetworkEndpoint. Mirrors SwiftyNetwork's HTTPMethod.

Link copied to clipboard

Lightweight, dependency-free logging facade for the library. Mirrors SwiftyNetwork's Logger.

Link copied to clipboard

Functional area a log line belongs to. Mirrors SwiftyNetwork's Logger.Category.

Link copied to clipboard

Verbosity levels for KenworkLogger. Mirrors SwiftyNetwork's LogLevel.

Link copied to clipboard
fun interface LogSink

Destination for log lines. Replace KenworkLogger.sink to route logs elsewhere.

Link copied to clipboard
class NetworkClient(configuration: NetworkClientConfiguration = NetworkClientConfiguration()) : NetworkDataSource

Coroutine-based HTTP client built on Ktor + OkHttp. The Kotlin counterpart of SwiftyNetwork's NetworkClient.

Link copied to clipboard
class NetworkClientConfiguration(val json: Json = DefaultKenworkJson, val authorizationProvider: AuthorizationProvider? = null, val maxAuthRefreshAttempts: Int = 1, val retryPolicy: RetryPolicy = DefaultRetryPolicy(), val reachabilityGate: ReachabilityGate? = null, val reachabilityWaitMillis: Long = DEFAULT_REACHABILITY_WAIT_MILLIS, val timeoutMillis: Long = DEFAULT_TIMEOUT_MILLIS, val retryDelayMillis: Long = DEFAULT_RETRY_DELAY_MILLIS, val logLevel: LogLevel = LogLevel.WARNING, val engineInterceptors: List<Interceptor> = emptyList(), val okHttpConfig: OkHttpClient.Builder.() -> Unit? = null, val okHttpCache: Cache? = null, val sslPinning: SslPinningConfiguration? = null, val engine: HttpClientEngine? = null, val eventListener: NetworkEventListener? = null, val requestInterceptor: RequestInterceptor? = null, val requestHeaderProvider: RequestHeaderProvider? = null)

Immutable configuration for a NetworkClient. Mirrors SwiftyNetwork's NetworkClientConfiguration.

Link copied to clipboard

Marker for an ApiClient usable as a repository's remote data source. Mirrors SwiftyNetwork's NetworkDataSource.

Link copied to clipboard
interface NetworkEndpoint

A type-safe description of one HTTP endpoint. Mirrors SwiftyNetwork's NetworkEndpoint.

Link copied to clipboard
sealed class NetworkError : Exception

The error type surfaced by NetworkClient. Mirrors SwiftyNetwork's NetworkError.

Link copied to clipboard
class NetworkEvent(val endpointId: String, val method: String, val durationMs: Long, val statusCode: Int? = null, val errorType: String? = null, val isRetryable: Boolean = false, val attempt: Int = 0, val isFinalAttempt: Boolean = true)

A single observed network request outcome, for telemetry/analytics. The Kotlin counterpart of Novalingo's NetworkTelemetryEvent, kept transport-agnostic so any analytics backend can consume it.

Link copied to clipboard
fun interface NetworkEventListener

Receives NetworkEvents emitted by NetworkClient. Wire this to your analytics pipeline.

Link copied to clipboard
class NetworkMonitor(context: Context)

Observes device connectivity via ConnectivityManager. The Kotlin counterpart of SwiftyNetwork's NetworkMonitor (which wraps NWPathMonitor).

Link copied to clipboard

Coarse network reachability state. Mirrors SwiftyNetwork's NetworkReachability.

Link copied to clipboard
class OAuthAuthorizationProvider(initialAccessToken: String, refreshTokenHandler: suspend () -> String?) : AuthorizationProvider

An AuthorizationProvider that holds an OAuth bearer access token and refreshes it via refreshTokenHandler. Mirrors SwiftyNetwork's OAuthAuthorizationProvider.

Link copied to clipboard
fun interface ReachabilityGate

A connectivity gate the retry path can wait on. Implemented by NetworkMonitor (via NetworkMonitor.asReachabilityGate), but kept abstract so NetworkClient doesn't depend on any concrete connectivity source and can be tested without one.

Link copied to clipboard
fun interface RequestHeaderProvider

Supplies extra request headers computed fresh for each attempt — the hook for trace-context propagation headers (W3C traceparent/tracestate, baggage, or an equivalent from any other tracing system) derived from whatever context is active right now.

Link copied to clipboard

Wraps a single request attempt, giving observability tooling — tracing in particular — a place to start a span/segment with an accurate timestamp, propagate the currently active context, and record the outcome, all without NetworkClient depending on any specific tracing API.

Link copied to clipboard
fun interface RetryPolicy

Decides whether (and after how long) a failed request should be retried.

Link copied to clipboard

Certificate (public-key) pinning configuration. Mirrors SwiftyNetwork's SSLPinningConfiguration, implemented on top of OkHttp's CertificatePinner.

Link copied to clipboard

An optional extension of LogSink for destinations that want structured key-value attributes alongside the formatted message — e.g. to populate OpenTelemetry log record Attributes, or any other structured-logging backend, instead of only a flat string.

Properties

Link copied to clipboard

The default JSON codec: lenient and tolerant of unknown keys.

Functions

Link copied to clipboard
suspend fun ApiClient.execute(endpoint: NetworkEndpoint)

Executes endpoint, discarding any response body.

Link copied to clipboard
inline suspend fun <T> ApiClient.request(endpoint: NetworkEndpoint): T

Executes endpoint and decodes the response into T.

inline suspend fun <B, T> ApiClient.request(endpoint: NetworkEndpoint, body: B): T

Executes endpoint sending body of type B, and decodes the response into T.