fromJson static method

HotelOfferDetails? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static HotelOfferDetails? 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 HotelOfferDetails(
      expiresAt: mapDateTime(json, r'expiresAt', r''),
      rooms: Room.listFromJson(json[r'rooms']),
      board: MealPlan.fromJson(json[r'board']),
      terms: BookingTerms.fromJson(json[r'terms']),
      taxes: TaxBreakdown.fromJson(json[r'taxes']),
      priceIsBinding: mapValueOfType<bool>(json, r'priceIsBinding'),
      nightlyPrices: NightlyPrice.listFromJson(json[r'nightlyPrices']),
      surcharges: Surcharge.listFromJson(json[r'surcharges']),
      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 [],
      withTransfers: mapValueOfType<bool>(json, r'withTransfers'),
      rateRules: HotelOfferDetailsRateRulesEnum.listFromJson(json[r'rateRules']),
      amendabilityStatus: HotelOfferDetailsAmendabilityStatusEnum.fromJson(json[r'amendabilityStatus']),
      guestNameRules: GuestNameRules.fromJson(json[r'guestNameRules']),
      minimumSellingPrice: Money.fromJson(json[r'minimumSellingPrice']),
      allowsSpecialRequests: mapValueOfType<bool>(json, r'allowsSpecialRequests'),
      specialRequestOptions: SpecialRequestOption.listFromJson(json[r'specialRequestOptions']),
    );
  }
  return null;
}