fromJson static method

RateTable? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static RateTable? 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'uuid'),
          'Required key "RateTable[uuid]" is missing from JSON.');
      assert(json[r'uuid'] != null,
          'Required key "RateTable[uuid]" has a null value in JSON.');
      assert(json.containsKey(r'leadUuid'),
          'Required key "RateTable[leadUuid]" is missing from JSON.');
      assert(json[r'leadUuid'] != null,
          'Required key "RateTable[leadUuid]" has a null value in JSON.');
      assert(json.containsKey(r'creditCardOffers'),
          'Required key "RateTable[creditCardOffers]" is missing from JSON.');
      assert(json[r'creditCardOffers'] != null,
          'Required key "RateTable[creditCardOffers]" has a null value in JSON.');
      assert(json.containsKey(r'loanOffers'),
          'Required key "RateTable[loanOffers]" is missing from JSON.');
      assert(json[r'loanOffers'] != null,
          'Required key "RateTable[loanOffers]" has a null value in JSON.');
      assert(json.containsKey(r'mortgageOffers'),
          'Required key "RateTable[mortgageOffers]" is missing from JSON.');
      assert(json[r'mortgageOffers'] != null,
          'Required key "RateTable[mortgageOffers]" has a null value in JSON.');
      assert(json.containsKey(r'savingsOffers'),
          'Required key "RateTable[savingsOffers]" is missing from JSON.');
      assert(json[r'savingsOffers'] != null,
          'Required key "RateTable[savingsOffers]" has a null value in JSON.');
      assert(json.containsKey(r'specialOffers'),
          'Required key "RateTable[specialOffers]" is missing from JSON.');
      assert(json[r'specialOffers'] != null,
          'Required key "RateTable[specialOffers]" has a null value in JSON.');
      assert(json.containsKey(r'additionalOffers'),
          'Required key "RateTable[additionalOffers]" is missing from JSON.');
      assert(json[r'additionalOffers'] != null,
          'Required key "RateTable[additionalOffers]" has a null value in JSON.');
      assert(json.containsKey(r'pendingOriginators'),
          'Required key "RateTable[pendingOriginators]" is missing from JSON.');
      assert(json[r'pendingOriginators'] != null,
          'Required key "RateTable[pendingOriginators]" has a null value in JSON.');
      assert(json.containsKey(r'pendingResponses'),
          'Required key "RateTable[pendingResponses]" is missing from JSON.');
      assert(json[r'pendingResponses'] != null,
          'Required key "RateTable[pendingResponses]" has a null value in JSON.');
      return true;
    }());

    return RateTable(
      uuid: mapValueOfType<String>(json, r'uuid')!,
      leadUuid: mapValueOfType<String>(json, r'leadUuid')!,
      loanAmount: mapValueOfType<int>(json, r'loanAmount'),
      createdAt: mapDateTime(json, r'createdAt', r''),
      embedUrl: mapValueOfType<String>(json, r'embedUrl'),
      partnerPageUrl: mapValueOfType<String>(json, r'partnerPageUrl'),
      creditCardOffers:
          CreditCardOffer.listFromJson(json[r'creditCardOffers']),
      loanOffers: LoanOffer.listFromJson(json[r'loanOffers']),
      mortgageOffers: MortgageOffer.listFromJson(json[r'mortgageOffers']),
      savingsOffers: SavingsOffer.listFromJson(json[r'savingsOffers']),
      specialOffers: SpecialOffer.listFromJson(json[r'specialOffers']),
      additionalOffers:
          RateTableAdditionalOffers.fromJson(json[r'additionalOffers'])!,
      pendingOriginators:
          Originator.listFromJson(json[r'pendingOriginators']),
      pendingResponses:
          PendingResponse.listFromJson(json[r'pendingResponses']),
    );
  }
  return null;
}