class VendorProfileModel {
  final int id;
  final String name;
  final String number;
  final String email;
  final String password;
  final int otp;
  final int isVerified;
  final String? address;

  final String? profilePic1;
  final String? updatedAt;
  final String createdAt;
  final String? vendorStatus;
  final String? vendorId;
  final String? endDate;

  VendorProfileModel({
    required this.id,
    required this.name,
    required this.number,
    required this.email,
    required this.password,
    required this.otp,
    required this.isVerified,
    this.address,
    this.profilePic1,
    this.updatedAt,
    required this.createdAt,
    this.vendorStatus,
    this.vendorId,
    this.endDate,
  });

  /// Factory method to create an instance from a JSON map
  factory VendorProfileModel.fromJson(Map<String, dynamic> json) {
    return VendorProfileModel(
      id: int.tryParse(json['id'].toString()) ?? 0,
      name: json['name']?.toString() ?? '',
      number: json['number']?.toString() ?? '',
      email: json['email']?.toString() ?? '',
      password: json['password']?.toString() ?? '',
      otp: int.tryParse(json['otp'].toString()) ?? 0,
      isVerified: int.tryParse(json['is_verified'].toString()) ?? 0,
      address: json['location']?.toString(),
      profilePic1: json['profile_pic1']?.toString(),
      updatedAt: json['updated_at']?.toString(),
      createdAt: json['created_at']?.toString() ?? '',
      vendorStatus: json['vendor_status']?.toString(),
      vendorId: json['vendor_id']?.toString(),
      endDate: json['end_date']?.toString(),
    );
  }

  /// Method to convert the object to a JSON map
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'number': number,
      'email': email,
      'password': password,
      'otp': otp,
      'is_verified': isVerified,
      'location': address,
      'profile_pic1': profilePic1,
      'updated_at': updatedAt,
      'created_at': createdAt,
      'vendor_status': vendorStatus,
      'vendor_id': vendorId,
      'end_date': endDate,
    };
  }
}
