class PagedResult<T> {
  final int? totalElements;
  final List<T> results;

  PagedResult({this.totalElements, required this.results});

  factory PagedResult.fromJson(Map<String, dynamic> json, object) {
    final items = json['content'].cast<Map<String, dynamic>>();
    final listItems =
        List<T>.from(items.map((itemsJson) => object.fromJson(itemsJson)));
    final total = json['totalElements'] as num;
    return PagedResult<T>(totalElements: total.toInt(), results: listItems);
  }
}
