sync remote asset metadata

This commit is contained in:
shenlong-tanwen
2025-08-29 15:04:37 +05:30
parent b93b07f461
commit d81ee18238
12 changed files with 799 additions and 30 deletions
@@ -0,0 +1,39 @@
import 'dart:convert';
enum RemoteAssetMetadataKey {
mobileApp("mobile-app");
final String key;
const RemoteAssetMetadataKey(this.key);
factory RemoteAssetMetadataKey.fromKey(String key) {
switch (key) {
case "mobile-app":
return RemoteAssetMetadataKey.mobileApp;
default:
throw ArgumentError("Unknown AssetMetadataKey key: $key");
}
}
}
class RemoteAssetMetadata {
final String? cloudId;
const RemoteAssetMetadata({this.cloudId});
Map<String, dynamic> toMap() {
final mobileAppValue = {};
if (cloudId != null) {
mobileAppValue["iCloudId"] = cloudId;
}
return {
"metadata": [
{"key": RemoteAssetMetadataKey.mobileApp.key, "value": mobileAppValue},
],
};
}
String toJson() => json.encode(toMap());
}
@@ -1,20 +0,0 @@
import 'dart:convert';
class AssetMetadata {
final String? cloudId;
const AssetMetadata({this.cloudId});
Map<String, dynamic> toMap() {
return {
"metadata": [
{
"key": "mobile-app",
"value": cloudId != null ? {"iCloudId": cloudId} : {},
},
],
};
}
String toJson() => json.encode(toMap());
}