create static method

Invoice create({
  1. bool schemeUtilsIsSetDefaultData = false,
  2. String special_type = "invoice",
  3. String? id,
  4. String? external_id,
  5. String? user_id,
  6. String? status,
  7. String? merchant_name,
  8. String? merchant_profile_picture_url,
  9. num? amount,
  10. String? expiry_date,
  11. String? invoice_url,
  12. List<AvailableBanks>? available_banks,
  13. List<AvailableRetailOutlets>? available_retail_outlets,
  14. List<AvailableEwallets>? available_ewallets,
  15. List<AvailableQrCodes>? available_qr_codes,
  16. List<Object>? available_direct_debits,
  17. List<Object>? available_paylaters,
  18. bool? should_exclude_credit_card,
  19. bool? should_send_email,
  20. String? created,
  21. String? updated,
  22. String? currency,
  23. CustomerNotificationPreference? customer_notification_preference,
})
override

return original data json

Implementation

static Invoice create({
  bool schemeUtilsIsSetDefaultData = false,
  String special_type = "invoice",
  String? id,
  String? external_id,
  String? user_id,
  String? status,
  String? merchant_name,
  String? merchant_profile_picture_url,
  num? amount,
  String? expiry_date,
  String? invoice_url,
  List<AvailableBanks>? available_banks,
  List<AvailableRetailOutlets>? available_retail_outlets,
  List<AvailableEwallets>? available_ewallets,
  List<AvailableQrCodes>? available_qr_codes,
  List<Object>? available_direct_debits,
  List<Object>? available_paylaters,
  bool? should_exclude_credit_card,
  bool? should_send_email,
  String? created,
  String? updated,
  String? currency,
  CustomerNotificationPreference? customer_notification_preference,
}) {
  // Invoice invoice = Invoice({
  final Map invoice_data_create_json = {
    "@type": special_type,
    "id": id,
    "external_id": external_id,
    "user_id": user_id,
    "status": status,
    "merchant_name": merchant_name,
    "merchant_profile_picture_url": merchant_profile_picture_url,
    "amount": amount,
    "expiry_date": expiry_date,
    "invoice_url": invoice_url,
    "available_banks":
        (available_banks != null) ? available_banks.toJson() : null,
    "available_retail_outlets": (available_retail_outlets != null)
        ? available_retail_outlets.toJson()
        : null,
    "available_ewallets":
        (available_ewallets != null) ? available_ewallets.toJson() : null,
    "available_qr_codes":
        (available_qr_codes != null) ? available_qr_codes.toJson() : null,
    "available_direct_debits": available_direct_debits,
    "available_paylaters": available_paylaters,
    "should_exclude_credit_card": should_exclude_credit_card,
    "should_send_email": should_send_email,
    "created": created,
    "updated": updated,
    "currency": currency,
    "customer_notification_preference":
        (customer_notification_preference != null)
            ? customer_notification_preference.toJson()
            : null,
  };

  invoice_data_create_json.removeWhere((key, value) => value == null);

  if (schemeUtilsIsSetDefaultData) {
    defaultData.forEach((key, value) {
      if (invoice_data_create_json.containsKey(key) == false) {
        invoice_data_create_json[key] = value;
      }
    });
  }
  return Invoice(invoice_data_create_json);
}