CustomerDiscount.fromJson constructor

CustomerDiscount.fromJson(
  1. Object? json
)

Implementation

factory CustomerDiscount.fromJson(Object? json) {
  final map = (json as Map).cast<String, Object?>();
  return CustomerDiscount(
    checkoutSession: map['checkout_session'] == null
        ? null
        : (map['checkout_session'] as String),
    coupon: Coupon.fromJson(map['coupon']),
    customer: map['customer'] == null
        ? null
        : BankAccountCustomerOrId.fromJson(map['customer']),
    end: map['end'] == null
        ? null
        : DateTime.fromMillisecondsSinceEpoch((map['end'] as int).toInt()),
    id: (map['id'] as String),
    invoice: map['invoice'] == null ? null : (map['invoice'] as String),
    invoiceItem:
        map['invoice_item'] == null ? null : (map['invoice_item'] as String),
    promotionCode: map['promotion_code'] == null
        ? null
        : PromotionCodeOrId.fromJson(map['promotion_code']),
    start: DateTime.fromMillisecondsSinceEpoch((map['start'] as int).toInt()),
    subscription:
        map['subscription'] == null ? null : (map['subscription'] as String),
  );
}