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

feat: persistent memories (#8330)

* feat: persistent memories

* refactor: use new add/remove asset utility
This commit is contained in:
Jason Rasmussen
2024-04-02 10:23:17 -04:00
committed by GitHub
parent 0849dbd1af
commit cd0e537e3e
43 changed files with 3497 additions and 0 deletions

View File

@@ -39,6 +39,7 @@ part 'api/download_api.dart';
part 'api/face_api.dart';
part 'api/job_api.dart';
part 'api/library_api.dart';
part 'api/memory_api.dart';
part 'api/o_auth_api.dart';
part 'api/partner_api.dart';
part 'api/person_api.dart';
@@ -128,7 +129,11 @@ part 'model/login_response_dto.dart';
part 'model/logout_response_dto.dart';
part 'model/map_marker_response_dto.dart';
part 'model/map_theme.dart';
part 'model/memory_create_dto.dart';
part 'model/memory_lane_response_dto.dart';
part 'model/memory_response_dto.dart';
part 'model/memory_type.dart';
part 'model/memory_update_dto.dart';
part 'model/merge_person_dto.dart';
part 'model/metadata_search_dto.dart';
part 'model/model_type.dart';

359
mobile/openapi/lib/api/memory_api.dart generated Normal file
View File

@@ -0,0 +1,359 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// 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 MemoryApi {
MemoryApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
final ApiClient apiClient;
/// Performs an HTTP 'PUT /memories/{id}/assets' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
///
/// * [BulkIdsDto] bulkIdsDto (required):
Future<Response> addMemoryAssetsWithHttpInfo(String id, BulkIdsDto bulkIdsDto,) async {
// ignore: prefer_const_declarations
final path = r'/memories/{id}/assets'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody = bulkIdsDto;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>['application/json'];
return apiClient.invokeAPI(
path,
'PUT',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [String] id (required):
///
/// * [BulkIdsDto] bulkIdsDto (required):
Future<List<BulkIdResponseDto>?> addMemoryAssets(String id, BulkIdsDto bulkIdsDto,) async {
final response = await addMemoryAssetsWithHttpInfo(id, bulkIdsDto,);
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) {
final responseBody = await _decodeBodyBytes(response);
return (await apiClient.deserializeAsync(responseBody, 'List<BulkIdResponseDto>') as List)
.cast<BulkIdResponseDto>()
.toList(growable: false);
}
return null;
}
/// Performs an HTTP 'POST /memories' operation and returns the [Response].
/// Parameters:
///
/// * [MemoryCreateDto] memoryCreateDto (required):
Future<Response> createMemoryWithHttpInfo(MemoryCreateDto memoryCreateDto,) async {
// ignore: prefer_const_declarations
final path = r'/memories';
// ignore: prefer_final_locals
Object? postBody = memoryCreateDto;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>['application/json'];
return apiClient.invokeAPI(
path,
'POST',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [MemoryCreateDto] memoryCreateDto (required):
Future<MemoryResponseDto?> createMemory(MemoryCreateDto memoryCreateDto,) async {
final response = await createMemoryWithHttpInfo(memoryCreateDto,);
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), 'MemoryResponseDto',) as MemoryResponseDto;
}
return null;
}
/// Performs an HTTP 'DELETE /memories/{id}' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
Future<Response> deleteMemoryWithHttpInfo(String id,) async {
// ignore: prefer_const_declarations
final path = r'/memories/{id}'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [String] id (required):
Future<void> deleteMemory(String id,) async {
final response = await deleteMemoryWithHttpInfo(id,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
}
/// Performs an HTTP 'GET /memories/{id}' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
Future<Response> getMemoryWithHttpInfo(String id,) async {
// ignore: prefer_const_declarations
final path = r'/memories/{id}'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [String] id (required):
Future<MemoryResponseDto?> getMemory(String id,) async {
final response = await getMemoryWithHttpInfo(id,);
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), 'MemoryResponseDto',) as MemoryResponseDto;
}
return null;
}
/// Performs an HTTP 'DELETE /memories/{id}/assets' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
///
/// * [BulkIdsDto] bulkIdsDto (required):
Future<Response> removeMemoryAssetsWithHttpInfo(String id, BulkIdsDto bulkIdsDto,) async {
// ignore: prefer_const_declarations
final path = r'/memories/{id}/assets'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody = bulkIdsDto;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>['application/json'];
return apiClient.invokeAPI(
path,
'DELETE',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [String] id (required):
///
/// * [BulkIdsDto] bulkIdsDto (required):
Future<List<BulkIdResponseDto>?> removeMemoryAssets(String id, BulkIdsDto bulkIdsDto,) async {
final response = await removeMemoryAssetsWithHttpInfo(id, bulkIdsDto,);
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) {
final responseBody = await _decodeBodyBytes(response);
return (await apiClient.deserializeAsync(responseBody, 'List<BulkIdResponseDto>') as List)
.cast<BulkIdResponseDto>()
.toList(growable: false);
}
return null;
}
/// Performs an HTTP 'GET /memories' operation and returns the [Response].
Future<Response> searchMemoriesWithHttpInfo() async {
// ignore: prefer_const_declarations
final path = r'/memories';
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
Future<List<MemoryResponseDto>?> searchMemories() async {
final response = await searchMemoriesWithHttpInfo();
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) {
final responseBody = await _decodeBodyBytes(response);
return (await apiClient.deserializeAsync(responseBody, 'List<MemoryResponseDto>') as List)
.cast<MemoryResponseDto>()
.toList(growable: false);
}
return null;
}
/// Performs an HTTP 'PUT /memories/{id}' operation and returns the [Response].
/// Parameters:
///
/// * [String] id (required):
///
/// * [MemoryUpdateDto] memoryUpdateDto (required):
Future<Response> updateMemoryWithHttpInfo(String id, MemoryUpdateDto memoryUpdateDto,) async {
// ignore: prefer_const_declarations
final path = r'/memories/{id}'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody = memoryUpdateDto;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>['application/json'];
return apiClient.invokeAPI(
path,
'PUT',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
/// Parameters:
///
/// * [String] id (required):
///
/// * [MemoryUpdateDto] memoryUpdateDto (required):
Future<MemoryResponseDto?> updateMemory(String id, MemoryUpdateDto memoryUpdateDto,) async {
final response = await updateMemoryWithHttpInfo(id, memoryUpdateDto,);
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), 'MemoryResponseDto',) as MemoryResponseDto;
}
return null;
}
}

View File

@@ -336,8 +336,16 @@ class ApiClient {
return MapMarkerResponseDto.fromJson(value);
case 'MapTheme':
return MapThemeTypeTransformer().decode(value);
case 'MemoryCreateDto':
return MemoryCreateDto.fromJson(value);
case 'MemoryLaneResponseDto':
return MemoryLaneResponseDto.fromJson(value);
case 'MemoryResponseDto':
return MemoryResponseDto.fromJson(value);
case 'MemoryType':
return MemoryTypeTypeTransformer().decode(value);
case 'MemoryUpdateDto':
return MemoryUpdateDto.fromJson(value);
case 'MergePersonDto':
return MergePersonDto.fromJson(value);
case 'MetadataSearchDto':

View File

@@ -97,6 +97,9 @@ String parameterToString(dynamic value) {
if (value is MapTheme) {
return MapThemeTypeTransformer().encode(value).toString();
}
if (value is MemoryType) {
return MemoryTypeTypeTransformer().encode(value).toString();
}
if (value is ModelType) {
return ModelTypeTypeTransformer().encode(value).toString();
}

View File

@@ -0,0 +1,157 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// 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 MemoryCreateDto {
/// Returns a new [MemoryCreateDto] instance.
MemoryCreateDto({
this.assetIds = const [],
required this.data,
this.isSaved,
required this.memoryAt,
this.seenAt,
required this.type,
});
List<String> assetIds;
Object data;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
bool? isSaved;
DateTime memoryAt;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
DateTime? seenAt;
MemoryType type;
@override
bool operator ==(Object other) => identical(this, other) || other is MemoryCreateDto &&
_deepEquality.equals(other.assetIds, assetIds) &&
other.data == data &&
other.isSaved == isSaved &&
other.memoryAt == memoryAt &&
other.seenAt == seenAt &&
other.type == type;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(assetIds.hashCode) +
(data.hashCode) +
(isSaved == null ? 0 : isSaved!.hashCode) +
(memoryAt.hashCode) +
(seenAt == null ? 0 : seenAt!.hashCode) +
(type.hashCode);
@override
String toString() => 'MemoryCreateDto[assetIds=$assetIds, data=$data, isSaved=$isSaved, memoryAt=$memoryAt, seenAt=$seenAt, type=$type]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'assetIds'] = this.assetIds;
json[r'data'] = this.data;
if (this.isSaved != null) {
json[r'isSaved'] = this.isSaved;
} else {
// json[r'isSaved'] = null;
}
json[r'memoryAt'] = this.memoryAt.toUtc().toIso8601String();
if (this.seenAt != null) {
json[r'seenAt'] = this.seenAt!.toUtc().toIso8601String();
} else {
// json[r'seenAt'] = null;
}
json[r'type'] = this.type;
return json;
}
/// Returns a new [MemoryCreateDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static MemoryCreateDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return MemoryCreateDto(
assetIds: json[r'assetIds'] is Iterable
? (json[r'assetIds'] as Iterable).cast<String>().toList(growable: false)
: const [],
data: mapValueOfType<Object>(json, r'data')!,
isSaved: mapValueOfType<bool>(json, r'isSaved'),
memoryAt: mapDateTime(json, r'memoryAt', r'')!,
seenAt: mapDateTime(json, r'seenAt', r''),
type: MemoryType.fromJson(json[r'type'])!,
);
}
return null;
}
static List<MemoryCreateDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <MemoryCreateDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = MemoryCreateDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, MemoryCreateDto> mapFromJson(dynamic json) {
final map = <String, MemoryCreateDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = MemoryCreateDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of MemoryCreateDto-objects as value to a dart map
static Map<String, List<MemoryCreateDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<MemoryCreateDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = MemoryCreateDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'data',
'memoryAt',
'type',
};
}

View File

@@ -0,0 +1,267 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// 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 MemoryResponseDto {
/// Returns a new [MemoryResponseDto] instance.
MemoryResponseDto({
this.assets = const [],
required this.createdAt,
required this.data,
this.deletedAt,
required this.id,
required this.isSaved,
required this.memoryAt,
required this.ownerId,
this.seenAt,
required this.type,
required this.updatedAt,
});
List<AssetResponseDto> assets;
DateTime createdAt;
Object data;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
DateTime? deletedAt;
String id;
bool isSaved;
DateTime memoryAt;
String ownerId;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
DateTime? seenAt;
MemoryResponseDtoTypeEnum type;
DateTime updatedAt;
@override
bool operator ==(Object other) => identical(this, other) || other is MemoryResponseDto &&
_deepEquality.equals(other.assets, assets) &&
other.createdAt == createdAt &&
other.data == data &&
other.deletedAt == deletedAt &&
other.id == id &&
other.isSaved == isSaved &&
other.memoryAt == memoryAt &&
other.ownerId == ownerId &&
other.seenAt == seenAt &&
other.type == type &&
other.updatedAt == updatedAt;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(assets.hashCode) +
(createdAt.hashCode) +
(data.hashCode) +
(deletedAt == null ? 0 : deletedAt!.hashCode) +
(id.hashCode) +
(isSaved.hashCode) +
(memoryAt.hashCode) +
(ownerId.hashCode) +
(seenAt == null ? 0 : seenAt!.hashCode) +
(type.hashCode) +
(updatedAt.hashCode);
@override
String toString() => 'MemoryResponseDto[assets=$assets, createdAt=$createdAt, data=$data, deletedAt=$deletedAt, id=$id, isSaved=$isSaved, memoryAt=$memoryAt, ownerId=$ownerId, seenAt=$seenAt, type=$type, updatedAt=$updatedAt]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'assets'] = this.assets;
json[r'createdAt'] = this.createdAt.toUtc().toIso8601String();
json[r'data'] = this.data;
if (this.deletedAt != null) {
json[r'deletedAt'] = this.deletedAt!.toUtc().toIso8601String();
} else {
// json[r'deletedAt'] = null;
}
json[r'id'] = this.id;
json[r'isSaved'] = this.isSaved;
json[r'memoryAt'] = this.memoryAt.toUtc().toIso8601String();
json[r'ownerId'] = this.ownerId;
if (this.seenAt != null) {
json[r'seenAt'] = this.seenAt!.toUtc().toIso8601String();
} else {
// json[r'seenAt'] = null;
}
json[r'type'] = this.type;
json[r'updatedAt'] = this.updatedAt.toUtc().toIso8601String();
return json;
}
/// Returns a new [MemoryResponseDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static MemoryResponseDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return MemoryResponseDto(
assets: AssetResponseDto.listFromJson(json[r'assets']),
createdAt: mapDateTime(json, r'createdAt', r'')!,
data: mapValueOfType<Object>(json, r'data')!,
deletedAt: mapDateTime(json, r'deletedAt', r''),
id: mapValueOfType<String>(json, r'id')!,
isSaved: mapValueOfType<bool>(json, r'isSaved')!,
memoryAt: mapDateTime(json, r'memoryAt', r'')!,
ownerId: mapValueOfType<String>(json, r'ownerId')!,
seenAt: mapDateTime(json, r'seenAt', r''),
type: MemoryResponseDtoTypeEnum.fromJson(json[r'type'])!,
updatedAt: mapDateTime(json, r'updatedAt', r'')!,
);
}
return null;
}
static List<MemoryResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <MemoryResponseDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = MemoryResponseDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, MemoryResponseDto> mapFromJson(dynamic json) {
final map = <String, MemoryResponseDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = MemoryResponseDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of MemoryResponseDto-objects as value to a dart map
static Map<String, List<MemoryResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<MemoryResponseDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = MemoryResponseDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'assets',
'createdAt',
'data',
'id',
'isSaved',
'memoryAt',
'ownerId',
'type',
'updatedAt',
};
}
class MemoryResponseDtoTypeEnum {
/// Instantiate a new enum with the provided [value].
const MemoryResponseDtoTypeEnum._(this.value);
/// The underlying value of this enum member.
final String value;
@override
String toString() => value;
String toJson() => value;
static const onThisDay = MemoryResponseDtoTypeEnum._(r'on_this_day');
/// List of all possible values in this [enum][MemoryResponseDtoTypeEnum].
static const values = <MemoryResponseDtoTypeEnum>[
onThisDay,
];
static MemoryResponseDtoTypeEnum? fromJson(dynamic value) => MemoryResponseDtoTypeEnumTypeTransformer().decode(value);
static List<MemoryResponseDtoTypeEnum> listFromJson(dynamic json, {bool growable = false,}) {
final result = <MemoryResponseDtoTypeEnum>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = MemoryResponseDtoTypeEnum.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
}
/// Transformation class that can [encode] an instance of [MemoryResponseDtoTypeEnum] to String,
/// and [decode] dynamic data back to [MemoryResponseDtoTypeEnum].
class MemoryResponseDtoTypeEnumTypeTransformer {
factory MemoryResponseDtoTypeEnumTypeTransformer() => _instance ??= const MemoryResponseDtoTypeEnumTypeTransformer._();
const MemoryResponseDtoTypeEnumTypeTransformer._();
String encode(MemoryResponseDtoTypeEnum data) => data.value;
/// Decodes a [dynamic value][data] to a MemoryResponseDtoTypeEnum.
///
/// 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]
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
///
/// 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.
MemoryResponseDtoTypeEnum? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'on_this_day': return MemoryResponseDtoTypeEnum.onThisDay;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
}
return null;
}
/// Singleton [MemoryResponseDtoTypeEnumTypeTransformer] instance.
static MemoryResponseDtoTypeEnumTypeTransformer? _instance;
}

View File

@@ -0,0 +1,82 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// 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 MemoryType {
/// Instantiate a new enum with the provided [value].
const MemoryType._(this.value);
/// The underlying value of this enum member.
final String value;
@override
String toString() => value;
String toJson() => value;
static const onThisDay = MemoryType._(r'on_this_day');
/// List of all possible values in this [enum][MemoryType].
static const values = <MemoryType>[
onThisDay,
];
static MemoryType? fromJson(dynamic value) => MemoryTypeTypeTransformer().decode(value);
static List<MemoryType> listFromJson(dynamic json, {bool growable = false,}) {
final result = <MemoryType>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = MemoryType.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
}
/// Transformation class that can [encode] an instance of [MemoryType] to String,
/// and [decode] dynamic data back to [MemoryType].
class MemoryTypeTypeTransformer {
factory MemoryTypeTypeTransformer() => _instance ??= const MemoryTypeTypeTransformer._();
const MemoryTypeTypeTransformer._();
String encode(MemoryType data) => data.value;
/// Decodes a [dynamic value][data] to a MemoryType.
///
/// 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]
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
///
/// 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.
MemoryType? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'on_this_day': return MemoryType.onThisDay;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
}
return null;
}
/// Singleton [MemoryTypeTypeTransformer] instance.
static MemoryTypeTypeTransformer? _instance;
}

View File

@@ -0,0 +1,141 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// 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 MemoryUpdateDto {
/// Returns a new [MemoryUpdateDto] instance.
MemoryUpdateDto({
this.isSaved,
this.memoryAt,
this.seenAt,
});
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
bool? isSaved;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
DateTime? memoryAt;
///
/// Please note: This property should have been non-nullable! Since the specification file
/// does not include a default value (using the "default:" property), however, the generated
/// source code must fall back to having a nullable type.
/// Consider adding a "default:" property in the specification file to hide this note.
///
DateTime? seenAt;
@override
bool operator ==(Object other) => identical(this, other) || other is MemoryUpdateDto &&
other.isSaved == isSaved &&
other.memoryAt == memoryAt &&
other.seenAt == seenAt;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(isSaved == null ? 0 : isSaved!.hashCode) +
(memoryAt == null ? 0 : memoryAt!.hashCode) +
(seenAt == null ? 0 : seenAt!.hashCode);
@override
String toString() => 'MemoryUpdateDto[isSaved=$isSaved, memoryAt=$memoryAt, seenAt=$seenAt]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
if (this.isSaved != null) {
json[r'isSaved'] = this.isSaved;
} else {
// json[r'isSaved'] = null;
}
if (this.memoryAt != null) {
json[r'memoryAt'] = this.memoryAt!.toUtc().toIso8601String();
} else {
// json[r'memoryAt'] = null;
}
if (this.seenAt != null) {
json[r'seenAt'] = this.seenAt!.toUtc().toIso8601String();
} else {
// json[r'seenAt'] = null;
}
return json;
}
/// Returns a new [MemoryUpdateDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static MemoryUpdateDto? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
return MemoryUpdateDto(
isSaved: mapValueOfType<bool>(json, r'isSaved'),
memoryAt: mapDateTime(json, r'memoryAt', r''),
seenAt: mapDateTime(json, r'seenAt', r''),
);
}
return null;
}
static List<MemoryUpdateDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <MemoryUpdateDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = MemoryUpdateDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, MemoryUpdateDto> mapFromJson(dynamic json) {
final map = <String, MemoryUpdateDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = MemoryUpdateDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of MemoryUpdateDto-objects as value to a dart map
static Map<String, List<MemoryUpdateDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<MemoryUpdateDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = MemoryUpdateDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
};
}