ente/lib/models/api/collection/create_request.dart
2022-10-27 10:08:55 +05:30

58 lines
1.7 KiB
Dart

import 'package:photos/models/collection.dart';
import 'package:photos/services/file_magic_service.dart';
class CreateRequest {
String encryptedKey;
String keyDecryptionNonce;
String encryptedName;
String nameDecryptionNonce;
String type;
CollectionAttributes? attributes;
MetadataRequest? magicMetadata;
CreateRequest({
required this.encryptedKey,
required this.keyDecryptionNonce,
required this.encryptedName,
required this.nameDecryptionNonce,
required this.type,
this.attributes,
this.magicMetadata,
});
CreateRequest copyWith({
String? encryptedKey,
String? keyDecryptionNonce,
String? encryptedName,
String? nameDecryptionNonce,
String? type,
CollectionAttributes? attributes,
MetadataRequest? magicMetadata,
}) =>
CreateRequest(
encryptedKey: encryptedKey ?? this.encryptedKey,
keyDecryptionNonce: keyDecryptionNonce ?? this.keyDecryptionNonce,
encryptedName: encryptedName ?? this.encryptedName,
nameDecryptionNonce: nameDecryptionNonce ?? this.nameDecryptionNonce,
type: type ?? this.type,
attributes: attributes ?? this.attributes,
magicMetadata: magicMetadata ?? this.magicMetadata,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['encryptedKey'] = encryptedKey;
map['keyDecryptionNonce'] = keyDecryptionNonce;
map['encryptedName'] = encryptedName;
map['nameDecryptionNonce'] = nameDecryptionNonce;
map['type'] = type;
if (attributes != null) {
map['attributes'] = attributes!.toMap();
}
if (magicMetadata != null) {
map['magicMetadata'] = magicMetadata!.toJson();
}
return map;
}
}