unregisterDevice method

  1. @override
Future<StudyDeploymentStatus?> unregisterDevice(
  1. String studyDeploymentId,
  2. String deviceRoleName
)
override

Unregister the device with the specified deviceRoleName for the study deployment with studyDeploymentId. Returns null if studyDeploymentId is not found.

Implementation

@override
Future<StudyDeploymentStatus?> unregisterDevice(
  String studyDeploymentId,
  String deviceRoleName,
) async {
  if (_repository[studyDeploymentId] == null) return null;
  StudyDeployment deployment = _repository[studyDeploymentId]!;
  DeviceConfiguration device = deployment.registeredDevices.keys.firstWhere(
      (configuration) => configuration.roleName == deviceRoleName);

  deployment.unregisterDevice(device);

  return deployment.status;
}