1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-10 23:22:22 +02:00

refactor: asset media endpoints (#9831)

* refactor: asset media endpoints

* refactor: mobile upload livePhoto as separate request

* refactor: change mobile backup flow to use new asset upload endpoints

* chore: format and analyze dart code

* feat: mark motion as hidden when linked

* feat: upload video portion of live photo before image portion

* fix: incorrect assetApi calls in mobile code

* fix: download asset

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
Co-authored-by: Zack Pollard <zackpollard@ymail.com>
This commit is contained in:
Jason Rasmussen
2024-05-31 13:44:04 -04:00
committed by GitHub
parent 66fced40e7
commit 69d2fcb43e
91 changed files with 1932 additions and 2456 deletions

View File

@@ -87,13 +87,13 @@ part 'model/asset_face_response_dto.dart';
part 'model/asset_face_update_dto.dart';
part 'model/asset_face_update_item.dart';
part 'model/asset_face_without_person_response_dto.dart';
part 'model/asset_file_upload_response_dto.dart';
part 'model/asset_full_sync_dto.dart';
part 'model/asset_ids_dto.dart';
part 'model/asset_ids_response_dto.dart';
part 'model/asset_job_name.dart';
part 'model/asset_jobs_dto.dart';
part 'model/asset_media_response_dto.dart';
part 'model/asset_media_size.dart';
part 'model/asset_media_status.dart';
part 'model/asset_order.dart';
part 'model/asset_response_dto.dart';
@@ -225,7 +225,6 @@ part 'model/system_config_trash_dto.dart';
part 'model/system_config_user_dto.dart';
part 'model/tag_response_dto.dart';
part 'model/tag_type_enum.dart';
part 'model/thumbnail_format.dart';
part 'model/time_bucket_response_dto.dart';
part 'model/time_bucket_size.dart';
part 'model/tone_mapping.dart';

View File

@@ -25,7 +25,7 @@ class AssetsApi {
/// * [AssetBulkUploadCheckDto] assetBulkUploadCheckDto (required):
Future<Response> checkBulkUploadWithHttpInfo(AssetBulkUploadCheckDto assetBulkUploadCheckDto,) async {
// ignore: prefer_const_declarations
final path = r'/asset/bulk-upload-check';
final path = r'/assets/bulk-upload-check';
// ignore: prefer_final_locals
Object? postBody = assetBulkUploadCheckDto;
@@ -77,7 +77,7 @@ class AssetsApi {
/// * [CheckExistingAssetsDto] checkExistingAssetsDto (required):
Future<Response> checkExistingAssetsWithHttpInfo(CheckExistingAssetsDto checkExistingAssetsDto,) async {
// ignore: prefer_const_declarations
final path = r'/asset/exist';
final path = r'/assets/exist';
// ignore: prefer_final_locals
Object? postBody = checkExistingAssetsDto;
@@ -120,13 +120,13 @@ class AssetsApi {
return null;
}
/// Performs an HTTP 'DELETE /asset' operation and returns the [Response].
/// Performs an HTTP 'DELETE /assets' operation and returns the [Response].
/// Parameters:
///
/// * [AssetBulkDeleteDto] assetBulkDeleteDto (required):
Future<Response> deleteAssetsWithHttpInfo(AssetBulkDeleteDto assetBulkDeleteDto,) async {
// ignore: prefer_const_declarations
final path = r'/asset';
final path = r'/assets';
// ignore: prefer_final_locals
Object? postBody = assetBulkDeleteDto;
@@ -159,6 +159,62 @@ class AssetsApi {
}
}
/// Performs an HTTP 'GET /assets/{id}/original' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
///
/// * [String] key:
Future<Response> downloadAssetWithHttpInfo(String id, { String? key, }) async {
// ignore: prefer_const_declarations
final path = r'/assets/{id}/original'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
if (key != null) {
queryParams.addAll(_queryParams('', 'key', key));
}
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [String] id (required):
///
/// * [String] key:
Future<MultipartFile?> downloadAsset(String id, { String? key, }) async {
final response = await downloadAssetWithHttpInfo(id, key: key, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'MultipartFile',) as MultipartFile;
}
return null;
}
/// Get all asset of a device that are in the database, ID only.
///
/// Note: This method returns the HTTP [Response].
@@ -168,7 +224,7 @@ class AssetsApi {
/// * [String] deviceId (required):
Future<Response> getAllUserAssetsByDeviceIdWithHttpInfo(String deviceId,) async {
// ignore: prefer_const_declarations
final path = r'/asset/device/{deviceId}'
final path = r'/assets/device/{deviceId}'
.replaceAll('{deviceId}', deviceId);
// ignore: prefer_final_locals
@@ -215,7 +271,7 @@ class AssetsApi {
return null;
}
/// Performs an HTTP 'GET /asset/{id}' operation and returns the [Response].
/// Performs an HTTP 'GET /assets/{id}' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
@@ -223,7 +279,7 @@ class AssetsApi {
/// * [String] key:
Future<Response> getAssetInfoWithHttpInfo(String id, { String? key, }) async {
// ignore: prefer_const_declarations
final path = r'/asset/{id}'
final path = r'/assets/{id}'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
@@ -271,7 +327,7 @@ class AssetsApi {
return null;
}
/// Performs an HTTP 'GET /asset/statistics' operation and returns the [Response].
/// Performs an HTTP 'GET /assets/statistics' operation and returns the [Response].
/// Parameters:
///
/// * [bool] isArchived:
@@ -281,7 +337,7 @@ class AssetsApi {
/// * [bool] isTrashed:
Future<Response> getAssetStatisticsWithHttpInfo({ bool? isArchived, bool? isFavorite, bool? isTrashed, }) async {
// ignore: prefer_const_declarations
final path = r'/asset/statistics';
final path = r'/assets/statistics';
// ignore: prefer_final_locals
Object? postBody;
@@ -336,70 +392,7 @@ class AssetsApi {
return null;
}
/// Performs an HTTP 'GET /asset/thumbnail/{id}' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
///
/// * [ThumbnailFormat] format:
///
/// * [String] key:
Future<Response> getAssetThumbnailWithHttpInfo(String id, { ThumbnailFormat? format, String? key, }) async {
// ignore: prefer_const_declarations
final path = r'/asset/thumbnail/{id}'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
if (format != null) {
queryParams.addAll(_queryParams('', 'format', format));
}
if (key != null) {
queryParams.addAll(_queryParams('', 'key', key));
}
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [String] id (required):
///
/// * [ThumbnailFormat] format:
///
/// * [String] key:
Future<MultipartFile?> getAssetThumbnail(String id, { ThumbnailFormat? format, String? key, }) async {
final response = await getAssetThumbnailWithHttpInfo(id, format: format, key: key, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'MultipartFile',) as MultipartFile;
}
return null;
}
/// Performs an HTTP 'GET /asset/memory-lane' operation and returns the [Response].
/// Performs an HTTP 'GET /assets/memory-lane' operation and returns the [Response].
/// Parameters:
///
/// * [int] day (required):
@@ -407,7 +400,7 @@ class AssetsApi {
/// * [int] month (required):
Future<Response> getMemoryLaneWithHttpInfo(int day, int month,) async {
// ignore: prefer_const_declarations
final path = r'/asset/memory-lane';
final path = r'/assets/memory-lane';
// ignore: prefer_final_locals
Object? postBody;
@@ -456,13 +449,13 @@ class AssetsApi {
return null;
}
/// Performs an HTTP 'GET /asset/random' operation and returns the [Response].
/// Performs an HTTP 'GET /assets/random' operation and returns the [Response].
/// Parameters:
///
/// * [num] count:
Future<Response> getRandomWithHttpInfo({ num? count, }) async {
// ignore: prefer_const_declarations
final path = r'/asset/random';
final path = r'/assets/random';
// ignore: prefer_final_locals
Object? postBody;
@@ -510,6 +503,62 @@ class AssetsApi {
return null;
}
/// Performs an HTTP 'GET /assets/{id}/video/playback' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
///
/// * [String] key:
Future<Response> playAssetVideoWithHttpInfo(String id, { String? key, }) async {
// ignore: prefer_const_declarations
final path = r'/assets/{id}/video/playback'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
if (key != null) {
queryParams.addAll(_queryParams('', 'key', key));
}
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [String] id (required):
///
/// * [String] key:
Future<MultipartFile?> playAssetVideo(String id, { String? key, }) async {
final response = await playAssetVideoWithHttpInfo(id, key: key, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'MultipartFile',) as MultipartFile;
}
return null;
}
/// Replace the asset with new file, without changing its id
///
/// Note: This method returns the HTTP [Response].
@@ -533,7 +582,7 @@ class AssetsApi {
/// * [String] duration:
Future<Response> replaceAssetWithHttpInfo(String id, MultipartFile assetData, String deviceAssetId, String deviceId, DateTime fileCreatedAt, DateTime fileModifiedAt, { String? key, String? duration, }) async {
// ignore: prefer_const_declarations
final path = r'/asset/{id}/file'
final path = r'/assets/{id}/original'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
@@ -625,13 +674,13 @@ class AssetsApi {
return null;
}
/// Performs an HTTP 'POST /asset/jobs' operation and returns the [Response].
/// Performs an HTTP 'POST /assets/jobs' operation and returns the [Response].
/// Parameters:
///
/// * [AssetJobsDto] assetJobsDto (required):
Future<Response> runAssetJobsWithHttpInfo(AssetJobsDto assetJobsDto,) async {
// ignore: prefer_const_declarations
final path = r'/asset/jobs';
final path = r'/assets/jobs';
// ignore: prefer_final_locals
Object? postBody = assetJobsDto;
@@ -664,77 +713,7 @@ class AssetsApi {
}
}
/// Performs an HTTP 'GET /asset/file/{id}' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
///
/// * [bool] isThumb:
///
/// * [bool] isWeb:
///
/// * [String] key:
Future<Response> serveFileWithHttpInfo(String id, { bool? isThumb, bool? isWeb, String? key, }) async {
// ignore: prefer_const_declarations
final path = r'/asset/file/{id}'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
if (isThumb != null) {
queryParams.addAll(_queryParams('', 'isThumb', isThumb));
}
if (isWeb != null) {
queryParams.addAll(_queryParams('', 'isWeb', isWeb));
}
if (key != null) {
queryParams.addAll(_queryParams('', 'key', key));
}
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [String] id (required):
///
/// * [bool] isThumb:
///
/// * [bool] isWeb:
///
/// * [String] key:
Future<MultipartFile?> serveFile(String id, { bool? isThumb, bool? isWeb, String? key, }) async {
final response = await serveFileWithHttpInfo(id, isThumb: isThumb, isWeb: isWeb, key: key, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'MultipartFile',) as MultipartFile;
}
return null;
}
/// Performs an HTTP 'PUT /asset/{id}' operation and returns the [Response].
/// Performs an HTTP 'PUT /assets/{id}' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
@@ -742,7 +721,7 @@ class AssetsApi {
/// * [UpdateAssetDto] updateAssetDto (required):
Future<Response> updateAssetWithHttpInfo(String id, UpdateAssetDto updateAssetDto,) async {
// ignore: prefer_const_declarations
final path = r'/asset/{id}'
final path = r'/assets/{id}'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
@@ -786,13 +765,13 @@ class AssetsApi {
return null;
}
/// Performs an HTTP 'PUT /asset' operation and returns the [Response].
/// Performs an HTTP 'PUT /assets' operation and returns the [Response].
/// Parameters:
///
/// * [AssetBulkUpdateDto] assetBulkUpdateDto (required):
Future<Response> updateAssetsWithHttpInfo(AssetBulkUpdateDto assetBulkUpdateDto,) async {
// ignore: prefer_const_declarations
final path = r'/asset';
final path = r'/assets';
// ignore: prefer_final_locals
Object? postBody = assetBulkUpdateDto;
@@ -825,13 +804,13 @@ class AssetsApi {
}
}
/// Performs an HTTP 'PUT /asset/stack/parent' operation and returns the [Response].
/// Performs an HTTP 'PUT /assets/stack/parent' operation and returns the [Response].
/// Parameters:
///
/// * [UpdateStackParentDto] updateStackParentDto (required):
Future<Response> updateStackParentWithHttpInfo(UpdateStackParentDto updateStackParentDto,) async {
// ignore: prefer_const_declarations
final path = r'/asset/stack/parent';
final path = r'/assets/stack/parent';
// ignore: prefer_final_locals
Object? postBody = updateStackParentDto;
@@ -864,7 +843,7 @@ class AssetsApi {
}
}
/// Performs an HTTP 'POST /asset/upload' operation and returns the [Response].
/// Performs an HTTP 'POST /assets' operation and returns the [Response].
/// Parameters:
///
/// * [MultipartFile] assetData (required):
@@ -892,12 +871,12 @@ class AssetsApi {
///
/// * [bool] isVisible:
///
/// * [MultipartFile] livePhotoData:
/// * [String] livePhotoVideoId:
///
/// * [MultipartFile] sidecarData:
Future<Response> uploadFileWithHttpInfo(MultipartFile assetData, String deviceAssetId, String deviceId, DateTime fileCreatedAt, DateTime fileModifiedAt, { String? key, String? xImmichChecksum, String? duration, bool? isArchived, bool? isFavorite, bool? isOffline, bool? isVisible, MultipartFile? livePhotoData, MultipartFile? sidecarData, }) async {
Future<Response> uploadAssetWithHttpInfo(MultipartFile assetData, String deviceAssetId, String deviceId, DateTime fileCreatedAt, DateTime fileModifiedAt, { String? key, String? xImmichChecksum, String? duration, bool? isArchived, bool? isFavorite, bool? isOffline, bool? isVisible, String? livePhotoVideoId, MultipartFile? sidecarData, }) async {
// ignore: prefer_const_declarations
final path = r'/asset/upload';
final path = r'/assets';
// ignore: prefer_final_locals
Object? postBody;
@@ -959,10 +938,9 @@ class AssetsApi {
hasFields = true;
mp.fields[r'isVisible'] = parameterToString(isVisible);
}
if (livePhotoData != null) {
if (livePhotoVideoId != null) {
hasFields = true;
mp.fields[r'livePhotoData'] = livePhotoData.field;
mp.files.add(livePhotoData);
mp.fields[r'livePhotoVideoId'] = parameterToString(livePhotoVideoId);
}
if (sidecarData != null) {
hasFields = true;
@@ -1011,11 +989,11 @@ class AssetsApi {
///
/// * [bool] isVisible:
///
/// * [MultipartFile] livePhotoData:
/// * [String] livePhotoVideoId:
///
/// * [MultipartFile] sidecarData:
Future<AssetFileUploadResponseDto?> uploadFile(MultipartFile assetData, String deviceAssetId, String deviceId, DateTime fileCreatedAt, DateTime fileModifiedAt, { String? key, String? xImmichChecksum, String? duration, bool? isArchived, bool? isFavorite, bool? isOffline, bool? isVisible, MultipartFile? livePhotoData, MultipartFile? sidecarData, }) async {
final response = await uploadFileWithHttpInfo(assetData, deviceAssetId, deviceId, fileCreatedAt, fileModifiedAt, key: key, xImmichChecksum: xImmichChecksum, duration: duration, isArchived: isArchived, isFavorite: isFavorite, isOffline: isOffline, isVisible: isVisible, livePhotoData: livePhotoData, sidecarData: sidecarData, );
Future<AssetMediaResponseDto?> uploadAsset(MultipartFile assetData, String deviceAssetId, String deviceId, DateTime fileCreatedAt, DateTime fileModifiedAt, { String? key, String? xImmichChecksum, String? duration, bool? isArchived, bool? isFavorite, bool? isOffline, bool? isVisible, String? livePhotoVideoId, MultipartFile? sidecarData, }) async {
final response = await uploadAssetWithHttpInfo(assetData, deviceAssetId, deviceId, fileCreatedAt, fileModifiedAt, key: key, xImmichChecksum: xImmichChecksum, duration: duration, isArchived: isArchived, isFavorite: isFavorite, isOffline: isOffline, isVisible: isVisible, livePhotoVideoId: livePhotoVideoId, sidecarData: sidecarData, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
@@ -1023,7 +1001,70 @@ class AssetsApi {
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'AssetFileUploadResponseDto',) as AssetFileUploadResponseDto;
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'AssetMediaResponseDto',) as AssetMediaResponseDto;
}
return null;
}
/// Performs an HTTP 'GET /assets/{id}/thumbnail' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
///
/// * [String] key:
///
/// * [AssetMediaSize] size:
Future<Response> viewAssetWithHttpInfo(String id, { String? key, AssetMediaSize? size, }) async {
// ignore: prefer_const_declarations
final path = r'/assets/{id}/thumbnail'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
if (key != null) {
queryParams.addAll(_queryParams('', 'key', key));
}
if (size != null) {
queryParams.addAll(_queryParams('', 'size', size));
}
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [String] id (required):
///
/// * [String] key:
///
/// * [AssetMediaSize] size:
Future<MultipartFile?> viewAsset(String id, { String? key, AssetMediaSize? size, }) async {
final response = await viewAssetWithHttpInfo(id, key: key, size: size, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'MultipartFile',) as MultipartFile;
}
return null;

View File

@@ -71,62 +71,6 @@ class DownloadApi {
return null;
}
/// Performs an HTTP 'POST /download/asset/{id}' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
///
/// * [String] key:
Future<Response> downloadFileWithHttpInfo(String id, { String? key, }) async {
// ignore: prefer_const_declarations
final path = r'/download/asset/{id}'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
if (key != null) {
queryParams.addAll(_queryParams('', 'key', key));
}
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'POST',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [String] id (required):
///
/// * [String] key:
Future<MultipartFile?> downloadFile(String id, { String? key, }) async {
final response = await downloadFileWithHttpInfo(id, key: key, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'MultipartFile',) as MultipartFile;
}
return null;
}
/// Performs an HTTP 'POST /download/info' operation and returns the [Response].
/// Parameters:
///

View File

@@ -238,8 +238,6 @@ class ApiClient {
return AssetFaceUpdateItem.fromJson(value);
case 'AssetFaceWithoutPersonResponseDto':
return AssetFaceWithoutPersonResponseDto.fromJson(value);
case 'AssetFileUploadResponseDto':
return AssetFileUploadResponseDto.fromJson(value);
case 'AssetFullSyncDto':
return AssetFullSyncDto.fromJson(value);
case 'AssetIdsDto':
@@ -252,6 +250,8 @@ class ApiClient {
return AssetJobsDto.fromJson(value);
case 'AssetMediaResponseDto':
return AssetMediaResponseDto.fromJson(value);
case 'AssetMediaSize':
return AssetMediaSizeTypeTransformer().decode(value);
case 'AssetMediaStatus':
return AssetMediaStatusTypeTransformer().decode(value);
case 'AssetOrder':
@@ -514,8 +514,6 @@ class ApiClient {
return TagResponseDto.fromJson(value);
case 'TagTypeEnum':
return TagTypeEnumTypeTransformer().decode(value);
case 'ThumbnailFormat':
return ThumbnailFormatTypeTransformer().decode(value);
case 'TimeBucketResponseDto':
return TimeBucketResponseDto.fromJson(value);
case 'TimeBucketSize':

View File

@@ -61,6 +61,9 @@ String parameterToString(dynamic value) {
if (value is AssetJobName) {
return AssetJobNameTypeTransformer().encode(value).toString();
}
if (value is AssetMediaSize) {
return AssetMediaSizeTypeTransformer().encode(value).toString();
}
if (value is AssetMediaStatus) {
return AssetMediaStatusTypeTransformer().encode(value).toString();
}
@@ -127,9 +130,6 @@ String parameterToString(dynamic value) {
if (value is TagTypeEnum) {
return TagTypeEnumTypeTransformer().encode(value).toString();
}
if (value is ThumbnailFormat) {
return ThumbnailFormatTypeTransformer().encode(value).toString();
}
if (value is TimeBucketSize) {
return TimeBucketSizeTypeTransformer().encode(value).toString();
}

View File

@@ -1,106 +0,0 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.18
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class AssetFileUploadResponseDto {
/// Returns a new [AssetFileUploadResponseDto] instance.
AssetFileUploadResponseDto({
required this.duplicate,
required this.id,
});
bool duplicate;
String id;
@override
bool operator ==(Object other) => identical(this, other) || other is AssetFileUploadResponseDto &&
other.duplicate == duplicate &&
other.id == id;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(duplicate.hashCode) +
(id.hashCode);
@override
String toString() => 'AssetFileUploadResponseDto[duplicate=$duplicate, id=$id]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'duplicate'] = this.duplicate;
json[r'id'] = this.id;
return json;
}
/// Returns a new [AssetFileUploadResponseDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static AssetFileUploadResponseDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return AssetFileUploadResponseDto(
duplicate: mapValueOfType<bool>(json, r'duplicate')!,
id: mapValueOfType<String>(json, r'id')!,
);
}
return null;
}
static List<AssetFileUploadResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <AssetFileUploadResponseDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = AssetFileUploadResponseDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, AssetFileUploadResponseDto> mapFromJson(dynamic json) {
final map = <String, AssetFileUploadResponseDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = AssetFileUploadResponseDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of AssetFileUploadResponseDto-objects as value to a dart map
static Map<String, List<AssetFileUploadResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<AssetFileUploadResponseDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = AssetFileUploadResponseDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'duplicate',
'id',
};
}

View File

@@ -11,9 +11,9 @@
part of openapi.api;
class ThumbnailFormat {
class AssetMediaSize {
/// Instantiate a new enum with the provided [value].
const ThumbnailFormat._(this.value);
const AssetMediaSize._(this.value);
/// The underlying value of this enum member.
final String value;
@@ -23,22 +23,22 @@ class ThumbnailFormat {
String toJson() => value;
static const JPEG = ThumbnailFormat._(r'JPEG');
static const WEBP = ThumbnailFormat._(r'WEBP');
static const preview = AssetMediaSize._(r'preview');
static const thumbnail = AssetMediaSize._(r'thumbnail');
/// List of all possible values in this [enum][ThumbnailFormat].
static const values = <ThumbnailFormat>[
JPEG,
WEBP,
/// List of all possible values in this [enum][AssetMediaSize].
static const values = <AssetMediaSize>[
preview,
thumbnail,
];
static ThumbnailFormat? fromJson(dynamic value) => ThumbnailFormatTypeTransformer().decode(value);
static AssetMediaSize? fromJson(dynamic value) => AssetMediaSizeTypeTransformer().decode(value);
static List<ThumbnailFormat> listFromJson(dynamic json, {bool growable = false,}) {
final result = <ThumbnailFormat>[];
static List<AssetMediaSize> listFromJson(dynamic json, {bool growable = false,}) {
final result = <AssetMediaSize>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = ThumbnailFormat.fromJson(row);
final value = AssetMediaSize.fromJson(row);
if (value != null) {
result.add(value);
}
@@ -48,16 +48,16 @@ class ThumbnailFormat {
}
}
/// Transformation class that can [encode] an instance of [ThumbnailFormat] to String,
/// and [decode] dynamic data back to [ThumbnailFormat].
class ThumbnailFormatTypeTransformer {
factory ThumbnailFormatTypeTransformer() => _instance ??= const ThumbnailFormatTypeTransformer._();
/// Transformation class that can [encode] an instance of [AssetMediaSize] to String,
/// and [decode] dynamic data back to [AssetMediaSize].
class AssetMediaSizeTypeTransformer {
factory AssetMediaSizeTypeTransformer() => _instance ??= const AssetMediaSizeTypeTransformer._();
const ThumbnailFormatTypeTransformer._();
const AssetMediaSizeTypeTransformer._();
String encode(ThumbnailFormat data) => data.value;
String encode(AssetMediaSize data) => data.value;
/// Decodes a [dynamic value][data] to a ThumbnailFormat.
/// Decodes a [dynamic value][data] to a AssetMediaSize.
///
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
@@ -65,11 +65,11 @@ class ThumbnailFormatTypeTransformer {
///
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
/// and users are still using an old app with the old code.
ThumbnailFormat? decode(dynamic data, {bool allowNull = true}) {
AssetMediaSize? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'JPEG': return ThumbnailFormat.JPEG;
case r'WEBP': return ThumbnailFormat.WEBP;
case r'preview': return AssetMediaSize.preview;
case r'thumbnail': return AssetMediaSize.thumbnail;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
@@ -79,7 +79,7 @@ class ThumbnailFormatTypeTransformer {
return null;
}
/// Singleton [ThumbnailFormatTypeTransformer] instance.
static ThumbnailFormatTypeTransformer? _instance;
/// Singleton [AssetMediaSizeTypeTransformer] instance.
static AssetMediaSizeTypeTransformer? _instance;
}

View File

@@ -23,11 +23,13 @@ class AssetMediaStatus {
String toJson() => value;
static const created = AssetMediaStatus._(r'created');
static const replaced = AssetMediaStatus._(r'replaced');
static const duplicate = AssetMediaStatus._(r'duplicate');
/// List of all possible values in this [enum][AssetMediaStatus].
static const values = <AssetMediaStatus>[
created,
replaced,
duplicate,
];
@@ -68,6 +70,7 @@ class AssetMediaStatusTypeTransformer {
AssetMediaStatus? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'created': return AssetMediaStatus.created;
case r'replaced': return AssetMediaStatus.replaced;
case r'duplicate': return AssetMediaStatus.duplicate;
default: