import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart';
import 'package:flutter/material.dart';

class ShoppingCartResponse with ChangeNotifier {
  int itemCount;
  int quantityCount;
  double subtotal;
  double subtotalWithVat;
  double subtotalVatAmount;
  double subtotalVatRate;
  List<ShoppingCart> shoppingCarts;

  ShoppingCartResponse(
      {this.itemCount,
      this.quantityCount,
      this.subtotal,
      this.subtotalWithVat,
      this.subtotalVatAmount,
      this.subtotalVatRate,
      this.shoppingCarts});

  void updateShoppingCard() {
    notifyListeners();
  }

  ShoppingCartResponse.fromJson(Map<String, dynamic> json) {
    itemCount = json['item_count'];
    quantityCount = json['quantity_count'];
    subtotal = json['subtotal'];
    subtotalWithVat = json['subtotal_with_vat'];
    subtotalVatAmount = json['subtotal_vat_amount'];
    subtotalVatRate = json['subtotal_vat_rate'];
    if (json['shopping_carts'] != null) {
      shoppingCarts = new List<ShoppingCart>();
      json['shopping_carts'].forEach((v) {
        shoppingCarts.add(new ShoppingCart.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['item_count'] = this.itemCount;
    data['quantity_count'] = this.quantityCount;
    data['subtotal'] = this.subtotal;
    data['subtotal_with_vat'] = this.subtotalWithVat;
    data['subtotal_vat_amount'] = this.subtotalVatAmount;
    data['subtotal_vat_rate'] = this.subtotalVatRate;
    if (this.shoppingCarts != null) {
      data['shopping_carts'] =
          this.shoppingCarts.map((v) => v.toJson()).toList();
    }
    return data;
  }
}
