xcAlarmVideoCalendar method

Future<List<String>> xcAlarmVideoCalendar({
  1. required String deviceId,
  2. required String userId,
  3. DateTime? monthDateTime,
  4. DateTime? startTime,
  5. DateTime? endTime,
  6. int? channel,
  7. String? mUserid,
  8. bool needAuth = true,
})

Implementation

Future<List<String>> xcAlarmVideoCalendar({
  required String deviceId,
  required String userId,
  DateTime? monthDateTime,
  DateTime? startTime,
  DateTime? endTime,
  int? channel,
  String? mUserid,
  bool needAuth = true,
}) async {
  if (monthDateTime == null && startTime != null && endTime != null) {
    assert(startTime.isBefore(endTime) || startTime == endTime,
        '开始日期必须早于等于结束日期');
  }

  String jsonStr = paramConfig(
      deviceId: deviceId,
      type: CalendarType.alarmVideo,
      monthDateTime: monthDateTime,
      startTime: startTime,
      endTime: endTime,
      userId: userId,
      mUserid: mUserid,
      needAuth: needAuth);

  final originResponse =
      await _api.xcAlarmCalendar(deviceId, jsonStr, ApiSeq.instance.getSeq());
  XCloudResponse<Map<String, dynamic>> response =
      XCloudResponse.fromOriginResponse<Map<String, dynamic>>(originResponse);
  if (response.code < 0) {
    return Future.error(XCloudAPIException(
        code: response.code, commandId: originResponse.commandId));
  }
  final dateMapList = response.data['dt'];
  final List<String> result = [];
  for (var dateMap in dateMapList) {
    result.add(dateMap['tm']);
  }
  return Future.value(result);
}