RestAPIService<DataType extends Jsonable<Object> > constructor
RestAPIService<DataType extends Jsonable<Object> > ({
- RestAPI? restAPI,
- DataType? dataType,
- String? token,
- String? apiKey,
- required String baseUrl,
- Duration? connectTimeout,
- Duration? receiveTimeout,
- Duration? sendTimeout,
- HttpClientAdapter? httpClientAdapter,
- Map<
String, dynamic> ? headers, - TokenCallback? tokenCallback,
- CancelTokenCallback? cancelTokenCallback,
- List<
Interceptor> ? interceptors,
Implementation
RestAPIService({
RestAPI? restAPI,
this.dataType,
String? token,
String? apiKey,
required String baseUrl,
Duration? connectTimeout,
Duration? receiveTimeout,
Duration? sendTimeout,
dio.HttpClientAdapter? httpClientAdapter,
Map<String, dynamic>? headers,
TokenCallback? tokenCallback,
CancelTokenCallback? cancelTokenCallback,
List<dio.Interceptor>? interceptors,
}) : assert(
(((token?.isNotEmpty ?? false) && tokenCallback == null) ||
((token?.isEmpty ?? true) && tokenCallback != null)) ||
(apiKey?.isNotEmpty ?? false),
'\n\nA token or tokenCallback must be specified, only one of both.'
'\nOtherwise an apiKey must be specified.',
),
restAPI = restAPI ?? RestAPI() {
this.restAPI.init(
apiKey: apiKey,
baseUrl: baseUrl,
connectTimeout: connectTimeout,
receiveTimeout: receiveTimeout,
sendTimeout: sendTimeout,
httpClientAdapter: httpClientAdapter,
headers: headers,
tokenCallback:
tokenCallback ?? (token == null ? null : (() async => token)),
cancelTokenCallback: cancelTokenCallback,
interceptors: interceptors,
);
}