get method

Gets contents of a directory. @returns Directory data and content (files and subfolders)

Implementation

Future<List<ApillonModel>> get({IStorageBucketContentRequest? params}) async {
  content = [];
  params ??= IStorageBucketContentRequest();
  params.directoryUuid = uuid;
  final url =
      constructUrlWithQueryParams('$apiPrefix/content', params.toJson());
  final data = await ApillonApi.get<IApillonList<dynamic>>(url,
      mapper: IApillonList.fromJson);

  for (final json in data.items) {
    if (json["type"] == StorageContentType.FILE.value) {
      content.add(File(uuid, json["directoryUuid"], json["uuid"], json));
    } else {
      content.add(Directory(bucketUuid, json["uuid"], data: json));
    }
  }
  return content;
}