import 'dart:convert';

class GetUserGroups {
  List<GroupResponse>? groupresponse;
  Null? errorResponses;

  GetUserGroups({this.groupresponse, this.errorResponses});
  factory GetUserGroups.fromRawJson(String str) => GetUserGroups.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());
  GetUserGroups.fromJson(Map<String, dynamic> json) {
    if (json['response'] != null) {
      groupresponse = <GroupResponse>[];
      json['response'].forEach((v) {
      if(v['isDeleted'] == false)
        groupresponse!.add(new GroupResponse.fromJson(v));
      });
    }
    errorResponses = json['errorResponses'];
  }

  Map<String, dynamic> toJson() {
     Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.groupresponse != null) {
      data['response'] = this.groupresponse!.map((v) => v.toJson()).toList();
    }
    data['errorResponses'] = this.errorResponses;
    return data;
  }
}

class GroupResponse {
  int? groupId;
  String? groupName;
  Null? groupIcon;
  bool? isDeleted;
  bool? isAdmin;
  bool? canVideoC;
  bool? canAudioC;
  bool? canShareS;
  bool? canAttach;
  bool? canArchive;
  bool? isMeeting;
  Null? meetingTime;
  Null? extUserLink;
  int? callStatus;
  int? groupUnreadMessageCount;
  AdminUser? adminUser;
  List<GroupUserList>? groupUserList;

  GroupResponse(
      {this.groupId,
        this.groupName,
        this.groupIcon,
        this.isDeleted,
        this.isAdmin,
        this.canVideoC,
        this.canAudioC,
        this.canShareS,
        this.canAttach,
        this.canArchive,
        this.isMeeting,
        this.meetingTime,
        this.extUserLink,
        this.callStatus,
        this.groupUnreadMessageCount,
        this.adminUser,
        this.groupUserList});

  GroupResponse.fromJson(Map<String, dynamic> json) {
    groupId = json['groupId'];
    groupName = json['groupName'];
    groupIcon = json['groupIcon'];
    isDeleted = json['isDeleted'];
    isAdmin = json['isAdmin'];
    canVideoC = json['canVideoC'];
    canAudioC = json['canAudioC'];
    canShareS = json['canShareS'];
    canAttach = json['canAttach'];
    canArchive = json['canArchive'];
    isMeeting = json['isMeeting'];
    meetingTime = json['meetingTime'];
    extUserLink = json['extUserLink'];
    callStatus = json['callStatus'];
    groupUnreadMessageCount = json['groupUnreadMessageCount'];
    adminUser = json['adminUser'] != null
        ? new AdminUser.fromJson(json['adminUser'])
        : null;
    if (json['groupUserList'] != null) {
      groupUserList = <GroupUserList>[];
      json['groupUserList'].forEach((v) {
        groupUserList!.add(new GroupUserList.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
     Map<String, dynamic> data = new Map<String, dynamic>();
    data['groupId'] = this.groupId;
    data['groupName'] = this.groupName;
    data['groupIcon'] = this.groupIcon;
    data['isDeleted'] = this.isDeleted;
    data['isAdmin'] = this.isAdmin;
    data['canVideoC'] = this.canVideoC;
    data['canAudioC'] = this.canAudioC;
    data['canShareS'] = this.canShareS;
    data['canAttach'] = this.canAttach;
    data['canArchive'] = this.canArchive;
    data['isMeeting'] = this.isMeeting;
    data['meetingTime'] = this.meetingTime;
    data['extUserLink'] = this.extUserLink;
    data['callStatus'] = this.callStatus;
    data['groupUnreadMessageCount'] = this.groupUnreadMessageCount;
    if (this.adminUser != null) {
      data['adminUser'] = this.adminUser!.toJson();
    }
    if (this.groupUserList != null) {
      data['groupUserList'] =
          this.groupUserList!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class AdminUser {
  int? id;
  String? userName;
  String? email;
  Null? phone;
  String? title;
  int? userStatus;
  Null? image;
  int? unreadMessageCount;
  Null? userAction;
  bool? isPin;
  bool? isFav;
  bool? isAdmin;
  Null? rKey;
  int? totalCount;

  AdminUser(
      {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});

  AdminUser.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    userName = json['userName'];
    email = json['email'];
    phone = json['phone'];
    title = json['title'];
    userStatus = json['userStatus'];
    image = json['image'];
    unreadMessageCount = json['unreadMessageCount'];
    userAction = json['userAction'];
    isPin = json['isPin'];
    isFav = json['isFav'];
    isAdmin = json['isAdmin'];
    rKey = json['rKey'];
    totalCount = json['totalCount'];
  }

  Map<String, dynamic> toJson() {
     Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['userName'] = this.userName;
    data['email'] = this.email;
    data['phone'] = this.phone;
    data['title'] = this.title;
    data['userStatus'] = this.userStatus;
    data['image'] = this.image;
    data['unreadMessageCount'] = this.unreadMessageCount;
    data['userAction'] = this.userAction;
    data['isPin'] = this.isPin;
    data['isFav'] = this.isFav;
    data['isAdmin'] = this.isAdmin;
    data['rKey'] = this.rKey;
    data['totalCount'] = this.totalCount;
    return data;
  }
}

class GroupUserList {
  int? id;
  String? userName;
  String? email;
  Null? phone;
  String? title;
  int? userStatus;
  Null? image;
  int? unreadMessageCount;
  int? userAction;
  bool? isPin;
  bool? isFav;
  bool? isAdmin;
  Null? rKey;
  int? totalCount;

  GroupUserList(
      {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});

  GroupUserList.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    userName = json['userName'];
    email = json['email'];
    phone = json['phone'];
    title = json['title'];
    userStatus = json['userStatus'];
    image = json['image'];
    unreadMessageCount = json['unreadMessageCount'];
    userAction = json['userAction'];
    isPin = json['isPin'];
    isFav = json['isFav'];
    isAdmin = json['isAdmin'];
    rKey = json['rKey'];
    totalCount = json['totalCount'];
  }

  Map<String, dynamic> toJson() {
     Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['userName'] = this.userName;
    data['email'] = this.email;
    data['phone'] = this.phone;
    data['title'] = this.title;
    data['userStatus'] = this.userStatus;
    data['image'] = this.image;
    data['unreadMessageCount'] = this.unreadMessageCount;
    data['userAction'] = this.userAction;
    data['isPin'] = this.isPin;
    data['isFav'] = this.isFav;
    data['isAdmin'] = this.isAdmin;
    data['rKey'] = this.rKey;
    data['totalCount'] = this.totalCount;
    return data;
  }
}
