public async void getCrimeLocationsTest() { LocationApi locationApi = new LocationApi(); PoliceApi policeApi = new PoliceApi(); // start date first of february DateTime startDate = new DateTime(2018, 2, 1); // end date 28th of February DateTime endDate = new DateTime(2018, 2, 28); LocationData locData = locationApi.getLocationData("norwich"); string category = "bicycle-theft"; int expectedCount = 34; List<Location> locations = await policeApi.getCrimeLocations(locData, startDate, endDate, category); }
public async void getCrimeLocationsTest() { Debug.WriteLine("policeApiTest"); // Integrated location API LocationApi locationApi = new LocationApi(); PoliceApi policeApi = new PoliceApi(); // start date first of february DateTime startDate = new DateTime(2018, 2, 1); // end date 28th of February DateTime endDate = new DateTime(2018, 2, 28); LocationData locData = locationApi.getLocationData("norwich"); string category = "bicycle-theft"; int expectedCount = 34; List <Location> locations = await policeApi.getCrimeLocations(locData, startDate, endDate, category); int actualCount = locations.Count; Assert.AreEqual(expectedCount, actualCount); }
public Location SearchCountry(string code, [FromQuery] string name = "") { if (_memCache.TryGetValue("LocationInfo" + code, out Location info)) { return(info); } // Let's try to speed up if the list of countries is already here if (_memCache.TryGetValue("HistoricalCountryList", out IEnumerable <Location> countries)) { var country = countries.FirstOrDefault(c => c.LocationId.Split(':').Last().Equals(code) || string.Equals(c.Name, name, StringComparison.CurrentCultureIgnoreCase)); return(country); } var locationApi = new LocationApi(_ncdcApiManager); info = locationApi.GetCountry(code, name).Result; var cacheEntryOptions = new MemoryCacheEntryOptions() .SetAbsoluteExpiration(TimeSpan.FromDays(1)); _memCache.Set("LocationInfo" + code, info, cacheEntryOptions); return(info); }
public TogglApi(ApiConfiguration configuration, HttpClientHandler handler = null) { Ensure.Argument.IsNotNull(configuration, nameof(configuration)); var httpHandler = handler ?? new HttpClientHandler { AutomaticDecompression = GZip | Deflate }; var httpClient = new HttpClient(httpHandler); var userAgent = configuration.UserAgent; var credentials = configuration.Credentials; var serializer = new JsonSerializer(); var apiClient = new ApiClient(httpClient, userAgent); var endpoints = new Endpoints(configuration.Environment); Status = new StatusApi(endpoints, apiClient); Tags = new TagsApi(endpoints, apiClient, serializer, credentials); User = new UserApi(endpoints, apiClient, serializer, credentials); Tasks = new TasksApi(endpoints, apiClient, serializer, credentials); Clients = new ClientsApi(endpoints, apiClient, serializer, credentials); Projects = new ProjectsApi(endpoints, apiClient, serializer, credentials); Location = new LocationApi(endpoints, apiClient, serializer, credentials); Countries = new CountriesApi(endpoints, apiClient, serializer, credentials); Workspaces = new WorkspacesApi(endpoints, apiClient, serializer, credentials); Preferences = new PreferencesApi(endpoints, apiClient, serializer, credentials); ProjectsSummary = new ProjectsSummaryApi(endpoints, apiClient, serializer, credentials); TimeEntries = new TimeEntriesApi(endpoints, apiClient, serializer, credentials, userAgent); WorkspaceFeatures = new WorkspaceFeaturesApi(endpoints, apiClient, serializer, credentials); }
public TogglApi(ApiConfiguration configuration, IApiClient apiClient) { Ensure.Argument.IsNotNull(configuration, nameof(configuration)); var userAgent = configuration.UserAgent; var credentials = configuration.Credentials; var serializer = new JsonSerializer(); var endpoints = new Endpoints(configuration.Environment); Status = new StatusApi(endpoints, apiClient); Tags = new TagsApi(endpoints, apiClient, serializer, credentials); User = new UserApi(endpoints, apiClient, serializer, credentials); Tasks = new TasksApi(endpoints, apiClient, serializer, credentials); Clients = new ClientsApi(endpoints, apiClient, serializer, credentials); Projects = new ProjectsApi(endpoints, apiClient, serializer, credentials); Location = new LocationApi(endpoints, apiClient, serializer, credentials); Countries = new CountriesApi(endpoints, apiClient, serializer, credentials); Workspaces = new WorkspacesApi(endpoints, apiClient, serializer, credentials); Preferences = new PreferencesApi(endpoints, apiClient, serializer, credentials); ProjectsSummary = new ProjectsSummaryApi(endpoints, apiClient, serializer, credentials); TimeEntries = new TimeEntriesApi(endpoints, apiClient, serializer, credentials, userAgent); TimeEntriesReports = new TimeEntriesReportsApi(endpoints, apiClient, serializer, credentials); WorkspaceFeatures = new WorkspaceFeaturesApi(endpoints, apiClient, serializer, credentials); Feedback = new FeedbackApiClient(endpoints, apiClient, serializer, credentials); Timezones = new TimezonesApi(endpoints, apiClient, serializer, credentials); }
protected override void BeginProcessing() { try { var locationApi = new LocationApi(Utilities.Configuration); if (!string.IsNullOrEmpty(this.LocationId)) { if (!string.IsNullOrEmpty(LocationId)) { var location = locationApi.FindById(LocationId, depth: 5); WriteObject(location); } else { WriteWarning("Location Id must consist of region name and location name separated by '/' for example us/las "); } } else { var locations = locationApi.FindAll(depth: 5); WriteObject(locations.Items); } } catch (Exception ex) { WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null)); } }
public void getLocationDataTest() { LocationApi locationApi = new LocationApi(); // established correct values from observed Bing Api output double expectedLat = 51.506420135498; double expectedLng = -0.127210006117821; string testLocation = "london"; // actual output from LocationApi class LocationData actual = locationApi.getLocationData(testLocation); // Assert expected outputs match actual output Assert.AreEqual(expectedLat, actual.CentrePoint.Latitude); Assert.AreEqual(expectedLng, actual.CentrePoint.Longitude); }
public IEnumerable <Location> GetHistoricalCountryList() { if (_memCache.TryGetValue("HistoricalCountryList", out IEnumerable <Location> countries)) { return(countries); } var locationApi = new LocationApi(_ncdcApiManager); var countriesTask = locationApi.GetAllCountriesAsync(); countriesTask.Wait(); var cacheEntryOptions = new MemoryCacheEntryOptions() .SetAbsoluteExpiration(TimeSpan.FromDays(1)); _memCache.Set("HistoricalCountryList", countriesTask.Result, cacheEntryOptions); return(countriesTask.Result); }
private async Task <List <Event> > GetEventsAsync(LocationApi location) { List <Event> events = await _eventService.GetAll(); List <Event> nearby = new List <Event>(); foreach (var e in events) { var eventLocation = _locationService.GetById(e.LocationId.ToString()); var inRadius = Math.Pow((location.Latitude - eventLocation.Latitude) * DegreeToKm, 2) + Math.Pow((location.Longitude - eventLocation.Longitude) * DegreeToKm, 2) < Math.Pow(Radius, 2); if (inRadius) { nearby.Add(e); } } return(nearby); }
private async Task <List <Info> > GetInfoAsync(LocationApi location) { List <Info> infos = await _infoService.GetAll(); List <Info> nearby = new List <Info>(); foreach (var info in infos) { var eventLocation = _locationService.GetById(info.LocationId.ToString()); var inRadius = Math.Pow((location.Latitude - eventLocation.Latitude) * DegreeToKm, 2) + Math.Pow((location.Longitude - eventLocation.Longitude) * DegreeToKm, 2) < Math.Pow(Radius, 2); if (inRadius) { nearby.Add(info); } } return(nearby); }
private async Task <List <Apartment> > GetApartmentsAsync(LocationApi location) { List <Apartment> apartments = await _apartmentService.GetAll(); List <Apartment> nearby = new List <Apartment>(); foreach (var apartment in apartments) { var apartmentLocation = _locationService.GetById(apartment.LocationId.ToString()); var inRadius = Math.Pow((location.Latitude - apartmentLocation.Latitude) * DegreeToKm, 2) + Math.Pow((location.Longitude - apartmentLocation.Longitude) * DegreeToKm, 2) <= Math.Pow(Radius, 2); if (inRadius) { nearby.Add(apartment); } } return(nearby); }
protected override void BeginProcessing() { try { var dcApi = new LocationApi(new Configuration { Username = Credential.UserName, Password = Utilities.SecureStringToString(Credential.Password), UsedBy = Version.Get }); var dcs = dcApi.FindAll(depth: 5); Utilities.Configuration = new Configuration { Username = Credential.UserName, Password = Utilities.SecureStringToString(Credential.Password), UsedBy = Version.Get }; WriteObject("Authorization successful"); } catch (ApiException ex) { WriteError(new ErrorRecord(new Exception("Authentication failed"), ex.ErrorCode.ToString(), ErrorCategory.AuthenticationError, null)); } }
public Api(string appKey, string appId) { var f = new HttpClientFactory(appKey, appId); this.Strains = new StrainApi(f); this.Locations = new LocationApi(f); }
public LocationApiTests() { instance = new LocationApi(); }
public async Task <List <Apartment> > GetLocationApartmentsAsync(LocationApi location) { return(await GetApartmentsAsync(location)); }
public async Task <List <Event> > GetLocationEventsAsync(LocationApi location) { return(await GetEventsAsync(location)); }
public async Task <List <Info> > GetLocationInfoAsync(LocationApi location) { return(await GetInfoAsync(location)); }
private LocationManger() { client = LocationApi.InitializeClient(); }
public void Init() { instance = new LocationApi(); }