getHealthConnections method

Future<List<HealthConnection>> getHealthConnections()

Implementation

Future<List<HealthConnection>> getHealthConnections() async {

 final baseUrl = ConfigManager.current.baseUrl;
 final url = Uri.parse('$baseUrl$_healthConnectionsEndpoint');
 final token = await storage.getTokenOrThrow();

 final headers = {
   'Authorization': 'Bearer $token',
 };


 try {
   final response = await http.get(
     url,
     headers: headers,
   );
   final responseDataReady = await _checkResponseData(response, 'Failed to get Connected Providers');
   if (responseDataReady) {
     final List<dynamic>? jsonList = jsonDecode(response.body);
     return jsonList?.map((json) => HealthConnection.fromJson(json)).toList() ?? [];
   }
   return [];
 } on SDKException {
   rethrow;
 } catch (e) {
   throw SDKException.withMessage(
     'PlumCheck SDK Exeption - Failed to get Connected Providers, Description: ${e.toString()}');
 }
  }