public async Task <Geocode> Geocode(string postcode) { try { _logger.LogInformation($"Getting geo code for postcode {postcode}"); var result = await _outerApiClient.Get <GetGeoPointResponse>(new GetGeoCodeRequest(postcode)); if (result?.GeoPoint?.Latitude != null && result?.GeoPoint?.Longitude != null) { return(new Geocode { GeoCodeMethod = Domain.Entities.GeoCodeMethod.OuterApi, Latitude = result.GeoPoint.Latitude, Longitude = result.GeoPoint.Longitude }); } return(null); } catch (Exception e) { string message = $"Get geocode failed for postcode: {postcode}"; _logger.LogDebug(message); throw new Exception(message, e); } }
private async Task <IEnumerable <TrainingProvider> > GetProviders() { _logger.LogTrace("Getting Providers from Outer Api"); var retryPolicy = GetApiRetryPolicy(); var result = await retryPolicy.Execute(context => _outerApiClient.Get <GetProvidersResponse>(new GetProvidersRequest()), new Dictionary <string, object>() { { "apiCall", "Providers" } }); return(result.Providers.Select(c => (TrainingProvider)c)); }
private async Task <IEnumerable <ApprenticeshipProgramme> > GetTrainingProgrammes() { _logger.LogTrace("Getting Training Programmes from Outer Api"); var retryPolicy = GetApiRetryPolicy(); var result = await retryPolicy.ExecuteAsync(context => _outerApiClient.Get <GetTrainingProgrammesResponse>(new GetTrainingProgrammesRequest()), new Dictionary <string, object>() { { "apiCall", "Standards" } }); return(result.TrainingProgrammes.Select(c => (ApprenticeshipProgramme)c)); }
public async Task <GetAddressesListResponse> GetAddresses(string searchTerm) { try { return(await _outerApiClient.Get <GetAddressesListResponse>(new GetAddressesRequest(searchTerm))); } catch (Exception e) { string message = $"Get addresses failed for search term: {searchTerm}."; _logger.LogDebug(message); throw new Exception(message, e); } }
public async Task <IEnumerable <StandardOptions> > GetStandardOptions() { try { var standardOptionsResponse = await _outerApiClient.Get <GetStandardOptionsListResponse>(new GetStandardOptionsRequest()); return(standardOptionsResponse.StandardOptions.Select(standard => new StandardOptions { StandardUId = standard.StandardUId, StandardCode = standard.LarsCode, StandardReference = standard.IfateReferenceNumber, Version = standard.Version.ToString("#.0"), CourseOption = standard.Options })); } catch (Exception ex) { _logger.LogError(ex, "STANDARD OPTIONS: Failed to get standard options"); } return(null); }
public async Task <IEnumerable <GetStandardsListItem> > GetActiveStandards() { var response = await _outerApiClient.Get <GetStandardsListResponse>(new GetActiveStandardsRequest()); return(response.Standards); }