updateAgentRoomGrant method

Future<void> updateAgentRoomGrant({
  1. required String projectId,
  2. required String agentId,
  3. required String roomId,
  4. AgentRoomGrant? permissions,
})

Implementation

Future<void> updateAgentRoomGrant({
  required String projectId,
  required String agentId,
  required String roomId,
  AgentRoomGrant? permissions,
}) async {
  final encodedProjectId = Uri.encodeComponent(projectId);
  final encodedAgentId = Uri.encodeComponent(agentId);
  final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/agent-room-grants/$encodedAgentId');
  final body = {'agent_id': agentId, 'room_id': roomId, 'permissions': (permissions ?? AgentRoomGrant()).toJson()};
  final response = await httpClient.put(uri, body: jsonEncode(body));

  if (response.statusCode >= 400) {
    throw MeshagentException(
      'Failed to update agent room grant. '
      'Status code: ${response.statusCode}, body: ${response.body}',
    );
  }
}