
import 'dart:convert';

import 'simple_business.dart';

class TicketFile {
  int? id;
  String? url;
  String? fileName;
  String? fileType;

  TicketFile.fromJson(Map<String, dynamic> json)
    : id = json['id'],
      url = json['url'],
      fileName = json['file_name'],
      fileType = json['file_type'];

  Map<String, dynamic> toJson() => {
    'id': id,
    'url': url,
    'file_name': fileName,
    'file_type': fileType,
  };

  @override
  String toString() {
    return json.encode(this);
  }
}

class Issue {
  int? id;
  String? msg;
  List<TicketFile>? files;

  Issue.fromJson(Map<String, dynamic> json)
    : id = json['id'],
      msg = json['msg'],
      files = (json['files'] as List).map((e) => TicketFile.fromJson(e)).toList();

  Map<String, dynamic> toJson() => {
    'id': id,
    'msg': msg,
    'files': files,
  };

  @override
  String toString() {
    return json.encode(this);
  }
}

class FollowUp {
  int? id;
  String? msg;
  String? poster;
  String? createdAt;
  List<TicketFile>? files;

  FollowUp.fromJson(Map<String, dynamic> json)
    : id = json['id'],
      msg = json['msg'],
      poster = json['poster'],
      createdAt = json['created_at'],
      files = (json['files'] as List).map((e) => TicketFile.fromJson(e)).toList();

  Map<String, dynamic> toJson() => {
    'id': id,
    'msg': msg,
    'poster': poster,
    'created_at': createdAt,
    'files': files
  };

  @override
  String toString() {
    return json.encode(this);
  }
}

class Ticket {
  int? id;
  Issue? issue;
  Store? store;
  List<FollowUp>? followUps;
  bool? isClosed;
  String? createdAt;

  Ticket.fromJson(Map<String, dynamic> json)
    : id = json['id'],
      issue = Issue.fromJson(json['issue']),
      store = Store.fromJson(json['store']),
      followUps = (json['follow_ups'] as List).map((e) => FollowUp.fromJson(e)).toList(),
      isClosed = json['is_closed'],
      createdAt = json['created_at'];

  Map<String, dynamic> toJson() => {
    'id': id,
    'issue': issue,
    'store': store,
    'follow_ups': followUps,
    'is_closed': isClosed,
    'created_at': createdAt,
  };

  @override
  String toString() {
    return json.encode(this);
  }
}