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

feat: sync implementation for the user entity (#16234)

* ci: print out typeorm generation changes

* feat: sync implementation for the user entity

wip

---------

Co-authored-by: Jason Rasmussen <jason@rasm.me>
This commit is contained in:
Zack Pollard
2025-02-21 04:37:57 +00:00
committed by GitHub
parent 02cd8da871
commit ac36effb45
38 changed files with 1774 additions and 10 deletions

View File

@ -226,6 +226,14 @@ part 'model/source_type.dart';
part 'model/stack_create_dto.dart';
part 'model/stack_response_dto.dart';
part 'model/stack_update_dto.dart';
part 'model/sync_ack_delete_dto.dart';
part 'model/sync_ack_dto.dart';
part 'model/sync_ack_set_dto.dart';
part 'model/sync_entity_type.dart';
part 'model/sync_request_type.dart';
part 'model/sync_stream_dto.dart';
part 'model/sync_user_delete_v1.dart';
part 'model/sync_user_v1.dart';
part 'model/system_config_backups_dto.dart';
part 'model/system_config_dto.dart';
part 'model/system_config_f_fmpeg_dto.dart';

View File

@ -16,6 +16,45 @@ class SyncApi {
final ApiClient apiClient;
/// Performs an HTTP 'DELETE /sync/ack' operation and returns the [Response].
/// Parameters:
///
/// * [SyncAckDeleteDto] syncAckDeleteDto (required):
Future<Response> deleteSyncAckWithHttpInfo(SyncAckDeleteDto syncAckDeleteDto,) async {
// ignore: prefer_const_declarations
final path = r'/sync/ack';
// ignore: prefer_final_locals
Object? postBody = syncAckDeleteDto;
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:
///
/// * [SyncAckDeleteDto] syncAckDeleteDto (required):
Future<void> deleteSyncAck(SyncAckDeleteDto syncAckDeleteDto,) async {
final response = await deleteSyncAckWithHttpInfo(syncAckDeleteDto,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
}
/// Performs an HTTP 'POST /sync/delta-sync' operation and returns the [Response].
/// Parameters:
///
@ -112,4 +151,126 @@ class SyncApi {
}
return null;
}
/// Performs an HTTP 'GET /sync/ack' operation and returns the [Response].
Future<Response> getSyncAckWithHttpInfo() async {
// ignore: prefer_const_declarations
final path = r'/sync/ack';
// 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<SyncAckDto>?> getSyncAck() async {
final response = await getSyncAckWithHttpInfo();
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<SyncAckDto>') as List)
.cast<SyncAckDto>()
.toList(growable: false);
}
return null;
}
/// Performs an HTTP 'POST /sync/stream' operation and returns the [Response].
/// Parameters:
///
/// * [SyncStreamDto] syncStreamDto (required):
Future<Response> getSyncStreamWithHttpInfo(SyncStreamDto syncStreamDto,) async {
// ignore: prefer_const_declarations
final path = r'/sync/stream';
// ignore: prefer_final_locals
Object? postBody = syncStreamDto;
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:
///
/// * [SyncStreamDto] syncStreamDto (required):
Future<void> getSyncStream(SyncStreamDto syncStreamDto,) async {
final response = await getSyncStreamWithHttpInfo(syncStreamDto,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
}
/// Performs an HTTP 'POST /sync/ack' operation and returns the [Response].
/// Parameters:
///
/// * [SyncAckSetDto] syncAckSetDto (required):
Future<Response> sendSyncAckWithHttpInfo(SyncAckSetDto syncAckSetDto,) async {
// ignore: prefer_const_declarations
final path = r'/sync/ack';
// ignore: prefer_final_locals
Object? postBody = syncAckSetDto;
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:
///
/// * [SyncAckSetDto] syncAckSetDto (required):
Future<void> sendSyncAck(SyncAckSetDto syncAckSetDto,) async {
final response = await sendSyncAckWithHttpInfo(syncAckSetDto,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
}
}

View File

@ -508,6 +508,22 @@ class ApiClient {
return StackResponseDto.fromJson(value);
case 'StackUpdateDto':
return StackUpdateDto.fromJson(value);
case 'SyncAckDeleteDto':
return SyncAckDeleteDto.fromJson(value);
case 'SyncAckDto':
return SyncAckDto.fromJson(value);
case 'SyncAckSetDto':
return SyncAckSetDto.fromJson(value);
case 'SyncEntityType':
return SyncEntityTypeTypeTransformer().decode(value);
case 'SyncRequestType':
return SyncRequestTypeTypeTransformer().decode(value);
case 'SyncStreamDto':
return SyncStreamDto.fromJson(value);
case 'SyncUserDeleteV1':
return SyncUserDeleteV1.fromJson(value);
case 'SyncUserV1':
return SyncUserV1.fromJson(value);
case 'SystemConfigBackupsDto':
return SystemConfigBackupsDto.fromJson(value);
case 'SystemConfigDto':

View File

@ -127,6 +127,12 @@ String parameterToString(dynamic value) {
if (value is SourceType) {
return SourceTypeTypeTransformer().encode(value).toString();
}
if (value is SyncEntityType) {
return SyncEntityTypeTypeTransformer().encode(value).toString();
}
if (value is SyncRequestType) {
return SyncRequestTypeTypeTransformer().encode(value).toString();
}
if (value is TimeBucketSize) {
return TimeBucketSizeTypeTransformer().encode(value).toString();
}

View File

@ -0,0 +1,98 @@
//
// 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 SyncAckDeleteDto {
/// Returns a new [SyncAckDeleteDto] instance.
SyncAckDeleteDto({
this.types = const [],
});
List<SyncEntityType> types;
@override
bool operator ==(Object other) => identical(this, other) || other is SyncAckDeleteDto &&
_deepEquality.equals(other.types, types);
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(types.hashCode);
@override
String toString() => 'SyncAckDeleteDto[types=$types]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'types'] = this.types;
return json;
}
/// Returns a new [SyncAckDeleteDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static SyncAckDeleteDto? fromJson(dynamic value) {
upgradeDto(value, "SyncAckDeleteDto");
if (value is Map) {
final json = value.cast<String, dynamic>();
return SyncAckDeleteDto(
types: SyncEntityType.listFromJson(json[r'types']),
);
}
return null;
}
static List<SyncAckDeleteDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SyncAckDeleteDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SyncAckDeleteDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, SyncAckDeleteDto> mapFromJson(dynamic json) {
final map = <String, SyncAckDeleteDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = SyncAckDeleteDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of SyncAckDeleteDto-objects as value to a dart map
static Map<String, List<SyncAckDeleteDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<SyncAckDeleteDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = SyncAckDeleteDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
};
}

107
mobile/openapi/lib/model/sync_ack_dto.dart generated Normal file
View File

@ -0,0 +1,107 @@
//
// 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 SyncAckDto {
/// Returns a new [SyncAckDto] instance.
SyncAckDto({
required this.ack,
required this.type,
});
String ack;
SyncEntityType type;
@override
bool operator ==(Object other) => identical(this, other) || other is SyncAckDto &&
other.ack == ack &&
other.type == type;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(ack.hashCode) +
(type.hashCode);
@override
String toString() => 'SyncAckDto[ack=$ack, type=$type]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'ack'] = this.ack;
json[r'type'] = this.type;
return json;
}
/// Returns a new [SyncAckDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static SyncAckDto? fromJson(dynamic value) {
upgradeDto(value, "SyncAckDto");
if (value is Map) {
final json = value.cast<String, dynamic>();
return SyncAckDto(
ack: mapValueOfType<String>(json, r'ack')!,
type: SyncEntityType.fromJson(json[r'type'])!,
);
}
return null;
}
static List<SyncAckDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SyncAckDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SyncAckDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, SyncAckDto> mapFromJson(dynamic json) {
final map = <String, SyncAckDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = SyncAckDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of SyncAckDto-objects as value to a dart map
static Map<String, List<SyncAckDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<SyncAckDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = SyncAckDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'ack',
'type',
};
}

View File

@ -0,0 +1,101 @@
//
// 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 SyncAckSetDto {
/// Returns a new [SyncAckSetDto] instance.
SyncAckSetDto({
this.acks = const [],
});
List<String> acks;
@override
bool operator ==(Object other) => identical(this, other) || other is SyncAckSetDto &&
_deepEquality.equals(other.acks, acks);
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(acks.hashCode);
@override
String toString() => 'SyncAckSetDto[acks=$acks]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'acks'] = this.acks;
return json;
}
/// Returns a new [SyncAckSetDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static SyncAckSetDto? fromJson(dynamic value) {
upgradeDto(value, "SyncAckSetDto");
if (value is Map) {
final json = value.cast<String, dynamic>();
return SyncAckSetDto(
acks: json[r'acks'] is Iterable
? (json[r'acks'] as Iterable).cast<String>().toList(growable: false)
: const [],
);
}
return null;
}
static List<SyncAckSetDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SyncAckSetDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SyncAckSetDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, SyncAckSetDto> mapFromJson(dynamic json) {
final map = <String, SyncAckSetDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = SyncAckSetDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of SyncAckSetDto-objects as value to a dart map
static Map<String, List<SyncAckSetDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<SyncAckSetDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = SyncAckSetDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'acks',
};
}

View File

@ -0,0 +1,85 @@
//
// 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 SyncEntityType {
/// Instantiate a new enum with the provided [value].
const SyncEntityType._(this.value);
/// The underlying value of this enum member.
final String value;
@override
String toString() => value;
String toJson() => value;
static const userV1 = SyncEntityType._(r'UserV1');
static const userDeleteV1 = SyncEntityType._(r'UserDeleteV1');
/// List of all possible values in this [enum][SyncEntityType].
static const values = <SyncEntityType>[
userV1,
userDeleteV1,
];
static SyncEntityType? fromJson(dynamic value) => SyncEntityTypeTypeTransformer().decode(value);
static List<SyncEntityType> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SyncEntityType>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SyncEntityType.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
}
/// Transformation class that can [encode] an instance of [SyncEntityType] to String,
/// and [decode] dynamic data back to [SyncEntityType].
class SyncEntityTypeTypeTransformer {
factory SyncEntityTypeTypeTransformer() => _instance ??= const SyncEntityTypeTypeTransformer._();
const SyncEntityTypeTypeTransformer._();
String encode(SyncEntityType data) => data.value;
/// Decodes a [dynamic value][data] to a SyncEntityType.
///
/// 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.
SyncEntityType? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'UserV1': return SyncEntityType.userV1;
case r'UserDeleteV1': return SyncEntityType.userDeleteV1;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
}
return null;
}
/// Singleton [SyncEntityTypeTypeTransformer] instance.
static SyncEntityTypeTypeTransformer? _instance;
}

View File

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

View File

@ -0,0 +1,99 @@
//
// 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 SyncStreamDto {
/// Returns a new [SyncStreamDto] instance.
SyncStreamDto({
this.types = const [],
});
List<SyncRequestType> types;
@override
bool operator ==(Object other) => identical(this, other) || other is SyncStreamDto &&
_deepEquality.equals(other.types, types);
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(types.hashCode);
@override
String toString() => 'SyncStreamDto[types=$types]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'types'] = this.types;
return json;
}
/// Returns a new [SyncStreamDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static SyncStreamDto? fromJson(dynamic value) {
upgradeDto(value, "SyncStreamDto");
if (value is Map) {
final json = value.cast<String, dynamic>();
return SyncStreamDto(
types: SyncRequestType.listFromJson(json[r'types']),
);
}
return null;
}
static List<SyncStreamDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SyncStreamDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SyncStreamDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, SyncStreamDto> mapFromJson(dynamic json) {
final map = <String, SyncStreamDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = SyncStreamDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of SyncStreamDto-objects as value to a dart map
static Map<String, List<SyncStreamDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<SyncStreamDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = SyncStreamDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'types',
};
}

View File

@ -0,0 +1,99 @@
//
// 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 SyncUserDeleteV1 {
/// Returns a new [SyncUserDeleteV1] instance.
SyncUserDeleteV1({
required this.userId,
});
String userId;
@override
bool operator ==(Object other) => identical(this, other) || other is SyncUserDeleteV1 &&
other.userId == userId;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(userId.hashCode);
@override
String toString() => 'SyncUserDeleteV1[userId=$userId]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'userId'] = this.userId;
return json;
}
/// Returns a new [SyncUserDeleteV1] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static SyncUserDeleteV1? fromJson(dynamic value) {
upgradeDto(value, "SyncUserDeleteV1");
if (value is Map) {
final json = value.cast<String, dynamic>();
return SyncUserDeleteV1(
userId: mapValueOfType<String>(json, r'userId')!,
);
}
return null;
}
static List<SyncUserDeleteV1> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SyncUserDeleteV1>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SyncUserDeleteV1.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, SyncUserDeleteV1> mapFromJson(dynamic json) {
final map = <String, SyncUserDeleteV1>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = SyncUserDeleteV1.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of SyncUserDeleteV1-objects as value to a dart map
static Map<String, List<SyncUserDeleteV1>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<SyncUserDeleteV1>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = SyncUserDeleteV1.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'userId',
};
}

127
mobile/openapi/lib/model/sync_user_v1.dart generated Normal file
View File

@ -0,0 +1,127 @@
//
// 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 SyncUserV1 {
/// Returns a new [SyncUserV1] instance.
SyncUserV1({
required this.deletedAt,
required this.email,
required this.id,
required this.name,
});
DateTime? deletedAt;
String email;
String id;
String name;
@override
bool operator ==(Object other) => identical(this, other) || other is SyncUserV1 &&
other.deletedAt == deletedAt &&
other.email == email &&
other.id == id &&
other.name == name;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(deletedAt == null ? 0 : deletedAt!.hashCode) +
(email.hashCode) +
(id.hashCode) +
(name.hashCode);
@override
String toString() => 'SyncUserV1[deletedAt=$deletedAt, email=$email, id=$id, name=$name]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
if (this.deletedAt != null) {
json[r'deletedAt'] = this.deletedAt!.toUtc().toIso8601String();
} else {
// json[r'deletedAt'] = null;
}
json[r'email'] = this.email;
json[r'id'] = this.id;
json[r'name'] = this.name;
return json;
}
/// Returns a new [SyncUserV1] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static SyncUserV1? fromJson(dynamic value) {
upgradeDto(value, "SyncUserV1");
if (value is Map) {
final json = value.cast<String, dynamic>();
return SyncUserV1(
deletedAt: mapDateTime(json, r'deletedAt', r''),
email: mapValueOfType<String>(json, r'email')!,
id: mapValueOfType<String>(json, r'id')!,
name: mapValueOfType<String>(json, r'name')!,
);
}
return null;
}
static List<SyncUserV1> listFromJson(dynamic json, {bool growable = false,}) {
final result = <SyncUserV1>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = SyncUserV1.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, SyncUserV1> mapFromJson(dynamic json) {
final map = <String, SyncUserV1>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = SyncUserV1.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of SyncUserV1-objects as value to a dart map
static Map<String, List<SyncUserV1>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<SyncUserV1>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = SyncUserV1.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'deletedAt',
'email',
'id',
'name',
};
}