fetchProvidersByAppId function

Future<List<ProviderV2>> fetchProvidersByAppId(
  1. String appId,
  2. String providerId
)

Implementation

Future<List<ProviderV2>> fetchProvidersByAppId(
    String appId, String providerId) async {
  try {
    final response = await http.get(Uri.parse(
        '${Constants.GET_PROVIDERS_BY_ID_API}/$appId/provider/$providerId'));
    final res = json.decode(response.body);
    List<dynamic> rawProviders = res['providers']['httpProvider'];
    final providers = rawProviders.map((p) => ProviderV2.fromJson(p)).toList();
    return providers;
  } catch (err) {
    logger.e(err);
    throw Exception('Error fetching provider with AppId: $appId');
  }
}