using DamageAssesment.Api.Responses.Interfaces; using DamageAssesment.Api.Responses.Models; using Newtonsoft.Json; namespace DamageAssesment.Api.Responses.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(string token) { try { var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null, token); 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(); } } } }