mirror of
https://github.com/bettercoding-dev/flutter-jwt-auth.git
synced 2025-08-06 17:28:17 +08:00
108 lines
3.0 KiB
Dart
108 lines
3.0 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
part of 'time_client.dart';
|
|
|
|
// **************************************************************************
|
|
// RetrofitGenerator
|
|
// **************************************************************************
|
|
|
|
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
|
|
|
|
class _TimeClient implements TimeClient {
|
|
_TimeClient(
|
|
this._dio, {
|
|
this.baseUrl,
|
|
this.errorLogger,
|
|
});
|
|
|
|
final Dio _dio;
|
|
|
|
String? baseUrl;
|
|
|
|
final ParseErrorLogger? errorLogger;
|
|
|
|
@override
|
|
Future<TimeResponse> getServerTime() async {
|
|
final _extra = <String, dynamic>{};
|
|
final queryParameters = <String, dynamic>{};
|
|
final _headers = <String, dynamic>{};
|
|
const Map<String, dynamic>? _data = null;
|
|
final _options = _setStreamType<TimeResponse>(Options(
|
|
method: 'GET',
|
|
headers: _headers,
|
|
extra: _extra,
|
|
)
|
|
.compose(
|
|
_dio.options,
|
|
'/time',
|
|
queryParameters: queryParameters,
|
|
data: _data,
|
|
)
|
|
.copyWith(
|
|
baseUrl: _combineBaseUrls(
|
|
_dio.options.baseUrl,
|
|
baseUrl,
|
|
)));
|
|
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
|
|
late TimeResponse _value;
|
|
try {
|
|
_value = TimeResponse.fromJson(_result.data!);
|
|
} on Object catch (e, s) {
|
|
errorLogger?.logError(e, s, _options);
|
|
rethrow;
|
|
}
|
|
return _value;
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
// **************************************************************************
|
|
// RiverpodGenerator
|
|
// **************************************************************************
|
|
|
|
String _$timeClientHash() => r'6b646e6d22b33365b77143253c69787fea6889b3';
|
|
|
|
/// See also [timeClient].
|
|
@ProviderFor(timeClient)
|
|
final timeClientProvider = AutoDisposeProvider<TimeClient>.internal(
|
|
timeClient,
|
|
name: r'timeClientProvider',
|
|
debugGetCreateSourceHash:
|
|
const bool.fromEnvironment('dart.vm.product') ? null : _$timeClientHash,
|
|
dependencies: null,
|
|
allTransitiveDependencies: null,
|
|
);
|
|
|
|
typedef TimeClientRef = AutoDisposeProviderRef<TimeClient>;
|
|
// ignore_for_file: type=lint
|
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|