api_service.g.dart 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. // GENERATED CODE - DO NOT MODIFY BY HAND
  2. part of 'api_service.dart';
  3. // **************************************************************************
  4. // RetrofitGenerator
  5. // **************************************************************************
  6. // ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element
  7. class _ApiService implements ApiService {
  8. _ApiService(
  9. this._dio, {
  10. this.baseUrl,
  11. this.errorLogger,
  12. });
  13. final Dio _dio;
  14. String? baseUrl;
  15. final ParseErrorLogger? errorLogger;
  16. @override
  17. Future<ApiResponse<LoginInfo>> login(String phoneNumber) async {
  18. final _extra = <String, dynamic>{};
  19. final queryParameters = <String, dynamic>{};
  20. final _headers = <String, dynamic>{r'Content-Type': 'application/json'};
  21. _headers.removeWhere((k, v) => v == null);
  22. final _data = {'phoneNumber': phoneNumber};
  23. final _options = _setStreamType<ApiResponse<LoginInfo>>(Options(
  24. method: 'POST',
  25. headers: _headers,
  26. extra: _extra,
  27. contentType: 'application/json',
  28. )
  29. .compose(
  30. _dio.options,
  31. '/app/login',
  32. queryParameters: queryParameters,
  33. data: _data,
  34. )
  35. .copyWith(
  36. baseUrl: _combineBaseUrls(
  37. _dio.options.baseUrl,
  38. baseUrl,
  39. )));
  40. final _result = await _dio.fetch<Map<String, dynamic>>(_options);
  41. late ApiResponse<LoginInfo> _value;
  42. try {
  43. _value = ApiResponse<LoginInfo>.fromJson(
  44. _result.data!,
  45. (json) => LoginInfo.fromJson(json as Map<String, dynamic>),
  46. );
  47. } on Object catch (e, s) {
  48. errorLogger?.logError(e, s, _options);
  49. rethrow;
  50. }
  51. return _value;
  52. }
  53. @override
  54. Future<ApiResponse<dynamic>> logout(String token) async {
  55. final _extra = <String, dynamic>{};
  56. final queryParameters = <String, dynamic>{};
  57. final _headers = <String, dynamic>{r'token': token};
  58. _headers.removeWhere((k, v) => v == null);
  59. const Map<String, dynamic>? _data = null;
  60. final _options = _setStreamType<ApiResponse<dynamic>>(Options(
  61. method: 'GET',
  62. headers: _headers,
  63. extra: _extra,
  64. )
  65. .compose(
  66. _dio.options,
  67. '/app/logout',
  68. queryParameters: queryParameters,
  69. data: _data,
  70. )
  71. .copyWith(
  72. baseUrl: _combineBaseUrls(
  73. _dio.options.baseUrl,
  74. baseUrl,
  75. )));
  76. final _result = await _dio.fetch<Map<String, dynamic>>(_options);
  77. late ApiResponse<dynamic> _value;
  78. try {
  79. _value = ApiResponse<dynamic>.fromJson(
  80. _result.data!,
  81. (json) => json as dynamic,
  82. );
  83. } on Object catch (e, s) {
  84. errorLogger?.logError(e, s, _options);
  85. rethrow;
  86. }
  87. return _value;
  88. }
  89. @override
  90. Future<ApiResponse<dynamic>> sendCaptchaCode(String phoneNumber) async {
  91. final _extra = <String, dynamic>{};
  92. final queryParameters = <String, dynamic>{};
  93. final _headers = <String, dynamic>{r'Content-Type': 'application/json'};
  94. _headers.removeWhere((k, v) => v == null);
  95. final _data = {'phoneNumber': phoneNumber};
  96. final _options = _setStreamType<ApiResponse<dynamic>>(Options(
  97. method: 'POST',
  98. headers: _headers,
  99. extra: _extra,
  100. contentType: 'application/json',
  101. )
  102. .compose(
  103. _dio.options,
  104. '/app/sendCaptchaCode',
  105. queryParameters: queryParameters,
  106. data: _data,
  107. )
  108. .copyWith(
  109. baseUrl: _combineBaseUrls(
  110. _dio.options.baseUrl,
  111. baseUrl,
  112. )));
  113. final _result = await _dio.fetch<Map<String, dynamic>>(_options);
  114. late ApiResponse<dynamic> _value;
  115. try {
  116. _value = ApiResponse<dynamic>.fromJson(
  117. _result.data!,
  118. (json) => json as dynamic,
  119. );
  120. } on Object catch (e, s) {
  121. errorLogger?.logError(e, s, _options);
  122. rethrow;
  123. }
  124. return _value;
  125. }
  126. @override
  127. Future<ApiResponse<dynamic>> checkCaptchaCode(
  128. String captchaCode,
  129. String phoneNumber,
  130. ) async {
  131. final _extra = <String, dynamic>{};
  132. final queryParameters = <String, dynamic>{};
  133. final _headers = <String, dynamic>{r'Content-Type': 'application/json'};
  134. _headers.removeWhere((k, v) => v == null);
  135. final _data = {
  136. 'captchaCode': captchaCode,
  137. 'phoneNumber': phoneNumber,
  138. };
  139. final _options = _setStreamType<ApiResponse<dynamic>>(Options(
  140. method: 'POST',
  141. headers: _headers,
  142. extra: _extra,
  143. contentType: 'application/json',
  144. )
  145. .compose(
  146. _dio.options,
  147. '/app/checkCaptchaCode',
  148. queryParameters: queryParameters,
  149. data: _data,
  150. )
  151. .copyWith(
  152. baseUrl: _combineBaseUrls(
  153. _dio.options.baseUrl,
  154. baseUrl,
  155. )));
  156. final _result = await _dio.fetch<Map<String, dynamic>>(_options);
  157. late ApiResponse<dynamic> _value;
  158. try {
  159. _value = ApiResponse<dynamic>.fromJson(
  160. _result.data!,
  161. (json) => json as dynamic,
  162. );
  163. } on Object catch (e, s) {
  164. errorLogger?.logError(e, s, _options);
  165. rethrow;
  166. }
  167. return _value;
  168. }
  169. @override
  170. Future<ApiResponse<List<DictInfo>>> dictList(String dictType) async {
  171. final _extra = <String, dynamic>{};
  172. final queryParameters = <String, dynamic>{};
  173. final _headers = <String, dynamic>{};
  174. const Map<String, dynamic>? _data = null;
  175. final _options = _setStreamType<ApiResponse<List<DictInfo>>>(Options(
  176. method: 'GET',
  177. headers: _headers,
  178. extra: _extra,
  179. )
  180. .compose(
  181. _dio.options,
  182. '/app/api/type/${dictType}',
  183. queryParameters: queryParameters,
  184. data: _data,
  185. )
  186. .copyWith(
  187. baseUrl: _combineBaseUrls(
  188. _dio.options.baseUrl,
  189. baseUrl,
  190. )));
  191. final _result = await _dio.fetch<Map<String, dynamic>>(_options);
  192. late ApiResponse<List<DictInfo>> _value;
  193. try {
  194. _value = ApiResponse<List<DictInfo>>.fromJson(
  195. _result.data!,
  196. (json) => json is List<dynamic>
  197. ? json
  198. .map<DictInfo>(
  199. (i) => DictInfo.fromJson(i as Map<String, dynamic>))
  200. .toList()
  201. : List.empty(),
  202. );
  203. } on Object catch (e, s) {
  204. errorLogger?.logError(e, s, _options);
  205. rethrow;
  206. }
  207. return _value;
  208. }
  209. @override
  210. Future<ApiResponse<VersionInfo>> getVersion(String type) async {
  211. final _extra = <String, dynamic>{};
  212. final queryParameters = <String, dynamic>{r'type': type};
  213. final _headers = <String, dynamic>{};
  214. const Map<String, dynamic>? _data = null;
  215. final _options = _setStreamType<ApiResponse<VersionInfo>>(Options(
  216. method: 'GET',
  217. headers: _headers,
  218. extra: _extra,
  219. )
  220. .compose(
  221. _dio.options,
  222. '/app/api/findVersion',
  223. queryParameters: queryParameters,
  224. data: _data,
  225. )
  226. .copyWith(
  227. baseUrl: _combineBaseUrls(
  228. _dio.options.baseUrl,
  229. baseUrl,
  230. )));
  231. final _result = await _dio.fetch<Map<String, dynamic>>(_options);
  232. late ApiResponse<VersionInfo> _value;
  233. try {
  234. _value = ApiResponse<VersionInfo>.fromJson(
  235. _result.data!,
  236. (json) => VersionInfo.fromJson(json as Map<String, dynamic>),
  237. );
  238. } on Object catch (e, s) {
  239. errorLogger?.logError(e, s, _options);
  240. rethrow;
  241. }
  242. return _value;
  243. }
  244. @override
  245. Future<ApiResponse<List<PatientInfo>>> getPatientList() async {
  246. final _extra = <String, dynamic>{};
  247. final queryParameters = <String, dynamic>{};
  248. final _headers = <String, dynamic>{};
  249. const Map<String, dynamic>? _data = null;
  250. final _options = _setStreamType<ApiResponse<List<PatientInfo>>>(Options(
  251. method: 'GET',
  252. headers: _headers,
  253. extra: _extra,
  254. )
  255. .compose(
  256. _dio.options,
  257. '/app/user/list',
  258. queryParameters: queryParameters,
  259. data: _data,
  260. )
  261. .copyWith(
  262. baseUrl: _combineBaseUrls(
  263. _dio.options.baseUrl,
  264. baseUrl,
  265. )));
  266. final _result = await _dio.fetch<Map<String, dynamic>>(_options);
  267. late ApiResponse<List<PatientInfo>> _value;
  268. try {
  269. _value = ApiResponse<List<PatientInfo>>.fromJson(
  270. _result.data!,
  271. (json) => json is List<dynamic>
  272. ? json
  273. .map<PatientInfo>(
  274. (i) => PatientInfo.fromJson(i as Map<String, dynamic>))
  275. .toList()
  276. : List.empty(),
  277. );
  278. } on Object catch (e, s) {
  279. errorLogger?.logError(e, s, _options);
  280. rethrow;
  281. }
  282. return _value;
  283. }
  284. @override
  285. Future<ApiResponse<List<ClinicInfo>>> getClinicList() async {
  286. final _extra = <String, dynamic>{};
  287. final queryParameters = <String, dynamic>{};
  288. final _headers = <String, dynamic>{};
  289. const Map<String, dynamic>? _data = null;
  290. final _options = _setStreamType<ApiResponse<List<ClinicInfo>>>(Options(
  291. method: 'GET',
  292. headers: _headers,
  293. extra: _extra,
  294. )
  295. .compose(
  296. _dio.options,
  297. '/app/api/clinicList',
  298. queryParameters: queryParameters,
  299. data: _data,
  300. )
  301. .copyWith(
  302. baseUrl: _combineBaseUrls(
  303. _dio.options.baseUrl,
  304. baseUrl,
  305. )));
  306. final _result = await _dio.fetch<Map<String, dynamic>>(_options);
  307. late ApiResponse<List<ClinicInfo>> _value;
  308. try {
  309. _value = ApiResponse<List<ClinicInfo>>.fromJson(
  310. _result.data!,
  311. (json) => json is List<dynamic>
  312. ? json
  313. .map<ClinicInfo>(
  314. (i) => ClinicInfo.fromJson(i as Map<String, dynamic>))
  315. .toList()
  316. : List.empty(),
  317. );
  318. } on Object catch (e, s) {
  319. errorLogger?.logError(e, s, _options);
  320. rethrow;
  321. }
  322. return _value;
  323. }
  324. @override
  325. Future<ApiResponse<dynamic>> addPatient(
  326. String name,
  327. String idCard,
  328. String relation,
  329. ) async {
  330. final _extra = <String, dynamic>{};
  331. final queryParameters = <String, dynamic>{};
  332. final _headers = <String, dynamic>{r'Content-Type': 'application/json'};
  333. _headers.removeWhere((k, v) => v == null);
  334. final _data = {
  335. 'patientName': name,
  336. 'identificationCard': idCard,
  337. 'relationship': relation,
  338. };
  339. final _options = _setStreamType<ApiResponse<dynamic>>(Options(
  340. method: 'POST',
  341. headers: _headers,
  342. extra: _extra,
  343. contentType: 'application/json',
  344. )
  345. .compose(
  346. _dio.options,
  347. '/app/user',
  348. queryParameters: queryParameters,
  349. data: _data,
  350. )
  351. .copyWith(
  352. baseUrl: _combineBaseUrls(
  353. _dio.options.baseUrl,
  354. baseUrl,
  355. )));
  356. final _result = await _dio.fetch<Map<String, dynamic>>(_options);
  357. late ApiResponse<dynamic> _value;
  358. try {
  359. _value = ApiResponse<dynamic>.fromJson(
  360. _result.data!,
  361. (json) => json as dynamic,
  362. );
  363. } on Object catch (e, s) {
  364. errorLogger?.logError(e, s, _options);
  365. rethrow;
  366. }
  367. return _value;
  368. }
  369. @override
  370. Future<HttpResponse<String>> getPrivacyPolicy() async {
  371. final _extra = <String, dynamic>{};
  372. final queryParameters = <String, dynamic>{};
  373. final _headers = <String, dynamic>{};
  374. const Map<String, dynamic>? _data = null;
  375. final _options = _setStreamType<HttpResponse<String>>(Options(
  376. method: 'GET',
  377. headers: _headers,
  378. extra: _extra,
  379. )
  380. .compose(
  381. _dio.options,
  382. '/app/api/privacyPolicy',
  383. queryParameters: queryParameters,
  384. data: _data,
  385. )
  386. .copyWith(
  387. baseUrl: _combineBaseUrls(
  388. _dio.options.baseUrl,
  389. baseUrl,
  390. )));
  391. final _result = await _dio.fetch<String>(_options);
  392. late String _value;
  393. try {
  394. _value = _result.data!;
  395. } on Object catch (e, s) {
  396. errorLogger?.logError(e, s, _options);
  397. rethrow;
  398. }
  399. final httpResponse = HttpResponse(_value, _result);
  400. return httpResponse;
  401. }
  402. @override
  403. Future<HttpResponse<String>> getUserAgreement() async {
  404. final _extra = <String, dynamic>{};
  405. final queryParameters = <String, dynamic>{};
  406. final _headers = <String, dynamic>{};
  407. const Map<String, dynamic>? _data = null;
  408. final _options = _setStreamType<HttpResponse<String>>(Options(
  409. method: 'GET',
  410. headers: _headers,
  411. extra: _extra,
  412. )
  413. .compose(
  414. _dio.options,
  415. '/app/api/userAgreement',
  416. queryParameters: queryParameters,
  417. data: _data,
  418. )
  419. .copyWith(
  420. baseUrl: _combineBaseUrls(
  421. _dio.options.baseUrl,
  422. baseUrl,
  423. )));
  424. final _result = await _dio.fetch<String>(_options);
  425. late String _value;
  426. try {
  427. _value = _result.data!;
  428. } on Object catch (e, s) {
  429. errorLogger?.logError(e, s, _options);
  430. rethrow;
  431. }
  432. final httpResponse = HttpResponse(_value, _result);
  433. return httpResponse;
  434. }
  435. @override
  436. Future<HttpResponse<String>> getPermissionDescription(String type) async {
  437. final _extra = <String, dynamic>{};
  438. final queryParameters = <String, dynamic>{r'type': type};
  439. final _headers = <String, dynamic>{};
  440. const Map<String, dynamic>? _data = null;
  441. final _options = _setStreamType<HttpResponse<String>>(Options(
  442. method: 'GET',
  443. headers: _headers,
  444. extra: _extra,
  445. )
  446. .compose(
  447. _dio.options,
  448. '/app/api/permissionDescription',
  449. queryParameters: queryParameters,
  450. data: _data,
  451. )
  452. .copyWith(
  453. baseUrl: _combineBaseUrls(
  454. _dio.options.baseUrl,
  455. baseUrl,
  456. )));
  457. final _result = await _dio.fetch<String>(_options);
  458. late String _value;
  459. try {
  460. _value = _result.data!;
  461. } on Object catch (e, s) {
  462. errorLogger?.logError(e, s, _options);
  463. rethrow;
  464. }
  465. final httpResponse = HttpResponse(_value, _result);
  466. return httpResponse;
  467. }
  468. RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
  469. if (T != dynamic &&
  470. !(requestOptions.responseType == ResponseType.bytes ||
  471. requestOptions.responseType == ResponseType.stream)) {
  472. if (T == String) {
  473. requestOptions.responseType = ResponseType.plain;
  474. } else {
  475. requestOptions.responseType = ResponseType.json;
  476. }
  477. }
  478. return requestOptions;
  479. }
  480. String _combineBaseUrls(
  481. String dioBaseUrl,
  482. String? baseUrl,
  483. ) {
  484. if (baseUrl == null || baseUrl.trim().isEmpty) {
  485. return dioBaseUrl;
  486. }
  487. final url = Uri.parse(baseUrl);
  488. if (url.isAbsolute) {
  489. return url.toString();
  490. }
  491. return Uri.parse(dioBaseUrl).resolveUri(url).toString();
  492. }
  493. }