import 'advance_response_dto.dart';

class AdvancesListResponseDto {
  final int statusCode;
  final bool isSuccess;
  final String? message;
  final AdvancesListDataDto? data;

  AdvancesListResponseDto({
    required this.statusCode,
    required this.isSuccess,
    this.message,
    this.data,
  });

  factory AdvancesListResponseDto.fromJson(Map<String, dynamic> json) {
    return AdvancesListResponseDto(
      statusCode: json['statusCode'] ?? 0,
      isSuccess: json['isSuccess'] ?? false,
      message: json['message'],
      data: json['data'] != null ? AdvancesListDataDto.fromJson(json['data']) : null,
    );
  }
}

class AdvancesListDataDto {
  final List<AdvanceDataDto> items;
  final int pageNumber;
  final int pageSize;
  final int totalCount;
  final int totalPages;

  AdvancesListDataDto({
    required this.items,
    required this.pageNumber,
    required this.pageSize,
    required this.totalCount,
    required this.totalPages,
  });

  factory AdvancesListDataDto.fromJson(Map<String, dynamic> json) {
    return AdvancesListDataDto(
      items: json['items'] != null
          ? (json['items'] as List)
              .map((item) => AdvanceDataDto.fromJson(item))
              .toList()
          : [],
      pageNumber: json['pageNumber'] ?? 1,
      pageSize: json['pageSize'] ?? 15,
      totalCount: json['totalCount'] ?? 0,
      totalPages: json['totalPages'] ?? 1,
    );
  }
}
