123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518 |
- // GENERATED CODE - DO NOT MODIFY BY HAND
- part of 'api_service.dart';
- // **************************************************************************
- // RetrofitGenerator
- // **************************************************************************
- // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
- class _ApiService implements ApiService {
- _ApiService(
- this._dio, {
- this.baseUrl,
- this.errorLogger,
- });
- final Dio _dio;
- String? baseUrl;
- final ParseErrorLogger? errorLogger;
- @override
- Future<ApiResponse<LoginInfo>> login(String phoneNumber) async {
- final _extra = <String, dynamic>{};
- final queryParameters = <String, dynamic>{};
- final _headers = <String, dynamic>{r'Content-Type': 'application/json'};
- _headers.removeWhere((k, v) => v == null);
- final _data = {'phoneNumber': phoneNumber};
- final _options = _setStreamType<ApiResponse<LoginInfo>>(Options(
- method: 'POST',
- headers: _headers,
- extra: _extra,
- contentType: 'application/json',
- )
- .compose(
- _dio.options,
- '/app/login',
- queryParameters: queryParameters,
- data: _data,
- )
- .copyWith(
- baseUrl: _combineBaseUrls(
- _dio.options.baseUrl,
- baseUrl,
- )));
- final _result = await _dio.fetch<Map<String, dynamic>>(_options);
- late ApiResponse<LoginInfo> _value;
- try {
- _value = ApiResponse<LoginInfo>.fromJson(
- _result.data!,
- (json) => LoginInfo.fromJson(json as Map<String, dynamic>),
- );
- } on Object catch (e, s) {
- errorLogger?.logError(e, s, _options);
- rethrow;
- }
- return _value;
- }
- @override
- Future<ApiResponse<dynamic>> logout(String token) async {
- final _extra = <String, dynamic>{};
- final queryParameters = <String, dynamic>{};
- final _headers = <String, dynamic>{r'token': token};
- _headers.removeWhere((k, v) => v == null);
- const Map<String, dynamic>? _data = null;
- final _options = _setStreamType<ApiResponse<dynamic>>(Options(
- method: 'GET',
- headers: _headers,
- extra: _extra,
- )
- .compose(
- _dio.options,
- '/app/logout',
- queryParameters: queryParameters,
- data: _data,
- )
- .copyWith(
- baseUrl: _combineBaseUrls(
- _dio.options.baseUrl,
- baseUrl,
- )));
- final _result = await _dio.fetch<Map<String, dynamic>>(_options);
- late ApiResponse<dynamic> _value;
- try {
- _value = ApiResponse<dynamic>.fromJson(
- _result.data!,
- (json) => json as dynamic,
- );
- } on Object catch (e, s) {
- errorLogger?.logError(e, s, _options);
- rethrow;
- }
- return _value;
- }
- @override
- Future<ApiResponse<dynamic>> sendCaptchaCode(String phoneNumber) async {
- final _extra = <String, dynamic>{};
- final queryParameters = <String, dynamic>{};
- final _headers = <String, dynamic>{r'Content-Type': 'application/json'};
- _headers.removeWhere((k, v) => v == null);
- final _data = {'phoneNumber': phoneNumber};
- final _options = _setStreamType<ApiResponse<dynamic>>(Options(
- method: 'POST',
- headers: _headers,
- extra: _extra,
- contentType: 'application/json',
- )
- .compose(
- _dio.options,
- '/app/sendCaptchaCode',
- queryParameters: queryParameters,
- data: _data,
- )
- .copyWith(
- baseUrl: _combineBaseUrls(
- _dio.options.baseUrl,
- baseUrl,
- )));
- final _result = await _dio.fetch<Map<String, dynamic>>(_options);
- late ApiResponse<dynamic> _value;
- try {
- _value = ApiResponse<dynamic>.fromJson(
- _result.data!,
- (json) => json as dynamic,
- );
- } on Object catch (e, s) {
- errorLogger?.logError(e, s, _options);
- rethrow;
- }
- return _value;
- }
- @override
- Future<ApiResponse<dynamic>> checkCaptchaCode(
- String captchaCode,
- String phoneNumber,
- ) async {
- final _extra = <String, dynamic>{};
- final queryParameters = <String, dynamic>{};
- final _headers = <String, dynamic>{r'Content-Type': 'application/json'};
- _headers.removeWhere((k, v) => v == null);
- final _data = {
- 'captchaCode': captchaCode,
- 'phoneNumber': phoneNumber,
- };
- final _options = _setStreamType<ApiResponse<dynamic>>(Options(
- method: 'POST',
- headers: _headers,
- extra: _extra,
- contentType: 'application/json',
- )
- .compose(
- _dio.options,
- '/app/checkCaptchaCode',
- queryParameters: queryParameters,
- data: _data,
- )
- .copyWith(
- baseUrl: _combineBaseUrls(
- _dio.options.baseUrl,
- baseUrl,
- )));
- final _result = await _dio.fetch<Map<String, dynamic>>(_options);
- late ApiResponse<dynamic> _value;
- try {
- _value = ApiResponse<dynamic>.fromJson(
- _result.data!,
- (json) => json as dynamic,
- );
- } on Object catch (e, s) {
- errorLogger?.logError(e, s, _options);
- rethrow;
- }
- return _value;
- }
- @override
- Future<ApiResponse<List<DictInfo>>> dictList(String dictType) async {
- final _extra = <String, dynamic>{};
- final queryParameters = <String, dynamic>{};
- final _headers = <String, dynamic>{};
- const Map<String, dynamic>? _data = null;
- final _options = _setStreamType<ApiResponse<List<DictInfo>>>(Options(
- method: 'GET',
- headers: _headers,
- extra: _extra,
- )
- .compose(
- _dio.options,
- '/app/api/type/${dictType}',
- queryParameters: queryParameters,
- data: _data,
- )
- .copyWith(
- baseUrl: _combineBaseUrls(
- _dio.options.baseUrl,
- baseUrl,
- )));
- final _result = await _dio.fetch<Map<String, dynamic>>(_options);
- late ApiResponse<List<DictInfo>> _value;
- try {
- _value = ApiResponse<List<DictInfo>>.fromJson(
- _result.data!,
- (json) => json is List<dynamic>
- ? json
- .map<DictInfo>(
- (i) => DictInfo.fromJson(i as Map<String, dynamic>))
- .toList()
- : List.empty(),
- );
- } on Object catch (e, s) {
- errorLogger?.logError(e, s, _options);
- rethrow;
- }
- return _value;
- }
- @override
- Future<ApiResponse<VersionInfo>> getVersion(String type) async {
- final _extra = <String, dynamic>{};
- final queryParameters = <String, dynamic>{r'type': type};
- final _headers = <String, dynamic>{};
- const Map<String, dynamic>? _data = null;
- final _options = _setStreamType<ApiResponse<VersionInfo>>(Options(
- method: 'GET',
- headers: _headers,
- extra: _extra,
- )
- .compose(
- _dio.options,
- '/app/api/findVersion',
- queryParameters: queryParameters,
- data: _data,
- )
- .copyWith(
- baseUrl: _combineBaseUrls(
- _dio.options.baseUrl,
- baseUrl,
- )));
- final _result = await _dio.fetch<Map<String, dynamic>>(_options);
- late ApiResponse<VersionInfo> _value;
- try {
- _value = ApiResponse<VersionInfo>.fromJson(
- _result.data!,
- (json) => VersionInfo.fromJson(json as Map<String, dynamic>),
- );
- } on Object catch (e, s) {
- errorLogger?.logError(e, s, _options);
- rethrow;
- }
- return _value;
- }
- @override
- Future<ApiResponse<List<PatientInfo>>> getPatientList() async {
- final _extra = <String, dynamic>{};
- final queryParameters = <String, dynamic>{};
- final _headers = <String, dynamic>{};
- const Map<String, dynamic>? _data = null;
- final _options = _setStreamType<ApiResponse<List<PatientInfo>>>(Options(
- method: 'GET',
- headers: _headers,
- extra: _extra,
- )
- .compose(
- _dio.options,
- '/app/user/list',
- queryParameters: queryParameters,
- data: _data,
- )
- .copyWith(
- baseUrl: _combineBaseUrls(
- _dio.options.baseUrl,
- baseUrl,
- )));
- final _result = await _dio.fetch<Map<String, dynamic>>(_options);
- late ApiResponse<List<PatientInfo>> _value;
- try {
- _value = ApiResponse<List<PatientInfo>>.fromJson(
- _result.data!,
- (json) => json is List<dynamic>
- ? json
- .map<PatientInfo>(
- (i) => PatientInfo.fromJson(i as Map<String, dynamic>))
- .toList()
- : List.empty(),
- );
- } on Object catch (e, s) {
- errorLogger?.logError(e, s, _options);
- rethrow;
- }
- return _value;
- }
- @override
- Future<ApiResponse<List<ClinicInfo>>> getClinicList() async {
- final _extra = <String, dynamic>{};
- final queryParameters = <String, dynamic>{};
- final _headers = <String, dynamic>{};
- const Map<String, dynamic>? _data = null;
- final _options = _setStreamType<ApiResponse<List<ClinicInfo>>>(Options(
- method: 'GET',
- headers: _headers,
- extra: _extra,
- )
- .compose(
- _dio.options,
- '/app/api/clinicList',
- queryParameters: queryParameters,
- data: _data,
- )
- .copyWith(
- baseUrl: _combineBaseUrls(
- _dio.options.baseUrl,
- baseUrl,
- )));
- final _result = await _dio.fetch<Map<String, dynamic>>(_options);
- late ApiResponse<List<ClinicInfo>> _value;
- try {
- _value = ApiResponse<List<ClinicInfo>>.fromJson(
- _result.data!,
- (json) => json is List<dynamic>
- ? json
- .map<ClinicInfo>(
- (i) => ClinicInfo.fromJson(i as Map<String, dynamic>))
- .toList()
- : List.empty(),
- );
- } on Object catch (e, s) {
- errorLogger?.logError(e, s, _options);
- rethrow;
- }
- return _value;
- }
- @override
- Future<ApiResponse<dynamic>> addPatient(
- String name,
- String idCard,
- String relation,
- ) async {
- final _extra = <String, dynamic>{};
- final queryParameters = <String, dynamic>{};
- final _headers = <String, dynamic>{r'Content-Type': 'application/json'};
- _headers.removeWhere((k, v) => v == null);
- final _data = {
- 'patientName': name,
- 'identificationCard': idCard,
- 'relationship': relation,
- };
- final _options = _setStreamType<ApiResponse<dynamic>>(Options(
- method: 'POST',
- headers: _headers,
- extra: _extra,
- contentType: 'application/json',
- )
- .compose(
- _dio.options,
- '/app/user',
- queryParameters: queryParameters,
- data: _data,
- )
- .copyWith(
- baseUrl: _combineBaseUrls(
- _dio.options.baseUrl,
- baseUrl,
- )));
- final _result = await _dio.fetch<Map<String, dynamic>>(_options);
- late ApiResponse<dynamic> _value;
- try {
- _value = ApiResponse<dynamic>.fromJson(
- _result.data!,
- (json) => json as dynamic,
- );
- } on Object catch (e, s) {
- errorLogger?.logError(e, s, _options);
- rethrow;
- }
- return _value;
- }
- @override
- Future<HttpResponse<String>> getPrivacyPolicy() async {
- final _extra = <String, dynamic>{};
- final queryParameters = <String, dynamic>{};
- final _headers = <String, dynamic>{};
- const Map<String, dynamic>? _data = null;
- final _options = _setStreamType<HttpResponse<String>>(Options(
- method: 'GET',
- headers: _headers,
- extra: _extra,
- )
- .compose(
- _dio.options,
- '/app/api/privacyPolicy',
- queryParameters: queryParameters,
- data: _data,
- )
- .copyWith(
- baseUrl: _combineBaseUrls(
- _dio.options.baseUrl,
- baseUrl,
- )));
- final _result = await _dio.fetch<String>(_options);
- late String _value;
- try {
- _value = _result.data!;
- } on Object catch (e, s) {
- errorLogger?.logError(e, s, _options);
- rethrow;
- }
- final httpResponse = HttpResponse(_value, _result);
- return httpResponse;
- }
- @override
- Future<HttpResponse<String>> getUserAgreement() async {
- final _extra = <String, dynamic>{};
- final queryParameters = <String, dynamic>{};
- final _headers = <String, dynamic>{};
- const Map<String, dynamic>? _data = null;
- final _options = _setStreamType<HttpResponse<String>>(Options(
- method: 'GET',
- headers: _headers,
- extra: _extra,
- )
- .compose(
- _dio.options,
- '/app/api/userAgreement',
- queryParameters: queryParameters,
- data: _data,
- )
- .copyWith(
- baseUrl: _combineBaseUrls(
- _dio.options.baseUrl,
- baseUrl,
- )));
- final _result = await _dio.fetch<String>(_options);
- late String _value;
- try {
- _value = _result.data!;
- } on Object catch (e, s) {
- errorLogger?.logError(e, s, _options);
- rethrow;
- }
- final httpResponse = HttpResponse(_value, _result);
- return httpResponse;
- }
- @override
- Future<HttpResponse<String>> getPermissionDescription(String type) async {
- final _extra = <String, dynamic>{};
- final queryParameters = <String, dynamic>{r'type': type};
- final _headers = <String, dynamic>{};
- const Map<String, dynamic>? _data = null;
- final _options = _setStreamType<HttpResponse<String>>(Options(
- method: 'GET',
- headers: _headers,
- extra: _extra,
- )
- .compose(
- _dio.options,
- '/app/api/permissionDescription',
- queryParameters: queryParameters,
- data: _data,
- )
- .copyWith(
- baseUrl: _combineBaseUrls(
- _dio.options.baseUrl,
- baseUrl,
- )));
- final _result = await _dio.fetch<String>(_options);
- late String _value;
- try {
- _value = _result.data!;
- } on Object catch (e, s) {
- errorLogger?.logError(e, s, _options);
- rethrow;
- }
- 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();
- }
- }
|