listToolkits method

Future<List<ToolkitDescription>> listToolkits({
  1. String? participantId,
  2. String? participantName,
  3. int? timeout,
})

Implementation

Future<List<ToolkitDescription>> listToolkits({String? participantId, String? participantName, int? timeout}) async {
  final request = <String, dynamic>{};
  if (participantId != null) {
    request["participant_id"] = participantId;
  }
  if (participantName != null) {
    request["participant_name"] = participantName;
  }
  if (timeout != null) {
    request["timeout"] = timeout;
  }

  final result = await sendRequest("room.list_toolkits", request);
  if (result is! JsonContent) {
    throw RoomServerException("unexpected return type from room.list_toolkits");
  }

  final toolsValue = result.json["tools"];
  if (toolsValue is! Map) {
    throw RoomServerException("unexpected return type from room.list_toolkits");
  }

  final tools = Map<String, dynamic>.from(toolsValue);
  final toolkits = <ToolkitDescription>[];

  for (final entry in tools.entries) {
    final json = entry.value;
    if (json is! Map) {
      throw RoomServerException("unexpected toolkit description from room.list_toolkits");
    }
    toolkits.add(ToolkitDescription.fromJson(Map<String, dynamic>.from(json), name: entry.key));
  }

  return toolkits;
}