import 'package:domain/generated/json/base/json_convert_content.dart';
import 'package:domain/entity/response/position_table_entity.dart';

PositionTableEntity $PositionTableEntityFromJson(Map<String, dynamic> json) {
  final PositionTableEntity positionTableEntity = PositionTableEntity();
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    positionTableEntity.total = total;
  }
  final List<PositionTableRows>? rows = (json['rows'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<PositionTableRows>(e) as PositionTableRows).toList();
  if (rows != null) {
    positionTableEntity.rows = rows;
  }
  return positionTableEntity;
}

Map<String, dynamic> $PositionTableEntityToJson(PositionTableEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['total'] = entity.total;
  data['rows'] = entity.rows.map((v) => v.toJson()).toList();
  return data;
}

extension PositionTableEntityExtension on PositionTableEntity {
  PositionTableEntity copyWith({
    int? total,
    List<PositionTableRows>? rows,
  }) {
    return PositionTableEntity()
      ..total = total ?? this.total
      ..rows = rows ?? this.rows;
  }
}

PositionTableRows $PositionTableRowsFromJson(Map<String, dynamic> json) {
  final PositionTableRows positionTableRows = PositionTableRows();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    positionTableRows.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    positionTableRows.name = name;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    positionTableRows.createdAt = createdAt;
  }
  final String? updatedAt = jsonConvert.convert<String>(json['updated_at']);
  if (updatedAt != null) {
    positionTableRows.updatedAt = updatedAt;
  }
  return positionTableRows;
}

Map<String, dynamic> $PositionTableRowsToJson(PositionTableRows entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['created_at'] = entity.createdAt;
  data['updated_at'] = entity.updatedAt;
  return data;
}

extension PositionTableRowsExtension on PositionTableRows {
  PositionTableRows copyWith({
    String? id,
    String? name,
    String? createdAt,
    String? updatedAt,
  }) {
    return PositionTableRows()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..createdAt = createdAt ?? this.createdAt
      ..updatedAt = updatedAt ?? this.updatedAt;
  }
}