ApiRequest<T extends Object> class abstract

Abstract base class for the API request

Created to cut down on code duplication between the different API endpoints, especially in the request and requestWithValues methods. It is not designed to be called used directly by the user of the library and should be wrapped by for example AareGuruApi.

T is the type of the object that is returned by the request.

Implementers

Constructors

ApiRequest(String host, String apiPath, {String? appName, String? appVersion})

Properties

apiPath String
Path to the API on the host
final
appName String?
Name of the app which uses the API
final
appVersion String?
Version of the app which uses the API
final
endpoint String
The endpoint of the request, should be set by the subclass
no setter
hashCode int
The hash code for this object.
no setterinherited
host String
Host domain of the API
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

baseRequest({Map<String, dynamic>? parameters, List<String> values = const []}) Future<String>
blueprint for a request, should called in the implementation of the formRequest method
formRequest([List<String>? values]) Future<String>
is called by the request and requestWithValuesmethod to form the request. Should be overridden by subclasses to add parameters
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parseResponse(dynamic json) → T
Subclasses should implement this method to parse the response from the API. Is used in the request method.
request() Future<T>
Request without values Specified, therefore the whole response is returned in parsed form.
requestWithValues(List<String> values) Future<List<String>>
A request with values specified, only the values of the given keys in values are in the response
sendRequest(Uri url) Future<String>
sends the request to the specified url
toString() String
A string representation of this object.
inherited
urlRequest(Uri url) Future<T>
Same parsed return as request but from the given url. Can be used if the exact url for the request is provided externally. Should not be used if values are specified.

Operators

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