import 'package:intl/intl.dart';

class Purchase {
  int? purchaseId;
  late int customerId;
  late int productId;

  late DateTime dateAdd;
  late double purchaseSum;
  late String currency;

  Purchase({required this.customerId, required this.productId});

  Purchase.fromJson(Map json) {
    this.purchaseId = json['purchaseId'];
    this.customerId = json['customerId'];
    this.productId = json['productId'];
    this.dateAdd = DateTime.parse(json['dateAdd']);
    this.purchaseSum = json['purchaseSum'];
    this.currency = json['currency'];
  }

  Map<String, dynamic> toJson() => {
        "purchaseId": purchaseId,
        "customerId": customerId,
        "productId": productId,
        "purchaseSum": purchaseSum,
        "dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateAdd),
        "currency": currency,
      };
}
