public void Can_Deserialize_4sq_Json_With_Root_Element_Specified() { string doc = File.ReadAllText(Path.Combine("SampleData", "4sq.txt")); JsonDeserializer json = new JsonDeserializer { RootElement = "response" }; VenuesResponse output = json.Deserialize <VenuesResponse>(new RestResponse { Content = doc }); Assert.IsNotEmpty(output.Groups); }
public void Venue_VenuesResponse_Data_IsCorrect() { var venue1 = new SDK.Venue.Models.Venue(); var venue2 = new SDK.Venue.Models.Venue(); var response = new VenuesResponse { response = new VenuesResponseContent { results = new List <SDK.Venue.Models.Venue> { venue1, venue2 } } }; var result = response.Data; Assert.AreEqual(2, result.Count); Assert.IsTrue(result.Contains(venue1)); Assert.IsTrue(result.Contains(venue2)); }
public async Task <IActionResult> Venues(string stateCode) { VenuesResponse venues = new VenuesResponse() { Venues = new List <Venue>(), Favorites = new List <string>() }; foreach (var favorite in _context.Favorites) { venues.Favorites.Add(favorite.EventId); } venues.PageLink = "venues.json?countryCode=US&apikey=2kVlEu5eTcizQZ73bkzcleUGRaFcJhxp&stateCode=" + stateCode; var client = new HttpClient(); client.BaseAddress = new Uri("https://app.ticketmaster.com/discovery/v2/"); client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (compatible; GrandCircus/1.0)"); var response = await client.GetStringAsync(venues.PageLink); var result = JsonConvert.DeserializeObject <SearchVenuesResponse>(response); venues.Venues.AddRange(result._embedded.Venues); venues.Page = result.Page.Number; return(View(venues)); //var request = new SearchVenuesRequest(); //request.AddQueryParameter(SearchVenuesQueryParameters.stateCode, statecode); //var response = await _discovery.Venues.SearchVenuesAsync(request); //VenuesResponse result = new VenuesResponse(); ////This will break if the API response is null. //result.Venues = response._embedded.Venues; //return View(result); }