ts_api_handler
library
Classes
ApiConfig
Everything ApiServices needs, in one object.
ApiLogOptions
Controls what the console logger prints for each request.
ApiObserver
A single place to watch every request the package makes — for crash
reporting, analytics, or a debug overlay.
ApiServices
A typed HTTP client wrapping Dio. All methods return Either<Failure, Response> —
use .fold(onLeft, onRight) to handle errors and successes without exceptions.
AuthConfig
Token-based authentication settings for ApiServices.
BaabaApiEndpoint
Generates typed endpoints from a .env file of KEY=path lines.
BaabaApiEnvironment
Generates typed configuration values from a .env file.
BaabaApiField
Names the .env key a field reads, instead of its UPPER_SNAKE name.
Base64LogTrimmer
Collapses base64 blobs out of the logger's output.
CancelToken
Controls cancellation of Dio's requests.
Either <L , R >
Represents a value of one of two possible types, Left or Right .
ErrorInterceptorHandler
The handler for interceptors to handle error occurred during the request.
FormData
A class to create readable "multipart/form-data" streams.
It can be used to submit forms and file uploads to http server.
HttpClientAdapter
HttpAdapter is a bridge between Dio and HttpClient .
Interceptor
Interceptor helps to deal with RequestOptions , Response ,
and DioException during the lifecycle of a request
before it reaches users.
InterceptorsWrapper
A helper class to create interceptors in ease.
Left <L , R >
MultipartFile
An upload content that is a part of MultipartRequest.
This doesn't need to correspond to a physical file.
PinningConfig
Certificate pinning by CA: each host is trusted only if its certificate
chains to one of the roots listed for it.
ProxyConfig
Sends requests for selected hosts through an HTTP proxy, and everything
else direct.
QueuedInterceptor
Interceptor in queue.
RequestInterceptorHandler
The handler for interceptors to handle before the request has been sent.
RequestOptions
The internal request option class that is the eventual result after
BaseOptions and Options are composed.
Response <T >
The Response class contains the payload (could be transformed)
that respond from the request, and other information of the response.
ResponseInterceptorHandler
The handler for interceptors to handle after respond.
RetryPolicy
Controls how transient failures are retried by NetworkRetryInterceptor.
Right <L , R >
UploadFile
One file in a multipart upload.
Extension Types
ApiEndpoint
An endpoint path, optionally with {} placeholders filled in order.
Functions
guardApi <T > (Future <T > body (), {void onUnexpected (Object error , StackTrace stackTrace )?, String client = ApiServices.defaultClient })
→ Future <Either <Failure , T > >
Runs body and returns its result as an Either, so a flow written with
orThrow() hands its caller the same type a single request does.
jwtExpired (String token , {Duration skew = const Duration(seconds: 30) , DateTime ? now })
→ bool
Whether the JWT token has expired, or will within skew.
jwtExpiryCheck (Future <String ? > getToken (), {Duration skew = const Duration(seconds: 30) })
→ Future <bool > Function()
jwtExpired , shaped for AuthConfig.isTokenExpired: reads the token with
getToken — usually the same function given to AuthConfig.getToken —
and checks it.
listParser <T > (T fromJson (Map <String , dynamic > json ), {String ? key })
→ List <T > Function(dynamic data )
Turns a single-object parser into one that reads a JSON array, for the
common list endpoint.