// To parse this JSON data, do
//
//     final memberLoginModel = memberLoginModelFromJson(jsonString);

import 'dart:convert';

import 'package:hmg_flutter_template/classes/consts.dart';
import 'package:shared_preferences/shared_preferences.dart';

MemberLoginModel memberLoginModelFromJson(String str) => MemberLoginModel.fromJson(json.decode(str));

String memberLoginModelToJson(MemberLoginModel data) => json.encode(data.toJson());

class MemberLoginModel {
  MemberLoginModel({
    this.date,
    this.languageId,
    this.serviceName,
    this.time,
    this.androidLink,
    this.authenticationTokenId,
    this.data,
    this.dataw,
    this.dietType,
    this.dietTypeId,
    this.errorCode,
    this.errorEndUserMessage,
    this.errorEndUserMessageN,
    this.errorMessage,
    this.errorType,
    this.foodCategory,
    this.iosLink,
    this.isAuthenticated,
    this.mealOrderStatus,
    this.mealType,
    this.messageStatus,
    this.numberOfResultRecords,
    this.patientBlodType,
    this.successMsg,
    this.successMsgN,
    this.vidaUpdatedResponse,
    this.doctorHaveOneClinic,
    this.doctorId,
    this.erpSessionId,
    this.listConsentMember,
    this.listConsentMemberNew,
    this.listDoctorProfile,
    this.listDoctorsClinic,
    this.listMemberInformation,
    this.listModelDbConnect,
    this.logInTokenId,
    this.mobileNumber,
    this.selectDeviceImeIbyImeiList,
    this.userId,
    this.zipCode,
    this.isActiveCode,
    this.isSmsSent,
  });

  final dynamic date;
  final int? languageId;
  final int? serviceName;
  final dynamic time;
  final dynamic androidLink;
  final dynamic authenticationTokenId;
  final dynamic data;
  final bool? dataw;
  final int? dietType;
  final int? dietTypeId;
  final dynamic errorCode;
  final dynamic errorEndUserMessage;
  final dynamic errorEndUserMessageN;
  final dynamic errorMessage;
  final int? errorType;
  final int? foodCategory;
  final dynamic iosLink;
  final bool? isAuthenticated;
  final int? mealOrderStatus;
  final int? mealType;
  final int? messageStatus;
  final int? numberOfResultRecords;
  final dynamic patientBlodType;
  final dynamic successMsg;
  final dynamic successMsgN;
  final dynamic vidaUpdatedResponse;
  final bool? doctorHaveOneClinic;
  final int? doctorId;
  final dynamic erpSessionId;
  final dynamic listConsentMember;
  final dynamic listConsentMemberNew;
  final dynamic listDoctorProfile;
  final dynamic listDoctorsClinic;
  final List<ListMemberInformation>? listMemberInformation;
  final dynamic listModelDbConnect;
  final String? logInTokenId;
  final String? mobileNumber;
  final dynamic selectDeviceImeIbyImeiList;
  final int? userId;
  final String? zipCode;
  final bool? isActiveCode;
  final bool? isSmsSent;

  factory MemberLoginModel.fromJson(Map<String, dynamic> json) => MemberLoginModel(
        date: json["Date"],
        languageId: json["LanguageID"] == null ? null : json["LanguageID"],
        serviceName: json["ServiceName"] == null ? null : json["ServiceName"],
        time: json["Time"],
        androidLink: json["AndroidLink"],
        authenticationTokenId: json["AuthenticationTokenID"],
        data: json["Data"],
        dataw: json["Dataw"] == null ? null : json["Dataw"],
        dietType: json["DietType"] == null ? null : json["DietType"],
        dietTypeId: json["DietTypeID"] == null ? null : json["DietTypeID"],
        errorCode: json["ErrorCode"],
        errorEndUserMessage: json["ErrorEndUserMessage"],
        errorEndUserMessageN: json["ErrorEndUserMessageN"],
        errorMessage: json["ErrorMessage"],
        errorType: json["ErrorType"] == null ? null : json["ErrorType"],
        foodCategory: json["FoodCategory"] == null ? null : json["FoodCategory"],
        iosLink: json["IOSLink"],
        isAuthenticated: json["IsAuthenticated"] == null ? null : json["IsAuthenticated"],
        mealOrderStatus: json["MealOrderStatus"] == null ? null : json["MealOrderStatus"],
        mealType: json["MealType"] == null ? null : json["MealType"],
        messageStatus: json["MessageStatus"] == null ? null : json["MessageStatus"],
        numberOfResultRecords: json["NumberOfResultRecords"] == null ? null : json["NumberOfResultRecords"],
        patientBlodType: json["PatientBlodType"],
        successMsg: json["SuccessMsg"],
        successMsgN: json["SuccessMsgN"],
        vidaUpdatedResponse: json["VidaUpdatedResponse"],
        doctorHaveOneClinic: json["DoctorHaveOneClinic"] == null ? null : json["DoctorHaveOneClinic"],
        doctorId: json["DoctorID"] == null ? null : json["DoctorID"],
        erpSessionId: json["ERP_SessionID"],
        listConsentMember: json["List_Consent_Member"],
        listConsentMemberNew: json["List_Consent_MemberNew"],
        listDoctorProfile: json["List_DoctorProfile"],
        listDoctorsClinic: json["List_DoctorsClinic"],
        listMemberInformation: json["List_MemberInformation"] == null ? null : List<ListMemberInformation>.from(json["List_MemberInformation"].map((x) => ListMemberInformation.fromJson(x))),
        listModelDbConnect: json["List_Model_DB_Connect"],
        logInTokenId: json["LogInTokenID"] == null ? null : json["LogInTokenID"],
        mobileNumber: json["MobileNumber"] == null ? null : json["MobileNumber"],
        selectDeviceImeIbyImeiList: json["SELECTDeviceIMEIbyIMEI_List"],
        userId: json["UserID"] == null ? null : json["UserID"],
        zipCode: json["ZipCode"] == null ? null : json["ZipCode"],
        isActiveCode: json["isActiveCode"] == null ? null : json["isActiveCode"],
        isSmsSent: json["isSMSSent"] == null ? null : json["isSMSSent"],
      );

  Map<String, dynamic> toJson() => {
        "Date": date,
        "LanguageID": languageId == null ? null : languageId,
        "ServiceName": serviceName == null ? null : serviceName,
        "Time": time,
        "AndroidLink": androidLink,
        "AuthenticationTokenID": authenticationTokenId,
        "Data": data,
        "Dataw": dataw == null ? null : dataw,
        "DietType": dietType == null ? null : dietType,
        "DietTypeID": dietTypeId == null ? null : dietTypeId,
        "ErrorCode": errorCode,
        "ErrorEndUserMessage": errorEndUserMessage,
        "ErrorEndUserMessageN": errorEndUserMessageN,
        "ErrorMessage": errorMessage,
        "ErrorType": errorType == null ? null : errorType,
        "FoodCategory": foodCategory == null ? null : foodCategory,
        "IOSLink": iosLink,
        "IsAuthenticated": isAuthenticated == null ? null : isAuthenticated,
        "MealOrderStatus": mealOrderStatus == null ? null : mealOrderStatus,
        "MealType": mealType == null ? null : mealType,
        "MessageStatus": messageStatus == null ? null : messageStatus,
        "NumberOfResultRecords": numberOfResultRecords == null ? null : numberOfResultRecords,
        "PatientBlodType": patientBlodType,
        "SuccessMsg": successMsg,
        "SuccessMsgN": successMsgN,
        "VidaUpdatedResponse": vidaUpdatedResponse,
        "DoctorHaveOneClinic": doctorHaveOneClinic == null ? null : doctorHaveOneClinic,
        "DoctorID": doctorId == null ? null : doctorId,
        "ERP_SessionID": erpSessionId,
        "List_Consent_Member": listConsentMember,
        "List_Consent_MemberNew": listConsentMemberNew,
        "List_DoctorProfile": listDoctorProfile,
        "List_DoctorsClinic": listDoctorsClinic,
        "List_MemberInformation": listMemberInformation == null ? null : List<dynamic>.from(listMemberInformation!.map((x) => x.toJson())),
        "List_Model_DB_Connect": listModelDbConnect,
        "LogInTokenID": logInTokenId == null ? null : logInTokenId,
        "MobileNumber": mobileNumber == null ? null : mobileNumber,
        "SELECTDeviceIMEIbyIMEI_List": selectDeviceImeIbyImeiList,
        "UserID": userId == null ? null : userId,
        "ZipCode": zipCode == null ? null : zipCode,
        "isActiveCode": isActiveCode == null ? null : isActiveCode,
        "isSMSSent": isSmsSent == null ? null : isSmsSent,
      };

  static Future<MemberLoginModel> getFromPrefs() async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    String decodedJson = prefs.getString(SharedPrefsConsts.memberModel) ?? "";
    return MemberLoginModel.fromJson(jsonDecode(decodedJson));
  }

  static void saveToPrefs(String json) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    await prefs.setString(SharedPrefsConsts.memberModel, json);
  }
}

class ListMemberInformation {
  ListMemberInformation({
    this.setupId,
    this.memberId,
    this.memberName,
    this.memberNameN,
    this.preferredLang,
    this.pin,
    this.saltHash,
    this.referenceId,
    this.employeeId,
    this.roleId,
    this.projectid,
  });

  final dynamic setupId;
  final int? memberId;
  final String? memberName;
  final dynamic memberNameN;
  final String? preferredLang;
  final dynamic pin;
  final dynamic saltHash;
  final int? referenceId;
  final int? employeeId;
  final int? roleId;
  final int? projectid;

  factory ListMemberInformation.fromJson(Map<String, dynamic> json) => ListMemberInformation(
        setupId: json["SetupID"],
        memberId: json["MemberID"] == null ? null : json["MemberID"],
        memberName: json["MemberName"] == null ? null : json["MemberName"],
        memberNameN: json["MemberNameN"],
        preferredLang: json["PreferredLang"] == null ? null : json["PreferredLang"],
        pin: json["PIN"],
        saltHash: json["SaltHash"],
        referenceId: json["ReferenceID"] == null ? null : json["ReferenceID"],
        employeeId: json["EmployeeID"] == null ? null : json["EmployeeID"],
        roleId: json["RoleID"] == null ? null : json["RoleID"],
        projectid: json["projectid"] == null ? null : json["projectid"],
      );

  Map<String, dynamic> toJson() => {
        "SetupID": setupId,
        "MemberID": memberId == null ? null : memberId,
        "MemberName": memberName == null ? null : memberName,
        "MemberNameN": memberNameN,
        "PreferredLang": preferredLang == null ? null : preferredLang,
        "PIN": pin,
        "SaltHash": saltHash,
        "ReferenceID": referenceId == null ? null : referenceId,
        "EmployeeID": employeeId == null ? null : employeeId,
        "RoleID": roleId == null ? null : roleId,
        "projectid": projectid == null ? null : projectid,
      };
}
