baaba_api_handler 1.3.1
baaba_api_handler: ^1.3.1 copied to clipboard
API handling services
1.3.1 #
- Added support for the
detailkey in API error responses (RFC 7807), falling back to it ifmessageis missing but prioritizing it overerror.
1.3.0 #
- Added
ApiServices.download()— streams a file response directly to disk (savePath) instead of loading it into memory, withonReceiveProgress,cancelToken, anddeleteOnErrorsupport. Goes through the same connectivity check and loader plumbing as the other HTTP methods. - Added
refreshTimeoutparameter toApiServices.configure()(default 30 seconds). Bounds how long a request that 401s while another refresh is already in flight will wait for that refresh before giving up and failing with the original error. TokenRefreshInterceptor: requests that 401 while a refresh is already in progress now wait for that refresh to finish and retry with the fresh token, instead of failing immediately. Previously only the first request in a concurrent-401 burst would succeed; the rest errored out just for losing the race.NetworkRetryInterceptornow only auto-retries idempotent methods (GET,HEAD,OPTIONS,PUT,DELETE).POST/PATCHare no longer retried on transient timeouts/connection errors, since the server may have already processed the request and a blind retry could duplicate the side effect.- Added
maxAgeparameter toApiCacheHelper.getCacheData()— if the cached entry is older thanmaxAge, it's treated as a miss (the stale entry is cleared andnullreturned) instead of returning stale data. Omit it to keep the previous behaviour of returning cached data regardless of age. - Bumped
dioto^5.10.0,pretty_dio_loggerto^1.4.0,internet_connection_checker_plusto^3.1.1,fpdartto^1.2.0,equatableto^2.1.0, andsqflite_common_ffi(dev) to^2.4.0+3.
1.2.0 #
- Added
ApiServices.configureLoader({onShow, onHide})— a global, framework-agnostic loading indicator shown automatically around every request (success, failure, and thrown exceptions all covered), so callers no longer need a per-screenisLoadingflag.onShow/onHideare plain callbacks (e.g.Get.dialog/Get.backfor GetX, orshowDialog/Navigator.popwith a global key) — the package has no UI dependency. - Added
showLoaderparameter (defaulttrue) toget/post/put/patch/deleteto opt a specific request out of the loader. - Concurrent requests share one indicator via reference counting:
onShowfires only for the first in-flight request,onHideonly once every in-flight request has finished.
1.1.0 #
- Breaking:
ErrorSourceenum variants renamed fromsnake_casetocamelCase(e.g.no_content→noContent,bad_request→badRequest). Update anyswitchor direct references in your code. - Added
bypassConnectivityCheckparameter toApiServices.configure()for staging/internal environments where connectivity probes fail due to proxies or firewalls. - Added
ApiServices.setConnectivityCheck({bool enabled})— controls the connectivity check independently of token auth configuration. cancelRequest()now cancels all in-flight requests (previously only the most recent). All activeCancelTokens are tracked in aSetand cancelled together.- Extended
ResponseCodeandErrorSourcewith six new HTTP status codes:created(201),requestTimeout(408),conflict(409),unprocessableEntity(422),tooManyRequests(429),badGateway(502). - Fixed
ResponseCode.noContentraw value from 201 to 204. ResponseCoderefactored to use inline integer values (ResponseCode.success(200)style) — no longer requires an extension for.value.ResponseStringsrewritten with cleaner, user-facing error messages.ErrorHandlerno longer implementsException.
1.0.7 #
- Added
TokenRefreshInterceptorfor automatic token refresh on 401 responses. - Added
NetworkRetryInterceptorfor automatic retry on transient network failures. - Added
ApiServices.configure()static method for setting up token-based authentication. - Added
headerBuilderparameter toApiServices.configure()for customising auth headers per request. - Added
onSendProgress,onReceiveProgress, andCancelTokenparameters to all request methods. - Re-exported
ResponseandCancelTokenfrom Dio, andAPICacheDBModelfrom api_cache_manager — no separate imports needed.
1.0.6 #
- Added
SERVICE_NOT_AVAILABLE(503) toResponseCodeand error handling. - Improved error message extraction from API response body (
messageanderrorkeys).
1.0.5 #
- Updated readme documentation and bumped version.
1.0.4 #
- Added license information.
1.0.3 #
- Updated package structure and internal functionality.
1.0.2 #
- Fixed multipart request method naming.
- Fixed incorrect MIME types in multipart requests.
1.0.1 #
- Added multipart request support.
- Updated dependencies.
1.0.0 #
- Initial release.
- HTTP methods: GET, POST, PUT, PATCH, DELETE.
- API response caching via
ApiCacheHelper. - Network connectivity checks before each request.
- Structured error handling with
Failure,ErrorSource, andResponseCode.