import 'dart:convert';

class UsersModel {
  int? id;
  String? name;
  int? role;
  String? mobile;
  dynamic otp;
  dynamic access;
  dynamic managerId;
  dynamic firebaseToken;
  int? isBlock;
  int? getSms;
  DateTime? createdAt;
  DateTime? updatedAt;

  UsersModel({
    this.id,
    this.name,
    this.role,
    this.mobile,
    this.otp,
    this.access,
    this.managerId,
    this.firebaseToken,
    this.isBlock,
    this.getSms,
    this.createdAt,
    this.updatedAt,
  });

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

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

  factory UsersModel.fromJson(Map<String, dynamic> json) => UsersModel(
        id: json["id"],
        name: json["name"],
        role: json["role"],
        mobile: json["mobile"],
        otp: json["otp"],
        access: json["access"],
        managerId: json["manager_id"],
        firebaseToken: json["firebase_token"],
        isBlock: json["is_block"],
        getSms: json["get_sms"],
        createdAt: json["created_at"] == null
            ? null
            : DateTime.parse(json["created_at"]),
        updatedAt: json["updated_at"] == null
            ? null
            : DateTime.parse(json["updated_at"]),
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "name": name,
        "role": role,
        "mobile": mobile,
        "otp": otp,
        "access": access,
        "manager_id": managerId,
        "firebase_token": firebaseToken,
        "is_block": isBlock,
        "get_sms": getSms,
        "created_at": createdAt?.toIso8601String(),
        "updated_at": updatedAt?.toIso8601String(),
      };
}
