dart-dio.apilib.mustache Maven / Gradle / Ivy
library {{pubName}}.api;
import 'package:dio/dio.dart';
import 'package:built_value/serializer.dart';
import 'package:{{pubName}}/serializers.dart';
{{#apiInfo}}{{#apis}}import 'package:{{pubName}}/api/{{classFilename}}.dart';
{{/apis}}{{/apiInfo}}
class {{clientName}} {
Dio dio;
Serializers serializers;
String basePath = "{{{basePath}}}";
{{clientName}}({this.dio, Serializers serializers}) {
if (dio == null) {
BaseOptions options = new BaseOptions(
baseUrl: basePath,
connectTimeout: 5000,
receiveTimeout: 3000,
);
this.dio = new Dio(options);
}
this.serializers = serializers ?? standardSerializers;
}
{{#apiInfo}}{{#apis}}
/**
* Get {{classname}} instance, base route and serializer can be overridden by a given but be careful,
* by doing that all interceptors will not be executed
*/
{{classname}} get{{classname}}() {
return {{classname}}(dio, serializers);
}
{{/apis}}{{/apiInfo}}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy