readStorageObject method
Reading storage objects
Define a class that describes the storage object and create a new storage object id with the collection name, key and user id. Finally, read the storage objects and parse the JSON data:
Implementation
@override
Future<model.StorageObject?> readStorageObject({
required model.Session session,
String? collection,
String? key,
String? userId,
}) async {
_session = session;
final res = await _api.v2StoragePost(
body: ApiReadStorageObjectsRequest(
objectIds: [
ApiReadStorageObjectId(
collection: collection,
key: key,
userId: userId,
),
],
),
);
return res.body?.objects?.isEmpty != false ? null : model.StorageObject.fromJson(res.body!.objects!.first.toJson());
}