stopPtz method

Future<Map<String, dynamic>> stopPtz(
  1. String deviceSerial,
  2. int channelNo, {
  3. PtzCommand? direction,
})

Implementation

Future<Map<String, dynamic>> stopPtz(
  String deviceSerial,
  int channelNo, {
  PtzCommand? direction,
}) async {
  final params = <String, dynamic>{};
  // The API doc specifies direction as a required parameter for stop.
  // If the API were to allow stopping all movements without specifying direction, this check would be different.
  if (direction != null) {
    params['direction'] = direction.index;
  } else {
    // As per API docs, direction is mandatory for stop. Throwing an error or handling as per library design choice.
    // For now, let's assume the API doc is strict and direction must be provided.
    // Or, if the intent is to stop a specific movement, then direction is indeed necessary.
    // If the API implies a general stop without direction, this part needs adjustment.
    // Based on the provided doc, direction IS required for stop.
    // We will proceed assuming it's always provided by the caller for now.
    // If an empty param call should stop all, the API would need to define that.
    throw ArgumentError(
      'Direction must be provided for stopPtz as per API documentation.',
    );
  }
  return _ptzControl(
    '/api/lapp/device/ptz/stop',
    deviceSerial,
    channelNo,
    params,
  );
}