createRoomGrantByEmail method
POST /accounts/projects/{project_id}/room-grants Body: { "room_name", "user_id", "permissions" } Returns {} on success.
Implementation
Future<void> createRoomGrantByEmail({
required String projectId,
required String roomId,
required String email,
required ApiScope permissions,
Uri? inviteRedirectUrl,
}) async {
final encodedProjectId = Uri.encodeComponent(projectId);
final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/room-grants');
final body = {
'room_id': roomId,
'email': email,
'permissions': permissions.toJson(),
'invite_redirect_url': ?inviteRedirectUrl?.toString(),
};
final response = await httpClient.post(uri, body: jsonEncode(body));
if (response.statusCode >= 400) {
throw MeshagentException(
'Failed to create room grant. '
'Status code: ${response.statusCode}, body: ${response.body}',
);
}
}