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

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

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

extension THOAAttachmentEntityExtension on THOAAttachmentEntity {
  THOAAttachmentEntity copyWith({
    int? total,
    List<THOAAttachmentRows>? rows,
  }) {
    return THOAAttachmentEntity()
      ..total = total ?? this.total
      ..rows = rows ?? this.rows;
  }
}

THOAAttachmentRows $THOAAttachmentRowsFromJson(Map<String, dynamic> json) {
  final THOAAttachmentRows tHOAAttachmentRows = THOAAttachmentRows();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    tHOAAttachmentRows.id = id;
  }
  final String? attUrl = jsonConvert.convert<String>(json['att_url']);
  if (attUrl != null) {
    tHOAAttachmentRows.attUrl = attUrl;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    tHOAAttachmentRows.createdAt = createdAt;
  }
  return tHOAAttachmentRows;
}

Map<String, dynamic> $THOAAttachmentRowsToJson(THOAAttachmentRows entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['att_url'] = entity.attUrl;
  data['created_at'] = entity.createdAt;
  return data;
}

extension THOAAttachmentRowsExtension on THOAAttachmentRows {
  THOAAttachmentRows copyWith({
    String? id,
    String? attUrl,
    String? createdAt,
  }) {
    return THOAAttachmentRows()
      ..id = id ?? this.id
      ..attUrl = attUrl ?? this.attUrl
      ..createdAt = createdAt ?? this.createdAt;
  }
}