Esempio n. 1
0
        public static List <PopularPlacesModel> GetPopularPlaces(HereApiQuery queryParams)
        {
            //double lat = queryParams.Lat;
            //double lon = queryParams.Lon;
            //make request
            //string query = "?";
            //query += String.Format("at={0}%2C{1}", lat, lon);
            ////            query += "at=" + "-36.8623%2C174.7494";//TODO use location value
            //query += "&app_id=" + KEY.ID;
            //query += "&app_code=" + KEY.CODE;
            ////string fullUrl = HereUrl.BASE + HereUrl.Explore + query;

            string    fullUrl = HereUrl.GetExplore(queryParams);
            WebClient client  = new WebClient();
            string    result  = client.DownloadString(fullUrl);

            var placesExploreJsonObj = JsonConvert.DeserializeObject <PlacesExplore>(result);

            List <PopularPlacesModel> popularPlacesList = new List <PopularPlacesModel>();

            //turn into  model
            foreach (var item in placesExploreJsonObj.results.items)
            {
                if (item != null)
                {
                    PopularPlacesModel popularPlace = new PopularPlacesModel()
                    {
                        Id       = item.id,
                        Title    = item.title,
                        Distance = item.distance,
                        Category = new CategoryModel {
                            Name = item.category.title, Value = item.category.id
                        },
                        AverageRating = item.averageRating,
                        DetailHref    = ParseDetailHref(item.href)
                    };

                    popularPlacesList.Add(popularPlace);
                }
            }

            return(popularPlacesList);
        }
Esempio n. 2
0
        public void TestCategory()
        {
            var destList = HereService.GetAllDestinations();

            //auckland as destination
            var dest1      = destList[0];
            var cat        = HereService.GetPlacesCategories();
            var item       = cat.Select(x => x.Value);
            var categories = String.Join(",", item.ToArray());


            //When passing into the api/here/getPopularPlaces, construct the queryParams as follow
            HereApiQuery queryParams = new HereApiQuery
            {
                Lat      = dest1.Latitude,
                Lon      = dest1.Longitude,
                Category = categories
            };
            //get a list of popular places in Auckland
            var popularPlace = HereService.GetPopularPlaces(queryParams);
        }
Esempio n. 3
0
        public void TestMethod1()
        {
            try
            {
                var destList = HereService.GetAllDestinations();

                //auckland as destination
                var          dest1       = destList[0];
                HereApiQuery queryParams = new HereApiQuery
                {
                    Lat = dest1.Latitude,
                    Lon = dest1.Longitude
                };
                //get a list of popular places in Auckland
                var popularPlace = HereService.GetPopularPlaces(queryParams);

                //get the detail of a popularPlace (activity detail)
                var detail = HereService.GetPopularPlaceDetail(popularPlace[0]);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Esempio n. 4
0
        public HttpResponseMessage GetPopularLocation([FromBody] HereApiQuery queryParams)
        {
            var popularPlacesList = HereService.GetPopularPlaces(queryParams);

            return(Request.CreateResponse(HttpStatusCode.OK, popularPlacesList));
        }