Exemplo n.º 1
0
        /// <summary>
        /// This pulls a hyper-local 10 day blotter based on a position and a radius distance.
        /// </summary>
        /// <returns>The local blotter.</returns>
        /// <param name="latitutde">Latitutde.</param>
        /// <param name="longitude">Longitude.</param>
        /// <param name="distance">Distance.</param>
        public async static Task <CrimeReport[]> GetLocalBlotter(double latitutde, double longitude, double distance)
        {
            JsonWebClient cli = new JsonWebClient();

            string getUri = GetUri(BLOTTER, string.Format($"/{latitutde}/{longitude}/{distance}/"));
            var    resp   = await cli.DoRequestJsonAsync <CrimeReport[]>(getUri);

            return(resp);
        }
Exemplo n.º 2
0
        public async static Task <YTD[]> GetYTD(int neighborhood)
        {
            JsonWebClient cli = new JsonWebClient();

            Debug.WriteLine($"Requesting YTD crime totals for neighborhood ID: {neighborhood}");

            string getUri = GetUri(GETYTD, string.Format("/{0}/", neighborhood));
            var    resp   = await cli.DoRequestJsonAsync <YTD[]>(getUri);

            return(resp);
        }
Exemplo n.º 3
0
        public async static Task <NewsContributionResponse> FlagNewsStory(NewsFlagConcern reason)
        {
            JsonWebClient cli = new JsonWebClient();

            // This is f****d up but this API stack will not allow a message body to go through in this case.
            // And % sign is verboten in URL string, so we have to replace that with $ signs.  The server will
            // reverse this process on the other end.

            string url = reason.URL;

            url = System.Net.WebUtility.UrlEncode(url);
            url = url.Replace('%', '$');

            string getUri = GetUri(NEWS, $"/{url}/{reason.Reason}/{reason.DCN}/");

            var resp = await cli.DoDeleteJson <NewsContributionResponse>(getUri);

            return(resp);
        }
Exemplo n.º 4
0
        public async static Task <bool> RegisterPushNotifications(string token,
                                                                  PushNotification.Plugin.Abstractions.DeviceType deviceType,
                                                                  double longitude, double latitude)
        {
            JsonWebClient cli = new JsonWebClient();

            string getUri = GetUri(PUSH);

            var notification = new crime_notification();

            notification.DeviceToken = token;
            notification.DeviceType  = Convert.ToInt32(deviceType);
            notification.Longitude   = longitude;
            notification.Latitude    = latitude;
            notification.Version     = Global.VERSION;

            Debug.WriteLine($"About to post registration to server... LONG: {longitude}  LAT: {latitude}");
            await cli.DoSilentPost(getUri, JsonConvert.SerializeObject(notification));

            return(true);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the 10-day blotter given an array of neighborhood IDs. The Neighborhoods are found using the call to Neighborhoods().
        /// </summary>
        /// <returns>The blotter.</returns>
        /// <param name="neighborhoods">Neighborhoods.</param>
        public async static Task <CrimeReport[]> GetBlotter(int[] neighborhoods)
        {
            JsonWebClient cli = new JsonWebClient();

            string hoods = "";

            for (int i = 0; i < neighborhoods.Length; i++)
            {
                hoods += neighborhoods[i].ToString();
                if (i != neighborhoods.Length - 1)
                {
                    hoods += ",";
                }
            }

            string getUri = GetUri(BLOTTER, string.Format("/{0}/", hoods));

            var resp = await cli.DoRequestJsonAsync <CrimeReport[]>(getUri);

            return(resp);
        }