fromJson static method

PassengerPricing? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static PassengerPricing? 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'passengerType'), 'Required key "PassengerPricing[passengerType]" is missing from JSON.');
      assert(json[r'passengerType'] != null, 'Required key "PassengerPricing[passengerType]" has a null value in JSON.');
      assert(json.containsKey(r'count'), 'Required key "PassengerPricing[count]" is missing from JSON.');
      assert(json[r'count'] != null, 'Required key "PassengerPricing[count]" has a null value in JSON.');
      assert(json.containsKey(r'pricePerPassenger'), 'Required key "PassengerPricing[pricePerPassenger]" is missing from JSON.');
      assert(json[r'pricePerPassenger'] != null, 'Required key "PassengerPricing[pricePerPassenger]" has a null value in JSON.');
      return true;
    }());

    return PassengerPricing(
      passengerType: PassengerPricingPassengerTypeEnum.fromJson(json[r'passengerType'])!,
      count: mapValueOfType<int>(json, r'count')!,
      pricePerPassenger: Money.fromJson(json[r'pricePerPassenger'])!,
      priceBreakdown: PriceBreakdown.fromJson(json[r'priceBreakdown']),
      fareBasisCode: mapValueOfType<String>(json, r'fareBasisCode'),
      bookingClass: mapValueOfType<String>(json, r'bookingClass'),
    );
  }
  return null;
}