import 'dart:convert';
import 'dart:io';

ChatUserModel chatUserModelFromJson(String str) => ChatUserModel.fromJson(json.decode(str));

String chatUserModelToJson(ChatUserModel data) => json.encode(data.toJson());

class ChatUserModel {
  ChatUserModel({
    this.response,
    this.errorResponses,
  });

  List<ChatUser>? response;
  List<ErrorResponse>? errorResponses;

  factory ChatUserModel.fromJson(Map<String, dynamic> json) => ChatUserModel(
        response: json["response"] == null ? null : List<ChatUser>.from(json["response"].map((x) => ChatUser.fromJson(x))),
        errorResponses: json["errorResponses"] == null ? null : List<ErrorResponse>.from(json["errorResponses"].map((x) => ErrorResponse.fromJson(x))),
      );

  Map<String, dynamic> toJson() => {
        "response": response == null ? null : List<dynamic>.from(response!.map((x) => x.toJson())),
        "errorResponses": errorResponses == null ? null : List<dynamic>.from(errorResponses!.map((x) => x.toJson())),
      };
}

class ErrorResponse {
  ErrorResponse({
    this.fieldName,
    this.message,
  });

  dynamic? fieldName;
  String? message;

  factory ErrorResponse.fromRawJson(String str) => ErrorResponse.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory ErrorResponse.fromJson(Map<String, dynamic> json) => ErrorResponse(
        fieldName: json["fieldName"],
        message: json["message"] == null ? null : json["message"],
      );

  Map<String, dynamic> toJson() => {
        "fieldName": fieldName,
        "message": message == null ? null : message,
      };
}

class ChatUser {
  ChatUser({
    this.id,
    this.userName,
    this.email,
    this.phone,
    this.title,
    this.userStatus,
    this.image,
    this.unreadMessageCount,
    this.userAction,
    this.isPin,
    this.isFav,
    this.isAdmin,
    this.rKey,
    this.totalCount,
    this.isTyping,
    this.isImageLoaded,
    this.isImageLoading,
    this.userLocalDownlaodedImage,
    this.isChecked
  });

  int? id;
  String? userName;
  String? email;
  dynamic? phone;
  String? title;
  int? userStatus;
  dynamic? image;
  int? unreadMessageCount;
  dynamic? userAction;
  bool? isPin;
  bool? isFav;
  bool? isAdmin;
  dynamic? rKey;
  int? totalCount;
  bool? isTyping;
  bool? isImageLoaded;
  bool? isImageLoading;
  File? userLocalDownlaodedImage;
  bool? isChecked;
  factory ChatUser.fromRawJson(String str) => ChatUser.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory ChatUser.fromJson(Map<String, dynamic> json) => ChatUser(
      id: json["id"] == null ? null : json["id"],
      userName: json["userName"] == null ? null : json["userName"],
      email: json["email"] == null ? null : json["email"],
      phone: json["phone"],
      title: json["title"] == null ? null : json["title"],
      userStatus: json["userStatus"] == null ? null : json["userStatus"],
      image: json["image"],
      unreadMessageCount: json["unreadMessageCount"] == null ? null : json["unreadMessageCount"],
      userAction: json["userAction"],
      isPin: json["isPin"] == null ? null : json["isPin"],
      isFav: json["isFav"] == null ? null : json["isFav"],
      isAdmin: json["isAdmin"] == null ? null : json["isAdmin"],
      rKey: json["rKey"],
      totalCount: json["totalCount"] == null ? null : json["totalCount"],
      isTyping: false,
      isImageLoaded: false,
      isImageLoading: true,
      userLocalDownlaodedImage: null,
      isChecked: false
  );

  Map<String, dynamic> toJson() => {
        "id": id == null ? null : id,
        "userName": userName == null ? null : userName,
        "email": email == null ? null : email,
        "phone": phone,
        "title": title == null ? null : title,
        "userStatus": userStatus == null ? null : userStatus,
        "image": image,
        "unreadMessageCount": unreadMessageCount == null ? null : unreadMessageCount,
        "userAction": userAction,
        "isPin": isPin == null ? null : isPin,
        "isFav": isFav == null ? null : isFav,
        "isAdmin": isAdmin == null ? null : isAdmin,
        "rKey": rKey,
        "totalCount": totalCount == null ? null : totalCount,
        "isChecked":isChecked
      };
}
