using DamageAssesment.Api.Responses.Interfaces; using DamageAssesment.Api.Responses.Models; using Newtonsoft.Json; namespace DamageAssesment.Api.Responses.Services { public class LocationServiceProvider :ServiceProviderBase, ILocationServiceProvider { public LocationServiceProvider(IConfiguration configuration, IHttpUtil httpUtil, ILogger logger) : base(configuration, httpUtil, logger, configuration.GetValue("RessourceSettings:Location"), configuration.GetValue("EndPointSettings:LocationUrlBase")) { } public async Task> getLocationsAsync(string token) { try { var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null, token); 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(); } } } }