asset_api.dart 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. //
  2. // AUTO-GENERATED FILE, DO NOT MODIFY!
  3. //
  4. // @dart=2.12
  5. // ignore_for_file: unused_element, unused_import
  6. // ignore_for_file: always_put_required_named_parameters_first
  7. // ignore_for_file: constant_identifier_names
  8. // ignore_for_file: lines_longer_than_80_chars
  9. part of openapi.api;
  10. class AssetApi {
  11. AssetApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
  12. final ApiClient apiClient;
  13. ///
  14. ///
  15. /// Check duplicated asset before uploading - for Web upload used
  16. ///
  17. /// Note: This method returns the HTTP [Response].
  18. ///
  19. /// Parameters:
  20. ///
  21. /// * [CheckDuplicateAssetDto] checkDuplicateAssetDto (required):
  22. Future<Response> checkDuplicateAssetWithHttpInfo(CheckDuplicateAssetDto checkDuplicateAssetDto,) async {
  23. // ignore: prefer_const_declarations
  24. final path = r'/asset/check';
  25. // ignore: prefer_final_locals
  26. Object? postBody = checkDuplicateAssetDto;
  27. final queryParams = <QueryParam>[];
  28. final headerParams = <String, String>{};
  29. final formParams = <String, String>{};
  30. const contentTypes = <String>['application/json'];
  31. return apiClient.invokeAPI(
  32. path,
  33. 'POST',
  34. queryParams,
  35. postBody,
  36. headerParams,
  37. formParams,
  38. contentTypes.isEmpty ? null : contentTypes.first,
  39. );
  40. }
  41. ///
  42. ///
  43. /// Check duplicated asset before uploading - for Web upload used
  44. ///
  45. /// Parameters:
  46. ///
  47. /// * [CheckDuplicateAssetDto] checkDuplicateAssetDto (required):
  48. Future<CheckDuplicateAssetResponseDto?> checkDuplicateAsset(CheckDuplicateAssetDto checkDuplicateAssetDto,) async {
  49. final response = await checkDuplicateAssetWithHttpInfo(checkDuplicateAssetDto,);
  50. if (response.statusCode >= HttpStatus.badRequest) {
  51. throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  52. }
  53. // When a remote server returns no body with a status of 204, we shall not decode it.
  54. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  55. // FormatException when trying to decode an empty string.
  56. if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
  57. return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'CheckDuplicateAssetResponseDto',) as CheckDuplicateAssetResponseDto;
  58. }
  59. return null;
  60. }
  61. /// Performs an HTTP 'DELETE /asset' operation and returns the [Response].
  62. /// Parameters:
  63. ///
  64. /// * [DeleteAssetDto] deleteAssetDto (required):
  65. Future<Response> deleteAssetWithHttpInfo(DeleteAssetDto deleteAssetDto,) async {
  66. // ignore: prefer_const_declarations
  67. final path = r'/asset';
  68. // ignore: prefer_final_locals
  69. Object? postBody = deleteAssetDto;
  70. final queryParams = <QueryParam>[];
  71. final headerParams = <String, String>{};
  72. final formParams = <String, String>{};
  73. const contentTypes = <String>['application/json'];
  74. return apiClient.invokeAPI(
  75. path,
  76. 'DELETE',
  77. queryParams,
  78. postBody,
  79. headerParams,
  80. formParams,
  81. contentTypes.isEmpty ? null : contentTypes.first,
  82. );
  83. }
  84. /// Parameters:
  85. ///
  86. /// * [DeleteAssetDto] deleteAssetDto (required):
  87. Future<List<DeleteAssetResponseDto>?> deleteAsset(DeleteAssetDto deleteAssetDto,) async {
  88. final response = await deleteAssetWithHttpInfo(deleteAssetDto,);
  89. if (response.statusCode >= HttpStatus.badRequest) {
  90. throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  91. }
  92. // When a remote server returns no body with a status of 204, we shall not decode it.
  93. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  94. // FormatException when trying to decode an empty string.
  95. if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
  96. final responseBody = await _decodeBodyBytes(response);
  97. return (await apiClient.deserializeAsync(responseBody, 'List<DeleteAssetResponseDto>') as List)
  98. .cast<DeleteAssetResponseDto>()
  99. .toList();
  100. }
  101. return null;
  102. }
  103. /// Performs an HTTP 'GET /asset/download' operation and returns the [Response].
  104. /// Parameters:
  105. ///
  106. /// * [String] aid (required):
  107. ///
  108. /// * [String] did (required):
  109. ///
  110. /// * [bool] isThumb:
  111. ///
  112. /// * [bool] isWeb:
  113. Future<Response> downloadFileWithHttpInfo(String aid, String did, { bool? isThumb, bool? isWeb, }) async {
  114. // ignore: prefer_const_declarations
  115. final path = r'/asset/download';
  116. // ignore: prefer_final_locals
  117. Object? postBody;
  118. final queryParams = <QueryParam>[];
  119. final headerParams = <String, String>{};
  120. final formParams = <String, String>{};
  121. queryParams.addAll(_queryParams('', 'aid', aid));
  122. queryParams.addAll(_queryParams('', 'did', did));
  123. if (isThumb != null) {
  124. queryParams.addAll(_queryParams('', 'isThumb', isThumb));
  125. }
  126. if (isWeb != null) {
  127. queryParams.addAll(_queryParams('', 'isWeb', isWeb));
  128. }
  129. const contentTypes = <String>[];
  130. return apiClient.invokeAPI(
  131. path,
  132. 'GET',
  133. queryParams,
  134. postBody,
  135. headerParams,
  136. formParams,
  137. contentTypes.isEmpty ? null : contentTypes.first,
  138. );
  139. }
  140. /// Parameters:
  141. ///
  142. /// * [String] aid (required):
  143. ///
  144. /// * [String] did (required):
  145. ///
  146. /// * [bool] isThumb:
  147. ///
  148. /// * [bool] isWeb:
  149. Future<Object?> downloadFile(String aid, String did, { bool? isThumb, bool? isWeb, }) async {
  150. final response = await downloadFileWithHttpInfo(aid, did, isThumb: isThumb, isWeb: isWeb, );
  151. if (response.statusCode >= HttpStatus.badRequest) {
  152. throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  153. }
  154. // When a remote server returns no body with a status of 204, we shall not decode it.
  155. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  156. // FormatException when trying to decode an empty string.
  157. if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
  158. return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Object',) as Object;
  159. }
  160. return null;
  161. }
  162. ///
  163. ///
  164. /// Get all AssetEntity belong to the user
  165. ///
  166. /// Note: This method returns the HTTP [Response].
  167. Future<Response> getAllAssetsWithHttpInfo() async {
  168. // ignore: prefer_const_declarations
  169. final path = r'/asset';
  170. // ignore: prefer_final_locals
  171. Object? postBody;
  172. final queryParams = <QueryParam>[];
  173. final headerParams = <String, String>{};
  174. final formParams = <String, String>{};
  175. const contentTypes = <String>[];
  176. return apiClient.invokeAPI(
  177. path,
  178. 'GET',
  179. queryParams,
  180. postBody,
  181. headerParams,
  182. formParams,
  183. contentTypes.isEmpty ? null : contentTypes.first,
  184. );
  185. }
  186. ///
  187. ///
  188. /// Get all AssetEntity belong to the user
  189. Future<List<AssetResponseDto>?> getAllAssets() async {
  190. final response = await getAllAssetsWithHttpInfo();
  191. if (response.statusCode >= HttpStatus.badRequest) {
  192. throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  193. }
  194. // When a remote server returns no body with a status of 204, we shall not decode it.
  195. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  196. // FormatException when trying to decode an empty string.
  197. if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
  198. final responseBody = await _decodeBodyBytes(response);
  199. return (await apiClient.deserializeAsync(responseBody, 'List<AssetResponseDto>') as List)
  200. .cast<AssetResponseDto>()
  201. .toList();
  202. }
  203. return null;
  204. }
  205. ///
  206. ///
  207. /// Get a single asset's information
  208. ///
  209. /// Note: This method returns the HTTP [Response].
  210. ///
  211. /// Parameters:
  212. ///
  213. /// * [String] assetId (required):
  214. Future<Response> getAssetByIdWithHttpInfo(String assetId,) async {
  215. // ignore: prefer_const_declarations
  216. final path = r'/asset/assetById/{assetId}'
  217. .replaceAll('{assetId}', assetId);
  218. // ignore: prefer_final_locals
  219. Object? postBody;
  220. final queryParams = <QueryParam>[];
  221. final headerParams = <String, String>{};
  222. final formParams = <String, String>{};
  223. const contentTypes = <String>[];
  224. return apiClient.invokeAPI(
  225. path,
  226. 'GET',
  227. queryParams,
  228. postBody,
  229. headerParams,
  230. formParams,
  231. contentTypes.isEmpty ? null : contentTypes.first,
  232. );
  233. }
  234. ///
  235. ///
  236. /// Get a single asset's information
  237. ///
  238. /// Parameters:
  239. ///
  240. /// * [String] assetId (required):
  241. Future<AssetResponseDto?> getAssetById(String assetId,) async {
  242. final response = await getAssetByIdWithHttpInfo(assetId,);
  243. if (response.statusCode >= HttpStatus.badRequest) {
  244. throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  245. }
  246. // When a remote server returns no body with a status of 204, we shall not decode it.
  247. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  248. // FormatException when trying to decode an empty string.
  249. if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
  250. return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'AssetResponseDto',) as AssetResponseDto;
  251. }
  252. return null;
  253. }
  254. /// Performs an HTTP 'GET /asset/searchTerm' operation and returns the [Response].
  255. Future<Response> getAssetSearchTermsWithHttpInfo() async {
  256. // ignore: prefer_const_declarations
  257. final path = r'/asset/searchTerm';
  258. // ignore: prefer_final_locals
  259. Object? postBody;
  260. final queryParams = <QueryParam>[];
  261. final headerParams = <String, String>{};
  262. final formParams = <String, String>{};
  263. const contentTypes = <String>[];
  264. return apiClient.invokeAPI(
  265. path,
  266. 'GET',
  267. queryParams,
  268. postBody,
  269. headerParams,
  270. formParams,
  271. contentTypes.isEmpty ? null : contentTypes.first,
  272. );
  273. }
  274. Future<List<String>?> getAssetSearchTerms() async {
  275. final response = await getAssetSearchTermsWithHttpInfo();
  276. if (response.statusCode >= HttpStatus.badRequest) {
  277. throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  278. }
  279. // When a remote server returns no body with a status of 204, we shall not decode it.
  280. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  281. // FormatException when trying to decode an empty string.
  282. if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
  283. final responseBody = await _decodeBodyBytes(response);
  284. return (await apiClient.deserializeAsync(responseBody, 'List<String>') as List)
  285. .cast<String>()
  286. .toList();
  287. }
  288. return null;
  289. }
  290. /// Performs an HTTP 'GET /asset/thumbnail/{assetId}' operation and returns the [Response].
  291. /// Parameters:
  292. ///
  293. /// * [String] assetId (required):
  294. ///
  295. /// * [ThumbnailFormat] format:
  296. Future<Response> getAssetThumbnailWithHttpInfo(String assetId, { ThumbnailFormat? format, }) async {
  297. // ignore: prefer_const_declarations
  298. final path = r'/asset/thumbnail/{assetId}'
  299. .replaceAll('{assetId}', assetId);
  300. // ignore: prefer_final_locals
  301. Object? postBody;
  302. final queryParams = <QueryParam>[];
  303. final headerParams = <String, String>{};
  304. final formParams = <String, String>{};
  305. if (format != null) {
  306. queryParams.addAll(_queryParams('', 'format', format));
  307. }
  308. const contentTypes = <String>[];
  309. return apiClient.invokeAPI(
  310. path,
  311. 'GET',
  312. queryParams,
  313. postBody,
  314. headerParams,
  315. formParams,
  316. contentTypes.isEmpty ? null : contentTypes.first,
  317. );
  318. }
  319. /// Parameters:
  320. ///
  321. /// * [String] assetId (required):
  322. ///
  323. /// * [ThumbnailFormat] format:
  324. Future<Object?> getAssetThumbnail(String assetId, { ThumbnailFormat? format, }) async {
  325. final response = await getAssetThumbnailWithHttpInfo(assetId, format: format, );
  326. if (response.statusCode >= HttpStatus.badRequest) {
  327. throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  328. }
  329. // When a remote server returns no body with a status of 204, we shall not decode it.
  330. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  331. // FormatException when trying to decode an empty string.
  332. if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
  333. return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Object',) as Object;
  334. }
  335. return null;
  336. }
  337. /// Performs an HTTP 'GET /asset/allLocation' operation and returns the [Response].
  338. Future<Response> getCuratedLocationsWithHttpInfo() async {
  339. // ignore: prefer_const_declarations
  340. final path = r'/asset/allLocation';
  341. // ignore: prefer_final_locals
  342. Object? postBody;
  343. final queryParams = <QueryParam>[];
  344. final headerParams = <String, String>{};
  345. final formParams = <String, String>{};
  346. const contentTypes = <String>[];
  347. return apiClient.invokeAPI(
  348. path,
  349. 'GET',
  350. queryParams,
  351. postBody,
  352. headerParams,
  353. formParams,
  354. contentTypes.isEmpty ? null : contentTypes.first,
  355. );
  356. }
  357. Future<List<CuratedLocationsResponseDto>?> getCuratedLocations() async {
  358. final response = await getCuratedLocationsWithHttpInfo();
  359. if (response.statusCode >= HttpStatus.badRequest) {
  360. throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  361. }
  362. // When a remote server returns no body with a status of 204, we shall not decode it.
  363. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  364. // FormatException when trying to decode an empty string.
  365. if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
  366. final responseBody = await _decodeBodyBytes(response);
  367. return (await apiClient.deserializeAsync(responseBody, 'List<CuratedLocationsResponseDto>') as List)
  368. .cast<CuratedLocationsResponseDto>()
  369. .toList();
  370. }
  371. return null;
  372. }
  373. /// Performs an HTTP 'GET /asset/allObjects' operation and returns the [Response].
  374. Future<Response> getCuratedObjectsWithHttpInfo() async {
  375. // ignore: prefer_const_declarations
  376. final path = r'/asset/allObjects';
  377. // ignore: prefer_final_locals
  378. Object? postBody;
  379. final queryParams = <QueryParam>[];
  380. final headerParams = <String, String>{};
  381. final formParams = <String, String>{};
  382. const contentTypes = <String>[];
  383. return apiClient.invokeAPI(
  384. path,
  385. 'GET',
  386. queryParams,
  387. postBody,
  388. headerParams,
  389. formParams,
  390. contentTypes.isEmpty ? null : contentTypes.first,
  391. );
  392. }
  393. Future<List<CuratedObjectsResponseDto>?> getCuratedObjects() async {
  394. final response = await getCuratedObjectsWithHttpInfo();
  395. if (response.statusCode >= HttpStatus.badRequest) {
  396. throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  397. }
  398. // When a remote server returns no body with a status of 204, we shall not decode it.
  399. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  400. // FormatException when trying to decode an empty string.
  401. if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
  402. final responseBody = await _decodeBodyBytes(response);
  403. return (await apiClient.deserializeAsync(responseBody, 'List<CuratedObjectsResponseDto>') as List)
  404. .cast<CuratedObjectsResponseDto>()
  405. .toList();
  406. }
  407. return null;
  408. }
  409. ///
  410. ///
  411. /// Get all asset of a device that are in the database, ID only.
  412. ///
  413. /// Note: This method returns the HTTP [Response].
  414. ///
  415. /// Parameters:
  416. ///
  417. /// * [String] deviceId (required):
  418. Future<Response> getUserAssetsByDeviceIdWithHttpInfo(String deviceId,) async {
  419. // ignore: prefer_const_declarations
  420. final path = r'/asset/{deviceId}'
  421. .replaceAll('{deviceId}', deviceId);
  422. // ignore: prefer_final_locals
  423. Object? postBody;
  424. final queryParams = <QueryParam>[];
  425. final headerParams = <String, String>{};
  426. final formParams = <String, String>{};
  427. const contentTypes = <String>[];
  428. return apiClient.invokeAPI(
  429. path,
  430. 'GET',
  431. queryParams,
  432. postBody,
  433. headerParams,
  434. formParams,
  435. contentTypes.isEmpty ? null : contentTypes.first,
  436. );
  437. }
  438. ///
  439. ///
  440. /// Get all asset of a device that are in the database, ID only.
  441. ///
  442. /// Parameters:
  443. ///
  444. /// * [String] deviceId (required):
  445. Future<List<String>?> getUserAssetsByDeviceId(String deviceId,) async {
  446. final response = await getUserAssetsByDeviceIdWithHttpInfo(deviceId,);
  447. if (response.statusCode >= HttpStatus.badRequest) {
  448. throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  449. }
  450. // When a remote server returns no body with a status of 204, we shall not decode it.
  451. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  452. // FormatException when trying to decode an empty string.
  453. if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
  454. final responseBody = await _decodeBodyBytes(response);
  455. return (await apiClient.deserializeAsync(responseBody, 'List<String>') as List)
  456. .cast<String>()
  457. .toList();
  458. }
  459. return null;
  460. }
  461. /// Performs an HTTP 'POST /asset/search' operation and returns the [Response].
  462. /// Parameters:
  463. ///
  464. /// * [SearchAssetDto] searchAssetDto (required):
  465. Future<Response> searchAssetWithHttpInfo(SearchAssetDto searchAssetDto,) async {
  466. // ignore: prefer_const_declarations
  467. final path = r'/asset/search';
  468. // ignore: prefer_final_locals
  469. Object? postBody = searchAssetDto;
  470. final queryParams = <QueryParam>[];
  471. final headerParams = <String, String>{};
  472. final formParams = <String, String>{};
  473. const contentTypes = <String>['application/json'];
  474. return apiClient.invokeAPI(
  475. path,
  476. 'POST',
  477. queryParams,
  478. postBody,
  479. headerParams,
  480. formParams,
  481. contentTypes.isEmpty ? null : contentTypes.first,
  482. );
  483. }
  484. /// Parameters:
  485. ///
  486. /// * [SearchAssetDto] searchAssetDto (required):
  487. Future<List<AssetResponseDto>?> searchAsset(SearchAssetDto searchAssetDto,) async {
  488. final response = await searchAssetWithHttpInfo(searchAssetDto,);
  489. if (response.statusCode >= HttpStatus.badRequest) {
  490. throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  491. }
  492. // When a remote server returns no body with a status of 204, we shall not decode it.
  493. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  494. // FormatException when trying to decode an empty string.
  495. if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
  496. final responseBody = await _decodeBodyBytes(response);
  497. return (await apiClient.deserializeAsync(responseBody, 'List<AssetResponseDto>') as List)
  498. .cast<AssetResponseDto>()
  499. .toList();
  500. }
  501. return null;
  502. }
  503. /// Performs an HTTP 'GET /asset/file' operation and returns the [Response].
  504. /// Parameters:
  505. ///
  506. /// * [String] aid (required):
  507. ///
  508. /// * [String] did (required):
  509. ///
  510. /// * [bool] isThumb:
  511. ///
  512. /// * [bool] isWeb:
  513. Future<Response> serveFileWithHttpInfo(String aid, String did, { bool? isThumb, bool? isWeb, }) async {
  514. // ignore: prefer_const_declarations
  515. final path = r'/asset/file';
  516. // ignore: prefer_final_locals
  517. Object? postBody;
  518. final queryParams = <QueryParam>[];
  519. final headerParams = <String, String>{};
  520. final formParams = <String, String>{};
  521. queryParams.addAll(_queryParams('', 'aid', aid));
  522. queryParams.addAll(_queryParams('', 'did', did));
  523. if (isThumb != null) {
  524. queryParams.addAll(_queryParams('', 'isThumb', isThumb));
  525. }
  526. if (isWeb != null) {
  527. queryParams.addAll(_queryParams('', 'isWeb', isWeb));
  528. }
  529. const contentTypes = <String>[];
  530. return apiClient.invokeAPI(
  531. path,
  532. 'GET',
  533. queryParams,
  534. postBody,
  535. headerParams,
  536. formParams,
  537. contentTypes.isEmpty ? null : contentTypes.first,
  538. );
  539. }
  540. /// Parameters:
  541. ///
  542. /// * [String] aid (required):
  543. ///
  544. /// * [String] did (required):
  545. ///
  546. /// * [bool] isThumb:
  547. ///
  548. /// * [bool] isWeb:
  549. Future<Object?> serveFile(String aid, String did, { bool? isThumb, bool? isWeb, }) async {
  550. final response = await serveFileWithHttpInfo(aid, did, isThumb: isThumb, isWeb: isWeb, );
  551. if (response.statusCode >= HttpStatus.badRequest) {
  552. throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  553. }
  554. // When a remote server returns no body with a status of 204, we shall not decode it.
  555. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  556. // FormatException when trying to decode an empty string.
  557. if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
  558. return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Object',) as Object;
  559. }
  560. return null;
  561. }
  562. /// Performs an HTTP 'POST /asset/upload' operation and returns the [Response].
  563. /// Parameters:
  564. ///
  565. /// * [MultipartFile] assetData (required):
  566. Future<Response> uploadFileWithHttpInfo(MultipartFile assetData,) async {
  567. // ignore: prefer_const_declarations
  568. final path = r'/asset/upload';
  569. // ignore: prefer_final_locals
  570. Object? postBody;
  571. final queryParams = <QueryParam>[];
  572. final headerParams = <String, String>{};
  573. final formParams = <String, String>{};
  574. const contentTypes = <String>['multipart/form-data'];
  575. bool hasFields = false;
  576. final mp = MultipartRequest('POST', Uri.parse(path));
  577. if (assetData != null) {
  578. hasFields = true;
  579. mp.fields[r'assetData'] = assetData.field;
  580. mp.files.add(assetData);
  581. }
  582. if (hasFields) {
  583. postBody = mp;
  584. }
  585. return apiClient.invokeAPI(
  586. path,
  587. 'POST',
  588. queryParams,
  589. postBody,
  590. headerParams,
  591. formParams,
  592. contentTypes.isEmpty ? null : contentTypes.first,
  593. );
  594. }
  595. /// Parameters:
  596. ///
  597. /// * [MultipartFile] assetData (required):
  598. Future<AssetFileUploadResponseDto?> uploadFile(MultipartFile assetData,) async {
  599. final response = await uploadFileWithHttpInfo(assetData,);
  600. if (response.statusCode >= HttpStatus.badRequest) {
  601. throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  602. }
  603. // When a remote server returns no body with a status of 204, we shall not decode it.
  604. // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  605. // FormatException when trying to decode an empty string.
  606. if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
  607. return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'AssetFileUploadResponseDto',) as AssetFileUploadResponseDto;
  608. }
  609. return null;
  610. }
  611. }