import '../../CommitmentEvent.dart';

class CommitmentEventPage {
  int number;

  int size;

  int totalElements;

  int totalPages;

  int numberOfElements;

  bool first;

  bool last;

  List<CommitmentEvent> content;

  CommitmentEventPage({
    this.number = 0,
    this.size = 0,
    this.totalElements = 0,
    this.totalPages = 0,
    this.numberOfElements = 0,
    this.first = true,
    this.last = true,
    List<CommitmentEvent>? content,
  }) : content = content ?? <CommitmentEvent>[];

  factory CommitmentEventPage.fromJson(Map<String, dynamic> json) {
    return CommitmentEventPage(
      number: json['number'] ?? 0,
      size: json['size'] ?? 0,
      totalElements: json['totalElements'] ?? 0,
      totalPages: json['totalPages'] ?? 0,
      numberOfElements: json['numberOfElements'] ?? 0,
      first: json['first'] ?? true,
      last: json['last'] ?? true,
      content: json['content'] == null
          ? <CommitmentEvent>[]
          : (json['content'] as List)
              .map((item) => CommitmentEvent.fromJson(item))
              .toList(),
    );
  }
}
