ApiService class
HTTP API client that handles authentication, cookies, and file transfers.
Uses ApiUrls to resolve named routes and StorageService to persist auth tokens and cookies across sessions.
Constructors
- ApiService({required ApiUrls urls, required String clientId, required String clientSecret})
- Creates an ApiService.
Properties
- clientId → String
-
OAuth2 client identifier.
final
- clientSecret → String
-
OAuth2 client secret.
final
-
Current session cookies keyed by name.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- urls → ApiUrls
-
Named URL resolver for this service instance.
final
Methods
-
authenticate(
String email, String code) → Future -
Authenticates a user using an email and one-time
code. -
downloadFile(
{required String urlName, Map< String, dynamic> ? data}) → Future<Uint8List> -
Downloads a file from
urlNameand returns its raw bytes. -
ensureHeaders(
Map< String, String> ? headers) → Future - Ensures the request headers contain the current auth token and cookies.
-
fileUploadMultipart(
{required String urlName, required Map< String, String> data, required String fieldName, required File file, Map<String, String> ? headers, OnUploadProgressCallback? onUploadProgress}) → Future<Map< String, dynamic> > -
Uploads a
fileas a multipart POST request. -
get(
String urlName, Map< String, dynamic> data) → Future<Response> - Performs an authenticated HTTP GET request.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
post(
String urlName, Map< String, dynamic> data, {Map<String, String> ? headers, Encoding? encoding}) → Future - Performs an authenticated HTTP POST request with JSON body.
-
setAuth(
) → Future - Loads the stored auth token and cookies into the request headers.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- trustSelfSigned ↔ bool
-
When
true, self-signed TLS certificates are accepted. Should only be enabled during development.getter/setter pair
Static Methods
-
getHttpClient(
) → HttpClient - Returns an HttpClient configured with a 10-second timeout and optional self-signed certificate trust.