updateRoomSecret method
Implementation
Future<void> updateRoomSecret({
required String projectId,
required String roomName,
required String secretId,
required Uint8List data,
String? name,
String? type,
String? delegatedTo,
String? forIdentity,
}) async {
final encodedProjectId = Uri.encodeComponent(projectId);
final encodedRoomName = Uri.encodeComponent(roomName);
final encodedSecretId = Uri.encodeComponent(secretId);
final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/rooms/$encodedRoomName/secrets/$encodedSecretId');
final body = <String, dynamic>{
'data_base64': base64Encode(_normalizeSecretBytes(data)),
if (name != null) 'name': name,
if (type != null) 'type': type,
if (delegatedTo != null) 'delegated_to': delegatedTo,
if (forIdentity != null) 'for_identity': forIdentity,
};
final response = await httpClient.put(uri, body: jsonEncode(body));
if (response.statusCode >= 400) {
throw MeshagentException(
'Failed to update room secret. '
'Status code: ${response.statusCode}, body: ${response.body}',
);
}
}