fromJson static method

CreditCardOfferDetails? fromJson(
  1. dynamic value
)

Returns a new CreditCardOfferDetails instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static CreditCardOfferDetails? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      assert(json.containsKey(r'cardImageUrl'),
          'Required key "CreditCardOfferDetails[cardImageUrl]" is missing from JSON.');
      assert(json[r'cardImageUrl'] != null,
          'Required key "CreditCardOfferDetails[cardImageUrl]" has a null value in JSON.');
      assert(json.containsKey(r'cardType'),
          'Required key "CreditCardOfferDetails[cardType]" is missing from JSON.');
      assert(json[r'cardType'] != null,
          'Required key "CreditCardOfferDetails[cardType]" has a null value in JSON.');
      assert(json.containsKey(r'preQualified'),
          'Required key "CreditCardOfferDetails[preQualified]" is missing from JSON.');
      assert(json[r'preQualified'] != null,
          'Required key "CreditCardOfferDetails[preQualified]" has a null value in JSON.');
      assert(json.containsKey(r'preApproved'),
          'Required key "CreditCardOfferDetails[preApproved]" is missing from JSON.');
      assert(json[r'preApproved'] != null,
          'Required key "CreditCardOfferDetails[preApproved]" has a null value in JSON.');
      assert(json.containsKey(r'preSelected'),
          'Required key "CreditCardOfferDetails[preSelected]" is missing from JSON.');
      assert(json[r'preSelected'] != null,
          'Required key "CreditCardOfferDetails[preSelected]" has a null value in JSON.');
      return true;
    }());

    return CreditCardOfferDetails(
      cardName: mapValueOfType<String>(json, r'cardName'),
      cardImageUrl: mapValueOfType<String>(json, r'cardImageUrl')!,
      cardPurposes: CardPurpose.listFromJson(json[r'cardPurposes']),
      ratesUrl: mapValueOfType<String>(json, r'ratesUrl'),
      maxPurchaseApr: mapValueOfType<double>(json, r'maxPurchaseApr'),
      minPurchaseApr: mapValueOfType<double>(json, r'minPurchaseApr'),
      purchaseAprText: mapValueOfType<String>(json, r'purchaseAprText'),
      purchaseAprDisclaimer:
          mapValueOfType<String>(json, r'purchaseAprDisclaimer'),
      maxPurchaseIntroApr:
          mapValueOfType<double>(json, r'maxPurchaseIntroApr'),
      minPurchaseIntroApr:
          mapValueOfType<double>(json, r'minPurchaseIntroApr'),
      purchaseIntroAprTerm:
          mapValueOfType<int>(json, r'purchaseIntroAprTerm'),
      purchaseIntroAprTermUnit:
          TermUnit.fromJson(json[r'purchaseIntroAprTermUnit']),
      purchaseIntroAprText:
          mapValueOfType<String>(json, r'purchaseIntroAprText'),
      regularIntroAprCombinedText:
          mapValueOfType<String>(json, r'regularIntroAprCombinedText'),
      maxCashAdvanceApr: mapValueOfType<double>(json, r'maxCashAdvanceApr'),
      minCashAdvanceApr: mapValueOfType<double>(json, r'minCashAdvanceApr'),
      cashAdvanceAprText: mapValueOfType<String>(json, r'cashAdvanceAprText'),
      maxCashAdvanceIntroApr:
          mapValueOfType<double>(json, r'maxCashAdvanceIntroApr'),
      minCashAdvanceIntroApr:
          mapValueOfType<double>(json, r'minCashAdvanceIntroApr'),
      cashAdvanceIntroAprTerm:
          mapValueOfType<int>(json, r'cashAdvanceIntroAprTerm'),
      cashAdvanceIntroAprTermUnit:
          TermUnit.fromJson(json[r'cashAdvanceIntroAprTermUnit']),
      cashAdvanceIntroAprText:
          mapValueOfType<String>(json, r'cashAdvanceIntroAprText'),
      maxBalanceTransferApr:
          mapValueOfType<double>(json, r'maxBalanceTransferApr'),
      minBalanceTransferApr:
          mapValueOfType<double>(json, r'minBalanceTransferApr'),
      balanceTransferAprText:
          mapValueOfType<String>(json, r'balanceTransferAprText'),
      maxBalanceTransferIntroApr:
          mapValueOfType<double>(json, r'maxBalanceTransferIntroApr'),
      minBalanceTransferIntroApr:
          mapValueOfType<double>(json, r'minBalanceTransferIntroApr'),
      balanceTransferIntroAprTerm:
          mapValueOfType<int>(json, r'balanceTransferIntroAprTerm'),
      balanceTransferIntroAprTermUnit:
          TermUnit.fromJson(json[r'balanceTransferIntroAprTermUnit']),
      balanceTransferIntroAprText:
          mapValueOfType<String>(json, r'balanceTransferIntroAprText'),
      balanceTransferFee: mapValueOfType<double>(json, r'balanceTransferFee'),
      balanceTransferFeeDisclaimer:
          mapValueOfType<String>(json, r'balanceTransferFeeDisclaimer'),
      maxAnnualFee: mapValueOfType<double>(json, r'maxAnnualFee'),
      minAnnualFee: mapValueOfType<double>(json, r'minAnnualFee'),
      annualFeeDisclaimer:
          mapValueOfType<String>(json, r'annualFeeDisclaimer'),
      annualFeeText: mapValueOfType<String>(json, r'annualFeeText'),
      annualIntroFee: mapValueOfType<double>(json, r'annualIntroFee'),
      annualIntroFeeTerm: mapValueOfType<int>(json, r'annualIntroFeeTerm'),
      introOfferAmount: mapValueOfType<double>(json, r'introOfferAmount'),
      introOfferText: mapValueOfType<String>(json, r'introOfferText'),
      introOfferDisclaimer:
          mapValueOfType<String>(json, r'introOfferDisclaimer'),
      introOfferType: IntroOfferType.fromJson(json[r'introOfferType']),
      introOfferTitle: mapValueOfType<String>(json, r'introOfferTitle'),
      details: json[r'details'] is Iterable
          ? (json[r'details'] as Iterable)
              .cast<String>()
              .toList(growable: false)
          : const [],
      additionalDetails: json[r'additionalDetails'] is Iterable
          ? (json[r'additionalDetails'] as Iterable)
              .cast<String>()
              .toList(growable: false)
          : const [],
      previewDetails: PreviewDetail.listFromJson(json[r'previewDetails']),
      cardType: CardType.fromJson(json[r'cardType'])!,
      minimumCreditLine: mapValueOfType<double>(json, r'minimumCreditLine'),
      minimumPenaltyApr: mapValueOfType<double>(json, r'minimumPenaltyApr'),
      maximumPenaltyApr: mapValueOfType<double>(json, r'maximumPenaltyApr'),
      aprType: AprType.fromJson(json[r'aprType']),
      cashAdvanceFee: mapValueOfType<double>(json, r'cashAdvanceFee'),
      lateFee: mapValueOfType<double>(json, r'lateFee'),
      foreignExchangeFee: mapValueOfType<double>(json, r'foreignExchangeFee'),
      accountOpeningFee: mapValueOfType<double>(json, r'accountOpeningFee'),
      returnPaymentFee: mapValueOfType<double>(json, r'returnPaymentFee'),
      monthlyServiceFee: mapValueOfType<double>(json, r'monthlyServiceFee'),
      recommendedCreditRatings: ProvidedCreditRating.listFromJson(
          json[r'recommendedCreditRatings']),
      recommendedCreditRatingsDisclaimer:
          mapValueOfType<String>(json, r'recommendedCreditRatingsDisclaimer'),
      recommendedCreditRatingsText:
          mapValueOfType<String>(json, r'recommendedCreditRatingsText'),
      preQualified: mapValueOfType<bool>(json, r'preQualified')!,
      preApproved: mapValueOfType<bool>(json, r'preApproved')!,
      preSelected: mapValueOfType<bool>(json, r'preSelected')!,
      foreignTransactionFee:
          mapValueOfType<double>(json, r'foreignTransactionFee'),
      earningProgram: mapValueOfType<Object>(json, r'earningProgram'),
      cardBenefits: CardBenefit.listFromJson(json[r'cardBenefits']),
      rewardsDescription: mapValueOfType<String>(json, r'rewardsDescription'),
      rewardsDisclaimer: mapValueOfType<String>(json, r'rewardsDisclaimer'),
      rewardsTitle: mapValueOfType<String>(json, r'rewardsTitle'),
      minDepositAmount: mapValueOfType<double>(json, r'minDepositAmount'),
      minDepositDisclaimer:
          mapValueOfType<String>(json, r'minDepositDisclaimer'),
      isITA: mapValueOfType<bool>(json, r'isITA'),
      badges: json[r'badges'] is Iterable
          ? (json[r'badges'] as Iterable)
              .cast<String>()
              .toList(growable: false)
          : const [],
    );
  }
  return null;
}