コード例 #1
0
        public async Task <List <Person> > GetForcePeople(string id)
        {
            var apiCall = ClientHelperExtensions.ToFullUrl(ApiUrl, $"/forces/{id}/people");

            HttpResponseMessage response = await HttpClient.GetAsync(apiCall);

            await HandleResponse(response);

            string responseBody = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <List <Person> >(responseBody);

            return(result);
        }
コード例 #2
0
        public async Task <NeighbourhoodResult> GetNeighbourhoodByLocation(string lat, string lng)
        {
            var apiCall = ClientHelperExtensions.ToFullUrl(ApiUrl, $"/locate-neighbourhood?q={lat},{lng}");

            HttpResponseMessage response = await HttpClient.GetAsync(apiCall);

            await HandleResponse(response);

            string responseBody = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <NeighbourhoodResult>(responseBody);

            return(result);
        }
コード例 #3
0
        public async Task <List <Availability> > GetAvailability()
        {
            var apiCall = ClientHelperExtensions.ToFullUrl(ApiUrl, "/crimes-street-dates");

            HttpResponseMessage response = await HttpClient.GetAsync(apiCall);

            await HandleResponse(response);

            string responseBody = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <List <Availability> >(responseBody);

            return(result);
        }
コード例 #4
0
        public async Task <List <Priority> > GetNeighbourhoodPriorities(string forceId, string id)
        {
            var apiCall = ClientHelperExtensions.ToFullUrl(ApiUrl, $"/{forceId}/{id}/priorities");

            HttpResponseMessage response = await HttpClient.GetAsync(apiCall);

            await HandleResponse(response);

            string responseBody = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <List <Priority> >(responseBody);

            return(result);
        }
コード例 #5
0
        public async Task <OutcomesForCrime> GetOutcomesForCrime(string id)
        {
            var apiCall = ClientHelperExtensions.ToFullUrl(ApiUrl, $"/outcomes-for-crime/{id}");

            HttpResponseMessage response = await HttpClient.GetAsync(apiCall);

            await HandleResponse(response);

            string responseBody = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <OutcomesForCrime>(responseBody, Converter.Settings);

            return(result);
        }
コード例 #6
0
        public async Task <CrimeLastUpdated> GetCrimeLastUpdated()
        {
            var apiCall = ClientHelperExtensions.ToFullUrl(ApiUrl, "/crime-last-updated");

            HttpResponseMessage response = await HttpClient.GetAsync(apiCall);

            await HandleResponse(response);

            string responseBody = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <CrimeLastUpdated>(responseBody);

            return(result);
        }
コード例 #7
0
        public async Task <List <Category> > GetCrimeCategories(string date)
        {
            var apiCall = ClientHelperExtensions.ToFullUrl(ApiUrl, $"/crime-categories?date={date}");

            HttpResponseMessage response = await HttpClient.GetAsync(apiCall);

            await HandleResponse(response);

            string responseBody = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <List <Category> >(responseBody, Converter.Settings);

            return(result);
        }
コード例 #8
0
        public async Task <List <CrimeAtLocation> > GetCrimesAtLocation(string date, string lat, string lng)
        {
            var apiCall = ClientHelperExtensions.ToFullUrl(ApiUrl, $"/crimes-at-location?date={date}&lat={lat}&lng={lng}");

            HttpResponseMessage response = await HttpClient.GetAsync(apiCall);

            await HandleResponse(response);

            string responseBody = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <List <CrimeAtLocation> >(responseBody, Converter.Settings);

            return(result);
        }
コード例 #9
0
        public async Task <List <Crime> > GetStreetCrimeByLocation(string id, string lat, string lng, string date = null)
        {
            var dateParameter = !string.IsNullOrEmpty(date) ? $"&date={date}" : string.Empty;
            var apiCall       = ClientHelperExtensions.ToFullUrl(ApiUrl, $"/crimes-street/{id}?lat={lat}&lng={lng}{dateParameter}");

            HttpResponseMessage response = await HttpClient.GetAsync(apiCall);

            await HandleResponse(response);

            string responseBody = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <List <Crime> >(responseBody, Converter.Settings);

            return(result);
        }
コード例 #10
0
        public async Task <List <StopAndSearch> > GetStopAndSearchByForce(string forceId, string date = null)
        {
            var dateParameter = !string.IsNullOrEmpty(date) ? $"&date={date}" : string.Empty;
            var apiCall       = ClientHelperExtensions.ToFullUrl(ApiUrl, $"/stops-force?force={forceId}{dateParameter}");

            HttpResponseMessage response = await HttpClient.GetAsync(apiCall);

            await HandleResponse(response);

            string responseBody = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <List <StopAndSearch> >(responseBody);

            return(result);
        }
コード例 #11
0
        public async Task <List <Neighbourhood> > GetNeighbourhoods(string id)
        {
            var apiCall = ClientHelperExtensions.ToFullUrl(ApiUrl, $"/{id}/neighbourhoods");

            HttpResponseMessage response = await HttpClient.GetAsync(apiCall);

            await HandleResponse(response);

            string responseBody = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <List <Neighbourhood> >(responseBody);

            result.Sort((x, y) => x.Name.CompareTo(y.Name));
            return(result);
        }
コード例 #12
0
        public async Task <List <OutcomeAtLocation> > GetOutcomesAtCustomLocation(string poly, string date = null)
        {
            var dateParameter = !string.IsNullOrEmpty(date) ? $"&date={date}" : string.Empty;
            var apiCall       = ClientHelperExtensions.ToFullUrl(ApiUrl, $"/outcomes-at-location?poly={poly}{dateParameter}");

            HttpResponseMessage response = await HttpClient.GetAsync(apiCall);

            await HandleResponse(response);

            string responseBody = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <List <OutcomeAtLocation> >(responseBody, Converter.Settings);

            return(result);
        }
コード例 #13
0
        public async Task <List <CrimesNoLocation> > GetCrimesNoLocation(string category, string force, string date = null)
        {
            var dateParameter = !string.IsNullOrEmpty(date) ? $"&date={date}" : string.Empty;
            var apiCall       = ClientHelperExtensions.ToFullUrl(ApiUrl, $"/crimes-no-location?category={category}&force={force}{dateParameter}");

            HttpResponseMessage response = await HttpClient.GetAsync(apiCall);

            await HandleResponse(response);

            string responseBody = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <List <CrimesNoLocation> >(responseBody, Converter.Settings);

            return(result);
        }