setSnoozePeriod method Null safety

Future<void> setSnoozePeriod(
  1. {required bool enable,
  2. DateTime? startDate,
  3. DateTime? endDate}
)

Sets snooze period enable with start and end date.

Implementation

Future<void> setSnoozePeriod({
  required bool enable,
  DateTime? startDate,
  DateTime? endDate,
}) async {
  if (enable) {
    if (startDate == null || endDate == null) throw InvalidParameterError();
    if (endDate.difference(startDate).inSeconds < 0) {
      throw InvalidParameterError();
    }
    if (endDate.difference(DateTime.now()).inSeconds < 0) {
      throw InvalidParameterError();
    }
  }
  return _int.api.send(UserSnoozePeriodSetRequest(
    enable: enable,
    startDate: startDate,
    endDate: endDate,
  ));
}