getAgentById method
Implementation
Future<Agent> getAgentById(String agentId) async {
final response = await http.get(
Uri.parse('$baseUrl/getHaivaAgentConfig?agent-id=$agentId'),
headers: {
'Authorization': 'Bearer $token',
'Content-Type': 'application/json',
},
);
if (response.statusCode == 200) {
final Map<String, dynamic> data = json.decode(response.body);
Constants.orgId = data['org_id'];
print("orgid = ${Constants.orgId}");
return Agent.fromJson(data);
} else {
print('Error status code: ${response.statusCode}');
print('Error response body: ${response.body}');
throw Exception('Failed to load agent with ID: $agentId');
}
}