fromJson static method

QuotedRate? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static QuotedRate? 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(() {
      return true;
    }());

    return QuotedRate(
      rooms: Room.listFromJson(json[r'rooms']),
      board: MealPlan.fromJson(json[r'board']),
      taxes: TaxBreakdown.fromJson(json[r'taxes']),
      priceIsBinding: mapValueOfType<bool>(json, r'priceIsBinding'),
      nightlyPrices: NightlyPrice.listFromJson(json[r'nightlyPrices']),
      rateTags: json[r'rateTags'] is Iterable
          ? (json[r'rateTags'] as Iterable).cast<String>().toList(growable: false)
          : const [],
      remarks: json[r'remarks'] is Iterable
          ? (json[r'remarks'] as Iterable).cast<String>().toList(growable: false)
          : const [],
      rateConditions: json[r'rateConditions'] is Iterable
          ? (json[r'rateConditions'] as Iterable).cast<String>().toList(growable: false)
          : const [],
      withTransfers: mapValueOfType<bool>(json, r'withTransfers'),
      rateRules: QuotedRateRateRulesEnum.listFromJson(json[r'rateRules']),
      amendabilityStatus: QuotedRateAmendabilityStatusEnum.fromJson(json[r'amendabilityStatus']),
      surcharges: Surcharge.listFromJson(json[r'surcharges']),
      minimumSellingPrice: Money.fromJson(json[r'minimumSellingPrice']),
      allowsSpecialRequests: mapValueOfType<bool>(json, r'allowsSpecialRequests'),
      specialRequestOptions: SpecialRequestOption.listFromJson(json[r'specialRequestOptions']),
    );
  }
  return null;
}