getAgentDetailsById method

Future getAgentDetailsById(
  1. String agentId
)

Implementation

Future<dynamic> getAgentDetailsById(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'];
    return data;
  } else {
    print('Error status code: ${response.statusCode}');
    print('Error response body: ${response.body}');
    throw Exception('Failed to load agent with ID: $agentId');
  }
}