json_rest_client library

A small, dependency-light JSON HTTP client with typed exceptions, pluggable auth token storage, user-agent injection, and refresh-on-401 retry with a single-flight refresh lock.

Classes

JsonRestClient
A small JSON-over-HTTP client with typed exceptions, pluggable token storage, user-agent injection, and single-flight refresh-on-401 retries.
RestResponse
A raw HTTP response returned by JsonRestClient.sendRaw.
TokenStore
Provides read access to authentication tokens persisted by the host app.

Typedefs

TokenRefresher = Future<String?> Function()
Obtains a fresh authentication token, or null when refreshing failed.
UserAgentProvider = Future<String> Function()
Resolves the user-agent value used for outgoing requests.

Exceptions / Errors

BadRequestException
Thrown when the server responds with HTTP 400 Bad Request.
ConflictDataException
Thrown when the server responds with HTTP 409 Conflict.
DeserializationException
Thrown when a successful response body cannot be decoded as JSON.
InvalidInputException
Thrown when the server responds with HTTP 422 Unprocessable Entity.
NetworkException
Thrown when a request fails because of a network-level error.
NotFoundException
Thrown when the server responds with HTTP 404 Not Found.
RequestTimeoutException
Thrown when a request does not complete within the configured timeout.
ResponseLimitException
Thrown when a response body exceeds the requested size limit.
RestClientException
Base class for all exceptions thrown by the JSON REST client.
ServerErrorException
Thrown when the server responds with HTTP 500 or any other unexpected non-success status code.
UnauthorizedException
Thrown when the server responds with HTTP 401 or 403 and no valid authentication token can be obtained.