ZonaiClient class
Main entry point for the Zonai HTTP client.
Wraps the generated Server and exposes higher-level service objects for authentication (auth), the database (db), photos (photos), and email (email) APIs.
Singleton usage (memory storage, base URL from BASE_URL env var or
http://localhost:8080):
final client = ZonaiClient.instance;
Explicit configuration (file-backed storage, custom base URL):
final client = ZonaiClient(
baseUrl: 'https://api.example.com',
storageDirectory: '/var/lib/myapp',
);
Access tokens are managed automatically via ZonaiStorage and the
Interceptor X-Auth round-trip. After the first successful authentication
call the token is stored and injected into subsequent requests as
Authorization: Bearer <token>.
Constructors
-
ZonaiClient({Uri? baseUrl, String? storageDirectory, Storage? storage, List<
HttpInterceptor> extraInterceptors = const []}) -
Creates a ZonaiClient with optional
baseUrlandstorageDirectory.factory - ZonaiClient.server({required Server server})
- Creates a ZonaiClient backed by an already-constructed Server.
Properties
- auth → Auth
-
Authentication service with automatic token management.
final
- db → Db
-
Database service for CRUD operations and real-time streaming.
final
- email → Emails
-
Email service for sending transactional emails.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- photos → Photos
-
Photo service for uploading, downloading, and deleting photos.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- server → Server
-
The underlying generated Server (e.g. for endpoints without a wrapper).
no setter
Methods
-
health(
) → Future< bool> -
Returns
trueif the server is reachable and healthy. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance ↔ ZonaiClient
-
Get the singleton instance of ZonaiClient.
getter/setter pair