API class

Requests sender and throttling container

Accepts instances of APIRequest on API.call method to control their throttling based on settings.

Is being configured for exact domain and credentials, these fields are final. To change them you need to create a new instance. Also see APIRequest.clone documentation that mentions requests instances reuse.

Implementers

Constructors

API(Uri domain, {Duration globalTimeout = Duration.zero, String? token, Map<String, Duration> requestTimeouts = const {}, Uri? noAuthDomain})
Build new API requests sender

Properties

domain Uri
Root path
final
globalTimeout Duration
Minimal timeout between all requests
final
hashCode int
The hash code for this object.
no setterinherited
isCartBusy bool
Returns true if there are requests being throttled
no setter
noAuthDomain Uri
No authentication Root path
final
requestTimeouts Map<String, Duration>
Minimal timeout between requests of the same class
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
token String?
Request credential
final

Methods

authAttacher(APIRequest request) → void
Attaches credentials to given request
call(APIRequest request) Future<APIResponse>
Evaluate the request
getMethodRequestTimeout(String methodId) Duration
Returns configured delay between requests of the same class
isMethodBusy(String methodId) bool
Returns is method [of class] is currently in-work
isRequestImmediate(String? methodId) bool
Returns true if request [of class] can be sent immediately
lastRequest({String? methodId}) DateTime
Returns last time request was sent
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
preprocessRequest(APIRequest request) → void
Preprocesses given request
toString() String
A string representation of this object.
inherited
willFreeIn({String? methodId}) Duration
Returns minimum required time until request [of class] can be sent

Operators

operator ==(Object other) bool
The equality operator.
inherited