fromJson static method
Returns a new HotelSearchRequest instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static HotelSearchRequest? 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'checkIn'), 'Required key "HotelSearchRequest[checkIn]" is missing from JSON.');
assert(json[r'checkIn'] != null, 'Required key "HotelSearchRequest[checkIn]" has a null value in JSON.');
assert(json.containsKey(r'checkOut'), 'Required key "HotelSearchRequest[checkOut]" is missing from JSON.');
assert(json[r'checkOut'] != null, 'Required key "HotelSearchRequest[checkOut]" has a null value in JSON.');
assert(json.containsKey(r'rooms'), 'Required key "HotelSearchRequest[rooms]" is missing from JSON.');
assert(json[r'rooms'] != null, 'Required key "HotelSearchRequest[rooms]" has a null value in JSON.');
assert(json.containsKey(r'guestNationality'), 'Required key "HotelSearchRequest[guestNationality]" is missing from JSON.');
return true;
}());
return HotelSearchRequest(
searchCriteria: HotelSearchCriteria.fromJson(json[r'searchCriteria']),
checkIn: mapDateTime(json, r'checkIn', r'')!,
checkOut: mapDateTime(json, r'checkOut', r'')!,
rooms: RoomOccupancyInput.listFromJson(json[r'rooms']),
guestNationality: mapValueOfType<String>(json, r'guestNationality'),
guestCountryOfResidence: mapValueOfType<String>(json, r'guestCountryOfResidence'),
filters: HotelSearchFilters.fromJson(json[r'filters']),
cursor: mapValueOfType<String>(json, r'cursor'),
limit: mapValueOfType<int>(json, r'limit'),
currency: mapValueOfType<String>(json, r'currency'),
);
}
return null;
}