class VisitsSearch { String? deviceSerialNumber; String? hospitalName; String? brand; String? model; String? contactStatus; DateTime? expectedDateFrom; DateTime? expectedDateTo; DateTime? actualDateFrom; DateTime? actualDateTo; int? statusValue; VisitsSearch({ this.deviceSerialNumber, this.statusValue, this.brand, this.hospitalName, this.actualDateTo, this.actualDateFrom, this.model, this.contactStatus, this.expectedDateFrom, this.expectedDateTo, }); fromSearch(VisitsSearch newSearch) { deviceSerialNumber = newSearch.deviceSerialNumber; brand = newSearch.brand; hospitalName = newSearch.hospitalName; actualDateTo = newSearch.actualDateTo; actualDateFrom = newSearch.actualDateFrom; model = newSearch.model; contactStatus = newSearch.contactStatus; expectedDateFrom = newSearch.expectedDateFrom; expectedDateTo = newSearch.expectedDateTo; statusValue = newSearch.statusValue; } Map queryParameters() { return { if (deviceSerialNumber != null && (deviceSerialNumber?.isNotEmpty ?? false)) 'sn_id': deviceSerialNumber, if (statusValue != null) 'status': statusValue?.toString(), if (hospitalName != null && (hospitalName?.isNotEmpty ?? false)) 'client': hospitalName, if (brand != null && (brand?.isNotEmpty ?? false)) 'brand': brand, if (model != null && (model?.isNotEmpty ?? false)) 'model': model, if (expectedDateFrom != null) 'expected_date_from': (expectedDateFrom?.millisecondsSinceEpoch ?? 0) ~/ 1000, if (expectedDateTo != null) 'expected_date_to': (expectedDateTo?.millisecondsSinceEpoch ?? 0) ~/ 1000, if (actualDateFrom != null) 'actual_date_from': (actualDateFrom?.millisecondsSinceEpoch ?? 0) ~/ 1000, if (actualDateTo != null) 'actual_date_to': (actualDateTo?.millisecondsSinceEpoch ?? 0) ~/ 1000, if (contactStatus != null) 'assigned_to': contactStatus, }; } }