class OrganizationListResponse {
  final bool success;
  final String message;
  final List<Organization> data;
  final dynamic errors;
  final int statusCode;
  final String timestamp;

  OrganizationListResponse({
    required this.success,
    required this.message,
    required this.data,
    this.errors,
    required this.statusCode,
    required this.timestamp,
  });

  factory OrganizationListResponse.fromJson(Map<String, dynamic> json) {
    return OrganizationListResponse(
      success: json['success'] ?? false,
      message: json['message'] ?? '',
      data: (json['data'] as List<dynamic>?)
              ?.map((e) => Organization.fromJson(e))
              .toList() ??
          [],
      errors: json['errors'],
      statusCode: json['statusCode'] ?? 0,
      timestamp: json['timestamp'] ?? '',
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'success': success,
      'message': message,
      'data': data.map((e) => e.toJson()).toList(),
      'errors': errors,
      'statusCode': statusCode,
      'timestamp': timestamp,
    };
  }
}

class Organization {
  final String id;
  final String name;
  final String email;
  final String contactPerson;
  final String address;
  final String contactNumber;
  final int sprid;
  final String createdAt;
  final dynamic createdBy;
  final dynamic updatedBy;
  final dynamic updatedAt;
  final bool isActive;

  Organization({
    required this.id,
    required this.name,
    required this.email,
    required this.contactPerson,
    required this.address,
    required this.contactNumber,
    required this.sprid,
    required this.createdAt,
    this.createdBy,
    this.updatedBy,
    this.updatedAt,
    required this.isActive,
  });

  factory Organization.fromJson(Map<String, dynamic> json) {
    return Organization(
      id: json['id'] ?? '',
      name: json['name'] ?? '',
      email: json['email'] ?? '',
      contactPerson: json['contactPerson'] ?? '',
      address: json['address'] ?? '',
      contactNumber: json['contactNumber'] ?? '',
      sprid: json['sprid'] ?? 0,
      createdAt: json['createdAt'] ?? '',
      createdBy: json['createdBy'],
      updatedBy: json['updatedBy'],
      updatedAt: json['updatedAt'],
      isActive: json['isActive'] ?? false,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'email': email,
      'contactPerson': contactPerson,
      'address': address,
      'contactNumber': contactNumber,
      'sprid': sprid,
      'createdAt': createdAt,
      'createdBy': createdBy,
      'updatedBy': updatedBy,
      'updatedAt': updatedAt,
      'isActive': isActive,
    };
  }
}
