import '../base.dart';

class Department extends Base {
  Department({
    this.id,
    this.departmentName,
    this.departmentCode,
    this.ntCode,
  }) : super(identifier: id.toString(), name: departmentName);

  Department.fromJson(dynamic json) {
    id = json['id'];
    identifier = id.toString();
    departmentName = json['departmentName'] ?? json['name'];
    name = departmentName;
    departmentCode = json['departmentCode'];
    ntCode = json['ntCode'];
  }

  num id;
  String departmentName;
  String departmentCode;
  String ntCode;

  Department copyWith({
    num id,
    String departmentName,
    String departmentCode,
    String ntCode,
  }) =>
      Department(
        id: id ?? this.id,
        departmentName: departmentName ?? this.departmentName,
        departmentCode: departmentCode ?? this.departmentCode,
        ntCode: ntCode ?? this.ntCode,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['departmentName'] = departmentName;
    map['departmentCode'] = departmentCode;
    map['ntCode'] = ntCode;
    return map;
  }
}
