Prechádzať zdrojové kódy

Add model for createColleciton request

Neeraj Gupta 2 rokov pred
rodič
commit
e5742f6b1b
1 zmenil súbory, kde vykonal 57 pridanie a 0 odobranie
  1. 57 0
      lib/models/api/collection/create_request.dart

+ 57 - 0
lib/models/api/collection/create_request.dart

@@ -0,0 +1,57 @@
+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;
+  }
+}