import 'PharmacyImageObject.dart';
import 'Reviews.dart';

class PharmacyProduct {
  String id;
  String name;
  String namen;
  String shortDescription;
  String fullDescription;
  String fullDescriptionn;
  int approvedRatingSum;
  int approvedTotalReviews;
  String sku;
  bool isRx;
  String rxMessage;
  String rxMessagen;
  int stockQuantity;
  String stockAvailability;
  String stockAvailabilityn;
  bool allowBackInStockSubscriptions;
  int orderMinimumQuantity;
  int orderMaximumQuantity;
  double price;
  double oldPrice;
  String discountName;
  String discountNamen;
  String discountPercentage;
  int displayOrder;
  List<int> discountIds;
  List<Reviews> reviews;
  List<PharmacyImageObject> images;

  PharmacyProduct(
      {this.id,
        this.name,
        this.namen,
        this.shortDescription,
        this.fullDescription,
        this.fullDescriptionn,
        this.approvedRatingSum,
        this.approvedTotalReviews,
        this.sku,
        this.isRx,
        this.rxMessage,
        this.rxMessagen,
        this.stockQuantity,
        this.stockAvailability,
        this.stockAvailabilityn,
        this.allowBackInStockSubscriptions,
        this.orderMinimumQuantity,
        this.orderMaximumQuantity,
        this.price,
        this.oldPrice,
        this.discountName,
        this.discountNamen,
        this.discountPercentage,
        this.displayOrder,
        this.discountIds,
        this.reviews,
        this.images});

  PharmacyProduct.fromJson(Map<String, dynamic> json) {
    try {
      id = json['id'];
      name = json['name'];
      namen = json['namen'];
      shortDescription = json['short_description'];
      fullDescription = json['full_description'];
      fullDescriptionn = json['full_descriptionn'];
      approvedRatingSum = json['approved_rating_sum'];
      approvedTotalReviews = json['approved_total_reviews'];
      sku = json['sku'];
      isRx = json['is_rx'];
      rxMessage = json['rx_message'];
      rxMessagen = json['rx_messagen'];
      stockQuantity = json['stock_quantity'];
      stockAvailability = json['stock_availability'];
      stockAvailabilityn = json['stock_availabilityn'];
      allowBackInStockSubscriptions = json['allow_back_in_stock_subscriptions'];
      orderMinimumQuantity = json['order_minimum_quantity'];
      orderMaximumQuantity = json['order_maximum_quantity'];
      price = json['price'];
      oldPrice = json['old_price'];
      discountName = json['discount_name'];
      discountNamen = json['discount_namen'];
      discountPercentage = json['discount_percentage'];
      displayOrder = json['display_order'];
      if (json['discount_ids'] != null) {
            discountIds = new List<int>();
            json['discount_ids'].forEach((v) {
              discountIds.add(v);
            });
          }
      if (json['reviews'] != null) {
            reviews = new List<Reviews>();
            json['reviews'].forEach((v) {
              reviews.add(new Reviews.fromJson(v));
            });
          }
      if (json['images'] != null) {
            images = new List<PharmacyImageObject>();
            json['images'].forEach((v) {
              images.add(new PharmacyImageObject.fromJson(v));
            });
          }
    } catch (e) {
      print(e);
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['name'] = this.name;
    data['namen'] = this.namen;
    data['short_description'] = this.shortDescription;
    data['full_description'] = this.fullDescription;
    data['full_descriptionn'] = this.fullDescriptionn;
    data['approved_rating_sum'] = this.approvedRatingSum;
    data['approved_total_reviews'] = this.approvedTotalReviews;
    data['sku'] = this.sku;
    data['is_rx'] = this.isRx;
    data['rx_message'] = this.rxMessage;
    data['rx_messagen'] = this.rxMessagen;
    data['stock_quantity'] = this.stockQuantity;
    data['stock_availability'] = this.stockAvailability;
    data['stock_availabilityn'] = this.stockAvailabilityn;
    data['allow_back_in_stock_subscriptions'] =
        this.allowBackInStockSubscriptions;
    data['order_minimum_quantity'] = this.orderMinimumQuantity;
    data['order_maximum_quantity'] = this.orderMaximumQuantity;
    data['price'] = this.price;
    data['old_price'] = this.oldPrice;
    data['discount_name'] = this.discountName;
    data['discount_namen'] = this.discountNamen;
    data['discount_percentage'] = this.discountPercentage;
    data['display_order'] = this.displayOrder;
    if (this.discountIds != String) {
      data['discount_ids'] = this.discountIds.map((v) => v).toList();
    }
    if (this.reviews != String) {
      data['reviews'] = this.reviews.map((v) => v.toJson()).toList();
    }
    if (this.images != String) {
      data['images'] = this.images.map((v) => v.toJson()).toList();
    }
    return data;
  }
}
