JsonRestApiClient class
Base class to create a json REST API client.
Constructors
- JsonRestApiClient(Uri? baseUrl, {String? bearerToken, Client? httpClient})
-
Set the baseUrl and an optional bearerToken. Overwrite
httpClient
with a mock client for testing.
Properties
- baseUrl ↔ Uri?
-
The base URL which will be the prefix for all requests.
getter/setter pair
- bearerToken ↔ String?
-
If set, all requests will send this token in the Authorization header
with
Bearer $bearerToken
.getter/setter pair - hashCode → int
-
The hash code for this object.
no setterinherited
- httpClient → Client
-
Handles the open connection to the server. Use this for additional tasks
like uploading.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
request(
RequestMethod method, String endpoint, {dynamic json, Map< String, dynamic> ? queryParameters, Duration? timeout, Map<String, String> headers = const {}}) → Future<JsonRestApiResponse> -
Perform a request to the API which could either return json data or null.
Set
method
to a valid http method likeGET
orPOST
and endpoint to one of the available endpoints of your api like/endpoint
. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited