getAgentById method

Future<deployPayload?> getAgentById(
  1. String agentId
)

Implementation

Future<deployPayload?> getAgentById(String agentId) async {
  try {
    final response = await http.get(
      Uri.parse('$_baseUrlStage?agent-id=$agentId'),
      // headers: {
      //   'Authorization': authorizationToken,
      // },
    );

    if (response.statusCode == 200) {
      final Map<String, dynamic> json = jsonDecode(response.body);
      //print('Raw JSON response: $json');
      return deployPayload.fromJson(json);
    }  else {
      throw Exception('Failed to load agent details');
    }
  } catch (e) {
    print('Exception while fetching agent details: $e');
    return null;
  }
}