Пример #1
0
 private static List<YelpResult> GenerateSchedule(string Location, string radius, bool isKidFriendly)
 {
     var o = GetOptions();
     var y = new Yelp(o);
     string categoryList = "";
     categoryList = setUpDefaultCategories(categoryList);
     categoryList = populateRemainingCategories(categoryList);
     var searchOptions = new YelpSharp.Data.Options.SearchOptions();
     var categories = categoryList.Split(',');
     List<YelpResult> results = new List<YelpResult>();
     foreach (var category in categories){
         searchOptions.GeneralOptions = new GeneralOptions()
         {
             term = category
         };
         searchOptions.LocationOptions = new LocationOptions()
         {
             location = Location,
         };
         var serchResult = y.Search(searchOptions).businesses;
         //TODO: IF no search result gotta figure out what else to do...
         if (serchResult == null || serchResult.Count() == 0)
             continue;
         Random rnd = new Random();
         int r = rnd.Next(0 , serchResult.Count - 1);
         serchResult.Remove(serchResult[r]);
         YelpResult yResult = new YelpResult(0, serchResult[r], serchResult);
         results.Add(yResult);
     }
     var retVals = insertDestinationsIntoTimeSlots(results);
     return retVals.OrderBy(f => f.Hour).ToList();
 }
Пример #2
0
        public void SimpleTest()
        {
            string _term = "food";
            string _location = "Denver";

            var y = new Yelp(new Options()
                        {
                            ConsumerKey = _ConsumerKey,
                            ConsumerSecret = _ConsumerSecret,
                            AccessToken = _Token,
                            AccessTokenSecret = _TokenSecret
                        });

            var searchOptions = new SearchOptions();
            searchOptions.GeneralOptions = new GeneralOptions()
            {
                term = _term
            };

            searchOptions.LocationOptions = new LocationOptions()
            {
                location = _location
            };

            var results = y.Search(searchOptions);
        }
Пример #3
0
        public async void GetBusiness(string businessId)
        {
            this.Business = null;

            Yelp yelp = new Yelp(Config.Options);

            this.Business = await yelp.GetBusiness(businessId);
        }
Пример #4
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     var yelp = new Yelp(Config.Options);
     var task = yelp.Search(txtSearch.Text, txtLocation.Text);
     task.ContinueWith((results) =>
     {
         App.ViewModel = new ViewModels.SearchResultViewModel(results.Result);
         NavigationService.Navigate(new Uri("/SearchResultsPage.xaml"));
     });
 }
Пример #5
0
 public void BasicTest()
 {
     var y = new Yelp(Config.Options);
     var results = y.Search("coffee", "seattle, wa").Result;
     if (results.error != null)
     {
         Assert.Fail(results.error.text);
     }
     Console.WriteLine(results);
 }
Пример #6
0
 public CoffeeSearcher()
 {
     YelpElement yelpConfig = ((ApiKeySection)ConfigurationManager.GetSection(ApiKeySection.SectionName)).Yelp;
     this._yelp = new Yelp(new Options
     {
         ConsumerKey = yelpConfig.ConsumerKey,
         ConsumerSecret = yelpConfig.ConsumerSecret,
         AccessToken = yelpConfig.Token,
         AccessTokenSecret = yelpConfig.TokenSecret,
     });
 }
Пример #7
0
 private static SearchResults GetSearchResults(double lat, double lon, string categories)
 {
     Yelp yelp = new Yelp(WebApiApplication.YelpOptions);
     var results = yelp.Search(new SearchOptions
     {
         GeneralOptions = new GeneralOptions { category_filter = categories, radius_filter = 30000, term = "", limit = 20, offset = 0, sort = 2, deals_filter = false },
         LocationOptions = new CoordinateOptions
         {
             latitude = lat,
             longitude = lon
         }
     });
     return results;
 }
        private void GetYelpData(Guid id, string yelpId)
        {
            var options = new Options
            {
                AccessToken = ConfigurationManager.AppSettings["YelpAPIToken"],
                AccessTokenSecret = ConfigurationManager.AppSettings["YelpAPITokenSecret"],
                ConsumerKey = ConfigurationManager.AppSettings["YelpAPIConsumerKey"],
                ConsumerSecret = ConfigurationManager.AppSettings["YelpAPIConsumerSecret"]
            };

            var yelp = new Yelp(options);
            Business business = yelp.GetBusiness(yelpId).Result;
            if (business != null)
                UpdateAccount(id, business.rating);
        }
Пример #9
0
        public async void Search()
        {
            this.Businesses.Clear();

            Yelp yelp = new Yelp(Config.Options);

            SearchResults searchResults = await yelp.Search(this.SearchOptions);
            
            if(searchResults != null && searchResults.businesses != null)
            {
                for (int count = 0; count < searchResults.businesses.Count; count++)
                {
                    this.Businesses.Add(searchResults.businesses[count]);
                }
            }            
            
        }
Пример #10
0
        public void AdvancedTest()
        {
            var o = GetOptions();
            var y = new Yelp(o);

            var searchOptions = new SearchOptions();
            searchOptions.GeneralOptions = new GeneralOptions()
            {
                term = "coffee"
            };

            searchOptions.LocationOptions = new LocationOptions()
            {
                location = "seattle"
            };

            var results = y.Search(searchOptions);
            Console.WriteLine(results);
        }
Пример #11
0
        public void AdvancedTest()
        {
            var y = new Yelp(Config.Options);

            var searchOptions = new SearchOptions();
            searchOptions.GeneralOptions = new GeneralOptions()
            {
                term = "coffee"
            };

            searchOptions.LocationOptions = new LocationOptions()
            {
                location = "seattle"
            };

            var results = y.Search(searchOptions).Result;
            Assert.IsTrue(results.businesses != null);
            Assert.IsTrue(results.businesses.Count > 0);
        }
Пример #12
0
        public void LimitTest()
        {
            var y = new Yelp(Config.Options);
            var searchOptions = new SearchOptions()
            {
                GeneralOptions = new GeneralOptions()
                {
                    term = "coffee",
                    limit = 15,
                },
                LocationOptions = new LocationOptions()
                {
                    location = "seattle, wa"
                }
            };
            var results = y.Search(searchOptions).Result;
            if (results.error != null)
            {
                Assert.Fail(results.error.text);
            }
            if (results.businesses.Count != 15)
            {
                Assert.Fail(string.Format("Limit test returned {0} results instead of 15", results.businesses.Count));
            }

            Console.WriteLine(results);
        }
Пример #13
0
 public void BusinessTest()
 {
     var y = new Yelp(Config.Options);
     var results = y.GetBusiness("yelp-san-francisco").Result;
     Assert.IsTrue(results != null);
 }
Пример #14
0
 public void BasicTest()
 {
     var o = GetOptions();
     var y = new Yelp(o);
     var results = y.Search("coffee", "seattle, wa");
     Console.WriteLine(results);
 }
Пример #15
0
 public void LocationByCoordinates()
 {
     var yelp = new Yelp(Config.Options);
     var searchOptions = new YelpSharp.Data.Options.SearchOptions()
     {
         LocationOptions = new BoundOptions()
         {
             sw_latitude = 37.9,
             sw_longitude = -122.5,
             ne_latitude = 37.788022,
             ne_longitude = -122.399797
         }
     };
     var results = yelp.Search(searchOptions).Result;
     Assert.IsTrue(results.businesses.Count > 0);
 }
Пример #16
0
        public void BusinessReviewTest()
        {
            var y = new Yelp(Config.Options);
            var results = y.GetBusiness("yelp-san-francisco").Result;
            Assert.IsTrue(results != null);

            Assert.IsNotNull(results.reviews);
            Assert.AreNotEqual(0, results.review_count);

            Assert.AreNotEqual(0, results.reviews.Count);

            var firstReview = results.reviews[0];
            Assert.IsNotNull(firstReview.rating_image_url);
            Assert.IsNotNull(firstReview.rating_image_small_url);
            Assert.IsNotNull(firstReview.rating_image_large_url);
        }
Пример #17
0
        public void VerifyTermWithEscapedCharacter()
        {
            var y = new Yelp(Config.Options);
            var searchOptions = new SearchOptions
            {
                GeneralOptions = new GeneralOptions
                {
                    term = "Frimark Keller & Associates"
                },
                LocationOptions = new LocationOptions
                {
                    location = "60173"
                }
            };

            var results = y.Search(searchOptions).Result;
            Assert.IsTrue(results.businesses != null);
            Assert.IsTrue(results.businesses.Count > 0);
        }
Пример #18
0
 public void LocationByCoordinates()
 {
     var o = GetOptions();
     var yelp = new Yelp(o);
     var searchOptions = new YelpSharp.Data.Options.SearchOptions()
     {
         GeneralOptions = new GeneralOptions() { radius_filter = 5 },
         LocationOptions = new CoordinateOptions()
         {
             latitude = 37.788022,
             longitude = -122.399797
         }
     };
     var results = yelp.Search(searchOptions);
     Console.WriteLine(results);
 }
Пример #19
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            /* initiate duplicate checker with excel file */
            if (xlWorkbook == null)
            {
                xlApp = new Excel.Application();
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "Excel Documents (*.xlsx)|*.xlsx";
                ofd.ShowDialog();

                xlWorkbook = xlApp.Workbooks.Open(ofd.FileName, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                xlWorksheet = (Excel._Worksheet)xlWorkbook.Sheets[1];
            }
            /* Save settings */
            SaveSettings();
            checkListCategories.Items.Clear();

            statusBotStrip.Text = "Status: Searching";

            string[] countriesArray = new string[]{"United States", "Singapore", "Australia", "New Zealand"};

            if (searchCity.Lines.Length == 0)
                searchCity.Text = countriesArray[searchCountry.SelectedIndex];

            for (int locationline = 0; locationline < searchCity.Lines.Length; locationline++)
            {
                for (int categoryline = 0; categoryline < searchCategory.Lines.Length; categoryline++)
                {
                    if (searchGoogle.Checked)
                    {
                        /* Conduct first page search */
                        string searchCritera = generateSearchQuery(categoryline, locationline);
                        statusBotStrip.Text = "Status: Searching " + searchCritera + " on Google";
                        searchCritera = searchCritera.Replace(" ", "+");
                        string json = getMapList(searchCritera);
                        var jarray = JsonConvert.DeserializeObject<RootObjectPlaces>(json);

                        if (jarray.status == "OK")
                        {
                            /* Populate the company list */
                            populateGoogleCompanies(jarray, xlWorksheet);

                            /* Conduct next page search until reached end of search */
                            string nextPageToken = jarray.next_page_token;
                            while (nextPageToken != null)
                            {
                                json = getMapList(searchCritera + "&pagetoken=" + nextPageToken);
                                jarray = JsonConvert.DeserializeObject<RootObjectPlaces>(json);
                                /* Populate again */
                                populateGoogleCompanies(jarray, xlWorksheet);
                                nextPageToken = jarray.next_page_token;
                            }
                        }
                        else if (jarray.status == "ZERO_RESULTS")
                            textDebugger.AppendText("Google found no results searching:" + searchCritera + Environment.NewLine);
                        else
                            textDebugger.AppendText("Google Search Error: " + jarray.error_message + " when searching: "
                                + searchCritera + Environment.NewLine);
                    }
                    saveDataSet();  
                    if (searchYelp.Checked)
                    {
                        string searchCriteria = searchCategory.Lines[categoryline];
                        string search_Country = searchCountry.Text;
                        string searchArea = "";
                        searchArea = generateSearchQueryArea(locationline);
                        statusBotStrip.Text = "Status: Searching " + searchArea + " " + searchCriteria + " on Yelp";
                        var yelp = new Yelp(Config.Options);
                        var searchOpt = new SearchOptions();
                        searchOpt.GeneralOptions = new GeneralOptions() { term = searchCriteria, radius_filter = 50000, category_filter = "homeservices", sort = 1 };
                        searchOpt.LocationOptions = new LocationOptions() { location = searchArea };
                        searchOpt.LocaleOptions = new LocaleOptions() { cc = search_Country };
                        var task = yelp.Search(searchOpt);

                        int pages = (int)Math.Ceiling(task.Result.total / 20.0);
                        for (int p = 1; p <= pages; p++)
                        {
                            for (int i = 0; i <= 19; i++)
                            {
                                try
                                {
                                    Business business = task.Result.businesses[i];
                                    string companyName = business.name;
                                    string companyAddress = String.Join(" ", business.location.address);
                                    string companyCity = business.location.city == null ? "" : business.location.city;
                                    string companyState = business.location.state_code == null ? "" : business.location.state_code;
                                    string companyZip = business.location.postal_code == null ? "" : business.location.postal_code;
                                    string companyCountry = business.location.country_code == null ? "" : business.location.country_code;
                                    string companyPhone = business.phone == null ? "" : fixPhoneNumberFormat(business.phone);
                                    if (!checkIfExistInCurrentList(companyName, companyPhone, "No website yet", "No email on 1st check"))
                                    {
                                        string companyWebsite = findYelpCompanyWebsite(task.Result.businesses[i].url);
                                        bool companyHasPicturesOrPersonalWebsite = true;
                                        if (companyWebsite == "No company website")
                                        {
                                            companyHasPicturesOrPersonalWebsite = doesYelpCompanyHavePictures();
                                            companyWebsite = task.Result.businesses[i].url;
                                        }
                                        if (companyHasPicturesOrPersonalWebsite)
                                        {
                                            List<string> companyCategories = new List<string>();
                                            foreach (string[] category in task.Result.businesses[i].categories)
                                                companyCategories.Add(category[0]);
                                            string companyHouzzSearch = generateHouzzSearchLink(replaceCompanyNamePTE(companyName),
                                                searchArea.Remove(0, searchArea.LastIndexOfAny(new char[] { ',', ' ' }) + 1).Replace(" ", ""), true);
                                            AddtoList(companyName, companyAddress, companyCity, companyState, companyZip, companyCountry,
                                                companyPhone, "No email", "", companyWebsite, companyHouzzSearch, companyCategories);
                                        }
                                    }
                                }
                                catch { }
                            }
                            var searchOptions = new SearchOptions();
                            searchOptions.GeneralOptions = new GeneralOptions()
                            {
                                term = searchCriteria,
                                offset = (p * 20),
                                radius_filter = 50000,
                                category_filter = "homeservices",
                                sort = 1 //distance
                            };
                            searchOptions.LocationOptions = new LocationOptions() { location = searchArea };
                            searchOptions.LocaleOptions = new LocaleOptions() { cc = search_Country };
                            task = yelp.Search(searchOptions);
                        }
                    }
                    saveDataSet();
                    if (searchFacebook.Checked)
                    {
                        string searchCriteria = searchCategory.Lines[categoryline];
                        string searchArea = generateSearchQueryArea(locationline);

                        statusBotStrip.Text = "Status: Searching " + searchArea + " " + searchCriteria + " on Facebook";

                        string[] jsonFacebookSearchResults = new string[5];
                        jsonFacebookSearchResults[1] = getFacebookSearchList(searchCriteria, searchArea, "page", false);
                        jsonFacebookSearchResults[2] = getFacebookSearchList(searchCriteria, searchArea, "page", true);
                        jsonFacebookSearchResults[3] = getFacebookSearchList(searchCriteria, searchArea, "place", false);
                        jsonFacebookSearchResults[4] = getFacebookSearchList(searchCriteria, searchArea, "place", true);

                        for (int i = 1; i <= 4; i++)
                        {
                            var jarray = JsonConvert.DeserializeObject<RootObjectFacebook>(jsonFacebookSearchResults[i]);
                            if( jarray.data != null & jarray.data.Count > 0 )
                                populateFacebookCompanies(jarray);
                            else if( jarray.error != null)
                                textDebugger.AppendText("Facebook search error: " + jarray.error.message + Environment.NewLine);
                        }
                    }
                    saveDataSet();
                    if (searchYellowPages.Checked)
                    {
                        /* Conduct first page search */
                        string searchCriteria = searchCategory.Lines[categoryline].Replace(" ", "+");
                        string search_Country = searchCountry.Text;
                        string searchArea = generateSearchQueryArea(locationline);
                        statusBotStrip.Text = "Status: Searching " + searchArea + " " + searchCriteria + " on YellowPages";
                        for (int i = 1; i <= 30; i++) /* 30 pages even if they do not reach 30 */
                        {
                            string json = getYPList(searchCriteria, searchArea, i);
                            var jarray = JsonConvert.DeserializeObject<RootObjectYP>(json);

                            if (jarray.searchResult.metaProperties.errorCode == "")
                            {
                                // Populate the company list 
                                if (jarray.searchResult.metaProperties.listingCount > 0)
                                {
                                    populateYPCompanies(jarray, xlWorksheet);
                                }
                                else
                                {
                                    textDebugger.AppendText("Error on YP page " + i.ToString() + ": No results found searching: " 
                                        + searchArea + " " + searchCriteria + Environment.NewLine);
                                    break;
                                }
                            }
                            else
                                textDebugger.AppendText("Error on YP page " + i.ToString() + ": " + jarray.searchResult.metaProperties.message
                                    + Environment.NewLine);
                        }
                    }
                    saveDataSet();  
                    if( searchFactual.Checked )
                    {
                        string searchCriteria = searchCategory.Lines[categoryline];
                        string search_Country = searchCountry.Text;
                        string search_City = "", search_State = "";
                        Factual factual = new Factual(apiFactualKey, apiFactualSecret);
                        Query q = new Query().SearchExact(searchCriteria);
                        if (search_Country != "US")
                        {
                            q.And(q.Field("country").Equal(search_Country), q.Limit(50));
                            statusBotStrip.Text = "Status: Searching" + search_Country + " " + searchCriteria + " on Factual";
                        }
                        if (search_Country == "US")
                        {
                            q.And(q.Field("country").Equal(search_Country), q.Field("region").Equal(search_State), q.Field("locality").Equal(search_City), q.Limit(50));
                            search_City = searchCity.Lines[locationline];
                            search_State = searchState.Text;
                            statusBotStrip.Text = "Status: Searching " + search_Country + " " + search_City
                                + " " + searchCriteria + " on Factual";
                        }
                            /* if (searchCategoryFilters != "")
                            q.Field("category_labels").Includes(searchCategoryFilters); */
                        int page = 1;
                        try
                        {
                            var json = factual.Fetch("places", q);
                            var jarray = JsonConvert.DeserializeObject<RootObjectFactual>(json);

                            while (jarray.status == "ok" & jarray.response.data.Count > 0)
                            {
                                /* Populate the company list */
                                foreach (Datum item in jarray.response.data)
                                {
                                    string companyName = item.name;
                                    string companyAddress = item.address == null ? "" : item.address;
                                    string companyCity = item.locality == null ? "" : item.locality;
                                    string companyState = item.region == null ? "" : item.region;
                                    string companyCountry = item.country == null ? "" : item.country;
                                    string companyZip = item.postcode == null ? "" : item.postcode;
                                    string companyPhone = item.tel == null ? "" : fixPhoneNumberFormat(item.tel);
                                    string companyEmail = item.email == null ? "no email" : item.email;
                                    string companyWebsite = item.website;
                                    string companyHouzzSearch = generateHouzzSearchLink(replaceCompanyNamePTE(companyName), companyState, true);
                                    List<string> companyCategories = item.category_labels == null ? new List<string>() : item.category_labels[0];
                                    //textDebugger.AppendText(companyName + Environment.NewLine);
                                    AddtoList(companyName, companyAddress, companyCity, companyState, companyZip, companyCountry,
                                        companyPhone, companyEmail, "", companyWebsite, companyHouzzSearch, companyCategories);
                                }
                                page++;
                                int pageOffset = (page - 1) * 50;
                                Query qnew = new Query().SearchExact(searchCriteria);
                                if ( searchCountry.Text == "US" || searchCountry.Text == "AU")
                                {
                                    json = factual.Fetch("places", new Query()
                                        .SearchExact(searchCriteria)
                                        .Field("country").Equal(search_Country)
                                        .Field("region").Equal(search_State)
                                        .Field("locality").Equal(search_City)
                                        .Limit(50)
                                        .Offset(pageOffset));
                                }
                                else if (searchCountry.Text != "US" & searchCountry.Text != "AU")
                                {
                                    json = factual.Fetch("places", new Query()
                                        .SearchExact(searchCriteria)
                                        .Field("country").Equal(search_Country)
                                        .Limit(50)
                                        .Offset(pageOffset));
                                }
                                jarray = JsonConvert.DeserializeObject<RootObjectFactual>(json);
                            }
                        }
                        catch (FactualApiException ex)
                        {
                            textDebugger.AppendText("Factual Requested URL: " + ex.Url + Environment.NewLine);
                            textDebugger.AppendText("Factual Error Status Code: " + ex.StatusCode + Environment.NewLine); ;
                            textDebugger.AppendText("Factual Error Response Message: " + ex.Response + Environment.NewLine); ;
                            if (ex.StatusCode.ToString().Contains("RequestedRangeNotSatisfiable"))
                                textDebugger.AppendText("Factual reached end of results on page " + (page - 1).ToString() + Environment.NewLine);
                        }
                    }
                    saveDataSet();
                    if( searchSensis.Checked )
                    {
                        var searcher = new SsapiSearcher(searchEndPoint, apiSensisKey);
                        // Perform a search and check the response
                        var searchResponse = searcher.SearchFor(searchCategory.Text, searchCity.Text, searchState.Text, 1); /* page 1 */
                        if (searchResponse.code < 200 || searchResponse.code > 299)
                            textDebugger.AppendText("Search failed - Error " + searchResponse.code + ": " + searchResponse.message + Environment.NewLine);
                        else
                        {
                            textDebugger.AppendText("Total results found: " + searchResponse.totalResults.ToString() + Environment.NewLine);
                            textDebugger.AppendText("Total pages: " + searchResponse.totalPages.ToString() + Environment.NewLine);

                            for (int page = 1; page < searchResponse.totalPages; page++)
                            {
                                // Display the results
                                foreach (var result in searchResponse.results)
                                {
                                    string companyWebsite = getSensisContactComponents(result.primaryContacts, "URL");
                                    if (companyWebsite != "")
                                    {
                                        string companyName = result.name;
                                        string companyAddress = "", companyCity = "", companyState = "", companyZip = "";
                                        if (result.primaryAddress != null)
                                        {
                                            companyAddress = result.primaryAddress.addressLine == null ? "" : result.primaryAddress.addressLine;
                                            companyCity = result.primaryAddress.suburb == null ? "" : result.primaryAddress.suburb;
                                            companyState = result.primaryAddress.state == null ? "" : result.primaryAddress.state;
                                            companyZip = result.primaryAddress.postcode == null ? "" : result.primaryAddress.postcode;
                                        }
                                        string companyCountry = "AU";
                                        string companyEmail = getSensisContactComponents(result.primaryContacts, "EMAIL");
                                        string companyPhone = fixPhoneNumberFormat(getSensisContactComponents(result.primaryContacts, "PHONE"));
                                        if (companyPhone == "") companyPhone = fixPhoneNumberFormat(getSensisContactComponents(result.primaryContacts, "MOBILE"));
                                        string companyContactUs = companyEmail.Contains("@") ? "" : getSensisExternalLinksComponents(result.externalLinks, "Contact Us");
                                        string companyHouzzSearch = generateHouzzSearchLink(replaceCompanyNamePTE(companyName), companyState, true);
                                        List<string> companyCategories = result.categories == null ? new List<string>() : new List<string>(new string[] { result.categories[0].name });

                                        //textDebugger.AppendText(companyName + companyAddress + companyCity + companyState + companyZip + companyEmail + companyPhone + companyWebsite + Environment.NewLine);

                                        AddtoList(companyName, companyAddress, companyCity, companyState, companyZip, companyCountry, companyPhone,
                                            companyEmail, companyContactUs, companyWebsite, companyHouzzSearch, companyCategories);
                                    }
                                }
                                searchResponse = searcher.SearchFor(searchCategory.Text, searchCity.Text, searchState.Text, page);
                            }
                        }
                    }
                    /* At the end of each category, we save the data found into an xml file*/
                    saveDataSet();  
                }
            }

            statusBotStrip.Text = "Status: Done";
            /* Save settings */
            SaveSettings();
        }
Пример #20
0
 public void VerifyLocationInResult()
 {
     var y = new Yelp(Config.Options);
     var results = y.Search("coffee", "seattle, wa").Result;
     if (results.error != null)
     {
         Assert.Fail(results.error.text);
     }
     var bus = results.businesses[0];
     if (bus.location.coordinate == null)
         Assert.Fail("No coordinate found on location for business");
 }
Пример #21
0
 public void LocationWithRadius()
 {
     var yelp = new Yelp(Config.Options);
     var searchOptions = new YelpSharp.Data.Options.SearchOptions()
     {
         GeneralOptions = new GeneralOptions() { term = "food", radius_filter = 5 },
         LocationOptions = new LocationOptions()
         {
             location = "bellevue"
         }
     };
     var results = yelp.Search(searchOptions).Result;
     Assert.IsTrue(results.businesses.Count > 0);
 }
Пример #22
0
        public void LocationWithCoordinates()
        {
            var yelp = new Yelp(Config.Options);

            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions() { term = "food" },
                LocationOptions = new LocationOptions()
                {
                    location = "bellevue",
                    coordinates = new CoordinateOptions()
                    {
                        latitude = 37.788022,
                        longitude = -122.399797
                    }
                }
            };

            var results = yelp.Search(searchOptions).Result;
            Assert.IsTrue(results.businesses.Count > 0);
        }
Пример #23
0
 public void MultipleCategories()
 {
     var yelp = new Yelp(Config.Options);
     var searchOptions = new YelpSharp.Data.Options.SearchOptions()
     {
         GeneralOptions = new GeneralOptions() { category_filter = "climbing,bowling" },
         LocationOptions = new LocationOptions()
         {
             location = "Seattle"
         }
     };
     var results = yelp.Search(searchOptions).Result;
     Assert.IsTrue(results.businesses.Count > 0);
 }
Пример #24
0
        public void LocationWithCoordinates()
        {
            var o = GetOptions();
            var yelp = new Yelp(o);

            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions() { term = "food" },
                LocationOptions = new LocationOptions()
                {
                    location = "bellevue",
                    coordinates = new CoordinateOptions()
                    {
                        latitude = 37.788022,
                        longitude = -122.399797
                    }
                }
            };

            var results = yelp.Search(searchOptions);

            Console.WriteLine(results);
        }
Пример #25
0
        public void UrlEscapedCharacters()
        {
            var y = new Yelp(Config.Options);

            var searchOptions = new SearchOptions();
            searchOptions.GeneralOptions = new GeneralOptions()
            {
                term = "coffee $&`:<>[]{}\"#%@/;=?\\^|~', tea"
                //term = "coffee $`:<>[]{}\"#%@/;=?\\^|~', tea"
            };

            searchOptions.LocationOptions = new LocationOptions()
            {
                location = "seattle"
            };

            var results = y.Search(searchOptions).Result;
            Assert.IsTrue(results.businesses != null);
            Assert.IsTrue(results.businesses.Count > 0);
            Console.WriteLine(results);
        }
Пример #26
0
        public void LocationWithRadius()
        {
            var o = GetOptions();
            var yelp = new Yelp(o);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions() { term = "food", radius_filter=5 },
                LocationOptions = new LocationOptions()
                {
                    location = "bellevue"
                }
            };
            var results = yelp.Search(searchOptions);

            Console.WriteLine(results);
        }
Пример #27
0
        public void ErrorTest_UNSPECIFIED_LOCATION()
        {
            var y = new Yelp(Config.Options);

            var searchOptions = new SearchOptions();

            var results = y.Search(searchOptions).Result;
            Assert.IsTrue(results.error != null);
            Assert.IsTrue(results.error.id == YelpSharp.Data.ErrorId.UNSPECIFIED_LOCATION);
            Console.WriteLine(results);
        }
Пример #28
0
        public void MultipleCategories()
        {
            var o = GetOptions();
            var yelp = new Yelp(o);
            var searchOptions = new YelpSharp.Data.Options.SearchOptions()
            {
                GeneralOptions = new GeneralOptions() { category_filter="climbing,bowling" },
                LocationOptions = new LocationOptions()
                {
                    location = "Seattle"
                }
            };
            var results = yelp.Search(searchOptions);

            Console.WriteLine(results);
        }
Пример #29
0
 public void BusinessTest()
 {
     var o = GetOptions();
     var y = new Yelp(o);
     var results = y.GetBusiness("yelp-san-francisco");
     Console.WriteLine(results);
 }
Пример #30
0
 public void LocationByBounds()
 {
     var yelp = new Yelp(Config.Options);
     var searchOptions = new YelpSharp.Data.Options.SearchOptions()
     {
         GeneralOptions = new GeneralOptions() { radius_filter = 5 },
         LocationOptions = new CoordinateOptions()
         {
             latitude = 37.788022,
             longitude = -122.399797
         }
     };
     var results = yelp.Search(searchOptions).Result;
     Assert.IsTrue(results.businesses.Count > 0);
 }