You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
3.0 KiB
97 lines
3.0 KiB
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
part of 'user_api.dart';
|
|
|
|
// dart format off
|
|
|
|
// **************************************************************************
|
|
// RetrofitGenerator
|
|
// **************************************************************************
|
|
|
|
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations,unused_element_parameter,avoid_unused_constructor_parameters,unreachable_from_main
|
|
|
|
class _UserApi implements UserApi {
|
|
_UserApi(this._dio, {this.baseUrl, this.errorLogger}) {
|
|
baseUrl ??= 'https://api.example.com/';
|
|
}
|
|
|
|
final Dio _dio;
|
|
|
|
String? baseUrl;
|
|
|
|
final ParseErrorLogger? errorLogger;
|
|
|
|
@override
|
|
Future<HttpResponse<dynamic>> login(Map<String, dynamic> data) async {
|
|
final _extra = <String, dynamic>{};
|
|
final queryParameters = <String, dynamic>{};
|
|
final _headers = <String, dynamic>{};
|
|
final _data = <String, dynamic>{};
|
|
_data.addAll(data);
|
|
final _options = _setStreamType<HttpResponse<dynamic>>(
|
|
Options(method: 'POST', headers: _headers, extra: _extra)
|
|
.compose(
|
|
_dio.options,
|
|
'auth/login',
|
|
queryParameters: queryParameters,
|
|
data: _data,
|
|
)
|
|
.copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
|
|
);
|
|
final _result = await _dio.fetch(_options);
|
|
final _value = _result.data;
|
|
final httpResponse = HttpResponse(_value, _result);
|
|
return httpResponse;
|
|
}
|
|
|
|
@override
|
|
Future<HttpResponse<dynamic>> getUserInfo() async {
|
|
final _extra = <String, dynamic>{};
|
|
final queryParameters = <String, dynamic>{};
|
|
final _headers = <String, dynamic>{};
|
|
const Map<String, dynamic>? _data = null;
|
|
final _options = _setStreamType<HttpResponse<dynamic>>(
|
|
Options(method: 'GET', headers: _headers, extra: _extra)
|
|
.compose(
|
|
_dio.options,
|
|
'user/info',
|
|
queryParameters: queryParameters,
|
|
data: _data,
|
|
)
|
|
.copyWith(baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl)),
|
|
);
|
|
final _result = await _dio.fetch(_options);
|
|
final _value = _result.data;
|
|
final httpResponse = HttpResponse(_value, _result);
|
|
return httpResponse;
|
|
}
|
|
|
|
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
|
|
if (T != dynamic &&
|
|
!(requestOptions.responseType == ResponseType.bytes ||
|
|
requestOptions.responseType == ResponseType.stream)) {
|
|
if (T == String) {
|
|
requestOptions.responseType = ResponseType.plain;
|
|
} else {
|
|
requestOptions.responseType = ResponseType.json;
|
|
}
|
|
}
|
|
return requestOptions;
|
|
}
|
|
|
|
String _combineBaseUrls(String dioBaseUrl, String? baseUrl) {
|
|
if (baseUrl == null || baseUrl.trim().isEmpty) {
|
|
return dioBaseUrl;
|
|
}
|
|
|
|
final url = Uri.parse(baseUrl);
|
|
|
|
if (url.isAbsolute) {
|
|
return url.toString();
|
|
}
|
|
|
|
return Uri.parse(dioBaseUrl).resolveUri(url).toString();
|
|
}
|
|
}
|
|
|
|
// dart format on
|