import 'package:autos/domain/entities/import_product.dart';

class ImportProductModel {
  final String id;
  final String sku;
  final String image;
  final String name;
  final String partNumber;
  final String category;
  final String subcategory;
  final double price;
  final int inventory;
  final String offerStatus;

  ImportProductModel({
    required this.id,
    required this.sku,
    required this.image,
    required this.name,
    required this.partNumber,
    required this.category,
    required this.subcategory,
    required this.price,
    required this.inventory,
    required this.offerStatus,
  });

  factory ImportProductModel.fromJson(Map<String, dynamic> json) {
    return ImportProductModel(
      id: json['id']?.toString() ?? '',
      sku: json['sku'] ?? '',
      image: json['imgSrc'] ?? '',
      name: json['name'] ?? '',
      partNumber: json['partNumber'] ?? '',
      category: json['category'] ?? '',
      subcategory: json['subcategory'] ?? '',
      price: double.tryParse(json['price'].toString()) ?? 0,
      inventory: json['inventory'] ?? 0,
      offerStatus: json['offer_status'] ?? '',
    );
  }

  ImportProductEntity toEntity() {
    return ImportProductEntity(
      id: id,
      sku: sku,
      image: image,
      name: name,
      partNumber: partNumber,
      category: category,
      subcategory: subcategory,
      price: price,
      inventory: inventory,
      offerStatus: offerStatus,
    );
  }
}
