using DamageAssesment.Api.SurveyResponses.Interfaces; using DamageAssesment.Api.SurveyResponses.Models; using Newtonsoft.Json; namespace DamageAssesment.Api.SurveyResponses.Services { public class LocationServiceProvider :ServiceProviderBase, ILocationServiceProvider { public LocationServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger logger) : base(configuration, httpUtil, logger, "/api/Locations", configuration.GetValue("EndPointSettings:LocationUrlBase")) { } public async Task> getLocationsAsync() { try { var url = urlBase + ressource; var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null); var locations = JsonConvert.DeserializeObject>(responseJsonString); if (locations == null || !locations.Any()) return new List(); else return locations; } catch (Exception ex) { logger?.LogError($"Exception Found : {ex.Message} - Ref: LocationServiceProvider.getLocationsAsync()"); return new List(); } } } }