create_request.dart 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import 'package:photos/models/collection.dart';
  2. import 'package:photos/services/file_magic_service.dart';
  3. class CreateRequest {
  4. String encryptedKey;
  5. String keyDecryptionNonce;
  6. String encryptedName;
  7. String nameDecryptionNonce;
  8. CollectionType type;
  9. CollectionAttributes? attributes;
  10. MetadataRequest? magicMetadata;
  11. CreateRequest({
  12. required this.encryptedKey,
  13. required this.keyDecryptionNonce,
  14. required this.encryptedName,
  15. required this.nameDecryptionNonce,
  16. required this.type,
  17. this.attributes,
  18. this.magicMetadata,
  19. });
  20. CreateRequest copyWith({
  21. String? encryptedKey,
  22. String? keyDecryptionNonce,
  23. String? encryptedName,
  24. String? nameDecryptionNonce,
  25. CollectionType? type,
  26. CollectionAttributes? attributes,
  27. MetadataRequest? magicMetadata,
  28. }) =>
  29. CreateRequest(
  30. encryptedKey: encryptedKey ?? this.encryptedKey,
  31. keyDecryptionNonce: keyDecryptionNonce ?? this.keyDecryptionNonce,
  32. encryptedName: encryptedName ?? this.encryptedName,
  33. nameDecryptionNonce: nameDecryptionNonce ?? this.nameDecryptionNonce,
  34. type: type ?? this.type,
  35. attributes: attributes ?? this.attributes,
  36. magicMetadata: magicMetadata ?? this.magicMetadata,
  37. );
  38. Map<String, dynamic> toJson() {
  39. final map = <String, dynamic>{};
  40. map['encryptedKey'] = encryptedKey;
  41. map['keyDecryptionNonce'] = keyDecryptionNonce;
  42. map['encryptedName'] = encryptedName;
  43. map['nameDecryptionNonce'] = nameDecryptionNonce;
  44. map['type'] = Collection.typeToString(type);
  45. if (attributes != null) {
  46. map['attributes'] = attributes!.toMap();
  47. }
  48. if (magicMetadata != null) {
  49. map['magicMetadata'] = magicMetadata!.toJson();
  50. }
  51. return map;
  52. }
  53. }