
import 'dart:convert';

import 'product.dart';

class CategoryProducts {
  int? id;
  int? businessId;
  String? name;
  String? description;
  String? iconUrl;
  List<Product>? products;

  CategoryProducts.fromJson(Map<String, dynamic> json)
    : id = json['id'],
      businessId = json['business_id'],
      name = json['name'],
      description = json['description'],
      iconUrl = json['icon_url'],
      products = (json['products'] as List).map((i) => Product.fromJson(i)).toList();

  Map<String, dynamic> toJson() => {
    'id': id,
    'business_id': businessId,
    'name': name,
    'description': description,
    'icon_url': iconUrl,
    'products': products
  };

  @override
  String toString() {
    return json.encode(this);
  }

  CategoryProducts(this.id, this.businessId, this.name, this.description,
      this.iconUrl, this.products);
}