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