From 2d1eb2233ac9dd0b8f3a951df57fb375113b53c7 Mon Sep 17 00:00:00 2001 From: Tommy Parnell Date: Sun, 10 May 2015 00:50:01 -0400 Subject: [PATCH 1/2] more singleObjectConvert is required --- src/Untappd.Net/Request/Repository.cs | 15 + src/Untappd.Net/Request/RepositoryGet.cs | 11 +- src/Untappd.Net/Request/RepositoryPost.cs | 6 +- src/Untappd.Net/Responses/BeerInfo.cs | 7 + src/Untappd.Net/Responses/BeerSearch.cs | 1 + src/Untappd.Net/Responses/BreweryInfo.cs | 2 + src/Untappd.Net/Responses/BrewerySearch.cs | 1 + .../Responses/Feeds/ActivityFeed.cs | 1 + .../Responses/Feeds/UserActivityFeed.cs | 1 + src/Untappd.Net/Responses/UserBadges.cs | 1 + src/Untappd.Net/Responses/UserDistinctBeer.cs | 1 + src/Untappd.Net/Responses/UserFriends.cs | 1 + src/Untappd.Net/Responses/UserInfo.cs | 343 +++++++++++++++--- src/Untappd.Net/Responses/UserWishlist.cs | 1 + src/Untappd.Net/Responses/VenueInfo.cs | 10 +- 15 files changed, 334 insertions(+), 68 deletions(-) diff --git a/src/Untappd.Net/Request/Repository.cs b/src/Untappd.Net/Request/Repository.cs index ad0af81..a6f7781 100644 --- a/src/Untappd.Net/Request/Repository.cs +++ b/src/Untappd.Net/Request/Repository.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using Newtonsoft.Json; using RestSharp; +using Untappd.Net.Client; namespace Untappd.Net.Request { @@ -36,6 +37,20 @@ namespace Untappd.Net.Request } + internal void ConfigureRequest(IUnAuthenticatedUntappdCredentials credentials, string endPoint, IDictionary bodyParameters = null, Method webMethod = Method.GET) + { + ConfigureRequest(endPoint, bodyParameters, webMethod); + Request.AddParameter("client_id", credentials.ClientId); + Request.AddParameter("client_secret", credentials.ClientSecret); + + } + + internal void ConfigureRequest(IAuthenticatedUntappdCredentials credentials, string endPoint, IDictionary bodyParameters = null, Method webMethod = Method.GET) + { + ConfigureRequest(endPoint, bodyParameters, webMethod); + Request.AddParameter("access_token", credentials.AccessToken); + } + private TResult ExecuteRequest() { var response = Client.Execute(Request); diff --git a/src/Untappd.Net/Request/RepositoryGet.cs b/src/Untappd.Net/Request/RepositoryGet.cs index 08a21c4..3204038 100644 --- a/src/Untappd.Net/Request/RepositoryGet.cs +++ b/src/Untappd.Net/Request/RepositoryGet.cs @@ -18,9 +18,7 @@ namespace Untappd.Net.Request where TResult : IUnAuthenticatedRequest, new() { var result = new TResult(); - ConfigureRequest(result.EndPoint(urlParameter), bodyParameters); - Request.AddParameter("client_id", credentials.ClientId); - Request.AddParameter("client_secret", credentials.ClientSecret); + ConfigureRequest(credentials, result.EndPoint(urlParameter), bodyParameters); return ExecuteRequest(); } @@ -36,9 +34,7 @@ namespace Untappd.Net.Request where TResult : IUnAuthenticatedRequest, new() { var result = new TResult(); - ConfigureRequest(result.EndPoint(urlParameter), bodyParameters); - Request.AddParameter("client_id", credentials.ClientId); - Request.AddParameter("client_secret", credentials.ClientSecret); + ConfigureRequest(credentials, result.EndPoint(urlParameter), bodyParameters); return ExecuteRequestAsync(); } @@ -54,8 +50,7 @@ namespace Untappd.Net.Request where TResult : IAuthenticatedRequest, new() { var result = new TResult(); - ConfigureRequest(result.EndPoint(urlParameter), bodyParameters); - Request.AddParameter("access_token", credentials.AccessToken); + ConfigureRequest(credentials, result.EndPoint(urlParameter), bodyParameters); return ExecuteRequest(); } diff --git a/src/Untappd.Net/Request/RepositoryPost.cs b/src/Untappd.Net/Request/RepositoryPost.cs index ee1e3d7..c6610ec 100644 --- a/src/Untappd.Net/Request/RepositoryPost.cs +++ b/src/Untappd.Net/Request/RepositoryPost.cs @@ -13,8 +13,7 @@ namespace Untappd.Net.Request /// returns dynamic since often the return doesn't matter public dynamic Post(IAuthenticatedUntappdCredentials credentials, IAction action) { - ConfigureRequest(action.EndPoint, action.BodyParameters, action.RequestMethod); - Request.AddParameter("access_token", credentials.AccessToken); + ConfigureRequest(credentials, action.EndPoint, action.BodyParameters, action.RequestMethod); return ExecuteRequest(); } @@ -26,8 +25,7 @@ namespace Untappd.Net.Request /// returns dynamic since often the return doesn't matter public Task PostAsync(IAuthenticatedUntappdCredentials credentials, IAction action) { - ConfigureRequest(action.EndPoint, action.BodyParameters, action.RequestMethod); - Request.AddParameter("access_token", credentials.AccessToken); + ConfigureRequest(credentials, action.EndPoint, action.BodyParameters, action.RequestMethod); return ExecuteRequestAsync(); } } diff --git a/src/Untappd.Net/Responses/BeerInfo.cs b/src/Untappd.Net/Responses/BeerInfo.cs index aadc620..f21f4dd 100644 --- a/src/Untappd.Net/Responses/BeerInfo.cs +++ b/src/Untappd.Net/Responses/BeerInfo.cs @@ -128,6 +128,7 @@ namespace Untappd.Net.Responses.BeerInfo public string CountryName { get; set; } [JsonProperty("contact")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Contact Contact { get; set; } [JsonProperty("location")] @@ -241,6 +242,7 @@ namespace Untappd.Net.Responses.BeerInfo public string CountryName { get; set; } [JsonProperty("contact")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Contact2 Contact { get; set; } [JsonProperty("location")] @@ -350,6 +352,7 @@ namespace Untappd.Net.Responses.BeerInfo public int IsPrivate { get; set; } [JsonProperty("contact")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public object Contact { get; set; } } @@ -444,6 +447,7 @@ namespace Untappd.Net.Responses.BeerInfo public string CountryName { get; set; } [JsonProperty("contact")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Contact3 Contact { get; set; } [JsonProperty("location")] @@ -758,6 +762,7 @@ namespace Untappd.Net.Responses.BeerInfo public string CountryName { get; set; } [JsonProperty("contact")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Contact4 Contact { get; set; } [JsonProperty("location")] @@ -910,6 +915,7 @@ namespace Untappd.Net.Responses.BeerInfo public Media Media { get; set; } [JsonProperty("checkins")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Checkins Checkins { get; set; } [JsonProperty("similar")] @@ -937,6 +943,7 @@ namespace Untappd.Net.Responses.BeerInfo public Meta Meta { get; set; } [JsonProperty("notifications")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Notifications Notifications { get; set; } [JsonProperty("response")] diff --git a/src/Untappd.Net/Responses/BeerSearch.cs b/src/Untappd.Net/Responses/BeerSearch.cs index 81291f8..2b5d83c 100644 --- a/src/Untappd.Net/Responses/BeerSearch.cs +++ b/src/Untappd.Net/Responses/BeerSearch.cs @@ -264,6 +264,7 @@ namespace Untappd.Net.Responses.BeerSearch public Meta Meta { get; set; } [JsonProperty("notifications")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Notifications Notifications { get; set; } [JsonProperty("response")] diff --git a/src/Untappd.Net/Responses/BreweryInfo.cs b/src/Untappd.Net/Responses/BreweryInfo.cs index 4e80784..f5365ed 100644 --- a/src/Untappd.Net/Responses/BreweryInfo.cs +++ b/src/Untappd.Net/Responses/BreweryInfo.cs @@ -892,6 +892,7 @@ namespace Untappd.Net.Responses.BreweryInfo public Media Media { get; set; } [JsonProperty("checkins")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Checkins Checkins { get; set; } [JsonProperty("beer_list")] @@ -913,6 +914,7 @@ namespace Untappd.Net.Responses.BreweryInfo public Meta Meta { get; set; } [JsonProperty("notifications")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Notifications Notifications { get; set; } [JsonProperty("response")] diff --git a/src/Untappd.Net/Responses/BrewerySearch.cs b/src/Untappd.Net/Responses/BrewerySearch.cs index 5a06784..8999559 100644 --- a/src/Untappd.Net/Responses/BrewerySearch.cs +++ b/src/Untappd.Net/Responses/BrewerySearch.cs @@ -152,6 +152,7 @@ namespace Untappd.Net.Responses.BrewerySearch public Meta Meta { get; set; } [JsonProperty("notifications")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Notifications Notifications { get; set; } [JsonProperty("response")] diff --git a/src/Untappd.Net/Responses/Feeds/ActivityFeed.cs b/src/Untappd.Net/Responses/Feeds/ActivityFeed.cs index ab79fa5..01aa653 100644 --- a/src/Untappd.Net/Responses/Feeds/ActivityFeed.cs +++ b/src/Untappd.Net/Responses/Feeds/ActivityFeed.cs @@ -502,6 +502,7 @@ namespace Untappd.Net.Responses.Feeds.ActivityFeed public bool Mg { get; set; } [JsonProperty("checkins")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Checkins Checkins { get; set; } [JsonProperty("pagination")] diff --git a/src/Untappd.Net/Responses/Feeds/UserActivityFeed.cs b/src/Untappd.Net/Responses/Feeds/UserActivityFeed.cs index 43c6616..c78f310 100644 --- a/src/Untappd.Net/Responses/Feeds/UserActivityFeed.cs +++ b/src/Untappd.Net/Responses/Feeds/UserActivityFeed.cs @@ -472,6 +472,7 @@ namespace Untappd.Net.Responses.Feeds.UserActivityFeed public Pagination Pagination { get; set; } [JsonProperty("checkins")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Checkins Checkins { get; set; } } diff --git a/src/Untappd.Net/Responses/UserBadges.cs b/src/Untappd.Net/Responses/UserBadges.cs index 5897062..161da3e 100644 --- a/src/Untappd.Net/Responses/UserBadges.cs +++ b/src/Untappd.Net/Responses/UserBadges.cs @@ -213,6 +213,7 @@ namespace Untappd.Net.Responses.UserBadges public Meta Meta { get; set; } [JsonProperty("notifications")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Notifications Notifications { get; set; } [JsonProperty("response")] diff --git a/src/Untappd.Net/Responses/UserDistinctBeer.cs b/src/Untappd.Net/Responses/UserDistinctBeer.cs index 5ceea9c..9601394 100644 --- a/src/Untappd.Net/Responses/UserDistinctBeer.cs +++ b/src/Untappd.Net/Responses/UserDistinctBeer.cs @@ -231,6 +231,7 @@ namespace Untappd.Net.Responses.UserDistinctBeer public Meta Meta { get; set; } [JsonProperty("notifications")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Notifications Notifications { get; set; } [JsonProperty("response")] diff --git a/src/Untappd.Net/Responses/UserFriends.cs b/src/Untappd.Net/Responses/UserFriends.cs index 6e8cf50..7b1750f 100644 --- a/src/Untappd.Net/Responses/UserFriends.cs +++ b/src/Untappd.Net/Responses/UserFriends.cs @@ -142,6 +142,7 @@ namespace Untappd.Net.Responses.UserFriends public Meta Meta { get; set; } [JsonProperty("notifications")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Notifications Notifications { get; set; } [JsonProperty("response")] diff --git a/src/Untappd.Net/Responses/UserInfo.cs b/src/Untappd.Net/Responses/UserInfo.cs index d605eab..8ca0d2a 100644 --- a/src/Untappd.Net/Responses/UserInfo.cs +++ b/src/Untappd.Net/Responses/UserInfo.cs @@ -5,7 +5,7 @@ using Untappd.Net.Request; namespace Untappd.Net.Responses.UserInfo { - public sealed class ResponseTime + public class ResponseTime { [JsonProperty("time")] @@ -31,12 +31,6 @@ namespace Untappd.Net.Responses.UserInfo [JsonProperty("code")] public int Code { get; set; } - [JsonProperty("error_detail")] - public string ErrorDetail { get; set; } - - [JsonProperty("error_type")] - public string ErrorType { get; set; } - [JsonProperty("response_time")] public ResponseTime ResponseTime { get; set; } @@ -44,6 +38,35 @@ namespace Untappd.Net.Responses.UserInfo public InitTime InitTime { get; set; } } + public class UnreadCount + { + + [JsonProperty("comments")] + public int Comments { get; set; } + + [JsonProperty("toasts")] + public int Toasts { get; set; } + + [JsonProperty("friends")] + public int Friends { get; set; } + + [JsonProperty("messages")] + public int Messages { get; set; } + + [JsonProperty("news")] + public int News { get; set; } + } + + public class Notifications + { + + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("unread_count")] + public UnreadCount UnreadCount { get; set; } + } + public class Stats { @@ -182,9 +205,6 @@ namespace Untappd.Net.Responses.UserInfo [JsonProperty("facebook")] public int Facebook { get; set; } - - [JsonProperty("twitter")] - public string Twitter { get; set; } } public class User2 @@ -215,7 +235,7 @@ namespace Untappd.Net.Responses.UserInfo public string Bio { get; set; } [JsonProperty("relationship")] - public object Relationship { get; set; } + public string Relationship { get; set; } [JsonProperty("user_avatar")] public string UserAvatar { get; set; } @@ -315,6 +335,118 @@ namespace Untappd.Net.Responses.UserInfo public int BreweryActive { get; set; } } + public class Item3 + { + + [JsonProperty("category_name")] + public string CategoryName { get; set; } + + [JsonProperty("category_id")] + public string CategoryId { get; set; } + + [JsonProperty("is_primary")] + public bool IsPrimary { get; set; } + } + + public class Categories + { + + [JsonProperty("count")] + public int Count { get; set; } + + [JsonProperty("items")] + public IList Items { get; set; } + } + + public class Location3 + { + + [JsonProperty("venue_address")] + public string VenueAddress { get; set; } + + [JsonProperty("venue_city")] + public string VenueCity { get; set; } + + [JsonProperty("venue_state")] + public string VenueState { get; set; } + + [JsonProperty("venue_country")] + public string VenueCountry { get; set; } + + [JsonProperty("lat")] + public double Lat { get; set; } + + [JsonProperty("lng")] + public double Lng { get; set; } + } + + public class Contact4 + { + + [JsonProperty("twitter")] + public string Twitter { get; set; } + + [JsonProperty("venue_url")] + public string VenueUrl { get; set; } + } + + public class Foursquare + { + + [JsonProperty("foursquare_id")] + public string FoursquareId { get; set; } + + [JsonProperty("foursquare_url")] + public string FoursquareUrl { get; set; } + } + + public class VenueIcon + { + + [JsonProperty("sm")] + public string Sm { get; set; } + + [JsonProperty("md")] + public string Md { get; set; } + + [JsonProperty("lg")] + public string Lg { get; set; } + } + + public class Venue + { + + [JsonProperty("venue_id")] + public int VenueId { get; set; } + + [JsonProperty("venue_name")] + public string VenueName { get; set; } + + [JsonProperty("primary_category")] + public string PrimaryCategory { get; set; } + + [JsonProperty("parent_category_id")] + public string ParentCategoryId { get; set; } + + [JsonProperty("categories")] + public Categories Categories { get; set; } + + [JsonProperty("location")] + public Location3 Location { get; set; } + + [JsonProperty("contact")] + public Contact4 Contact { get; set; } + + [JsonProperty("public_venue")] + public bool PublicVenue { get; set; } + + [JsonProperty("foursquare")] + public Foursquare Foursquare { get; set; } + + [JsonProperty("venue_icon")] + public VenueIcon VenueIcon { get; set; } + } + public class Comments { @@ -359,10 +491,10 @@ namespace Untappd.Net.Responses.UserInfo public string AccountType { get; set; } [JsonProperty("brewery_details")] - public object BreweryDetails { get; set; } + public IList BreweryDetails { get; set; } } - public class Item3 + public class Item4 { [JsonProperty("uid")] @@ -391,10 +523,10 @@ namespace Untappd.Net.Responses.UserInfo public int Count { get; set; } [JsonProperty("auth_toast")] - public object AuthToast { get; set; } + public bool AuthToast { get; set; } [JsonProperty("items")] - public IList Items { get; set; } + public IList Items { get; set; } } public class Photo @@ -413,7 +545,7 @@ namespace Untappd.Net.Responses.UserInfo public string PhotoImgOg { get; set; } } - public class Item4 + public class Item5 { [JsonProperty("photo_id")] @@ -430,7 +562,7 @@ namespace Untappd.Net.Responses.UserInfo public int Count { get; set; } [JsonProperty("items")] - public IList Items { get; set; } + public IList Items { get; set; } } public class Source @@ -456,7 +588,7 @@ namespace Untappd.Net.Responses.UserInfo public string Lg { get; set; } } - public class Item5 + public class Item6 { [JsonProperty("badge_id")] @@ -485,7 +617,7 @@ namespace Untappd.Net.Responses.UserInfo public int Count { get; set; } [JsonProperty("items")] - public IList Items { get; set; } + public IList Items { get; set; } } public class Item2 @@ -513,7 +645,8 @@ namespace Untappd.Net.Responses.UserInfo public Brewery2 Brewery { get; set; } [JsonProperty("venue")] - public object Venue { get; set; } + [JsonConverter(typeof(SingleObjectArrayConverter))] + public Venue Venue { get; set; } [JsonProperty("comments")] public Comments Comments { get; set; } @@ -616,7 +749,7 @@ namespace Untappd.Net.Responses.UserInfo public bool WishList { get; set; } } - public class Contact4 + public class Contact5 { [JsonProperty("twitter")] @@ -632,7 +765,7 @@ namespace Untappd.Net.Responses.UserInfo public string Url { get; set; } } - public class Location3 + public class Location4 { [JsonProperty("brewery_city")] @@ -667,16 +800,128 @@ namespace Untappd.Net.Responses.UserInfo public string CountryName { get; set; } [JsonProperty("contact")] - public Contact4 Contact { get; set; } + public Contact5 Contact { get; set; } [JsonProperty("location")] - public Location3 Location { get; set; } + public Location4 Location { get; set; } [JsonProperty("brewery_active")] public int BreweryActive { get; set; } } - public class Item6 + public class Item8 + { + + [JsonProperty("category_name")] + public string CategoryName { get; set; } + + [JsonProperty("category_id")] + public string CategoryId { get; set; } + + [JsonProperty("is_primary")] + public bool IsPrimary { get; set; } + } + + public class Categories2 + { + + [JsonProperty("count")] + public int Count { get; set; } + + [JsonProperty("items")] + public IList Items { get; set; } + } + + public class Location5 + { + + [JsonProperty("venue_address")] + public string VenueAddress { get; set; } + + [JsonProperty("venue_city")] + public string VenueCity { get; set; } + + [JsonProperty("venue_state")] + public string VenueState { get; set; } + + [JsonProperty("venue_country")] + public string VenueCountry { get; set; } + + [JsonProperty("lat")] + public double Lat { get; set; } + + [JsonProperty("lng")] + public double Lng { get; set; } + } + + public class Contact6 + { + + [JsonProperty("twitter")] + public string Twitter { get; set; } + + [JsonProperty("venue_url")] + public string VenueUrl { get; set; } + } + + public class Foursquare2 + { + + [JsonProperty("foursquare_id")] + public string FoursquareId { get; set; } + + [JsonProperty("foursquare_url")] + public string FoursquareUrl { get; set; } + } + + public class VenueIcon2 + { + + [JsonProperty("sm")] + public string Sm { get; set; } + + [JsonProperty("md")] + public string Md { get; set; } + + [JsonProperty("lg")] + public string Lg { get; set; } + } + + public class Venue2 + { + + [JsonProperty("venue_id")] + public int VenueId { get; set; } + + [JsonProperty("venue_name")] + public string VenueName { get; set; } + + [JsonProperty("primary_category")] + public string PrimaryCategory { get; set; } + + [JsonProperty("parent_category_id")] + public string ParentCategoryId { get; set; } + + [JsonProperty("categories")] + public Categories2 Categories { get; set; } + + [JsonProperty("location")] + public Location5 Location { get; set; } + + [JsonProperty("contact")] + public Contact6 Contact { get; set; } + + [JsonProperty("public_venue")] + public bool PublicVenue { get; set; } + + [JsonProperty("foursquare")] + public Foursquare2 Foursquare { get; set; } + + [JsonProperty("venue_icon")] + public VenueIcon2 VenueIcon { get; set; } + } + + public class Item7 { [JsonProperty("photo_id")] @@ -701,7 +946,7 @@ namespace Untappd.Net.Responses.UserInfo public Brewery3 Brewery { get; set; } [JsonProperty("venue")] - public object Venue { get; set; } + public Venue2 Venue { get; set; } } public class Media2 @@ -711,54 +956,63 @@ namespace Untappd.Net.Responses.UserInfo public int Count { get; set; } [JsonProperty("items")] - public IList Items { get; set; } + public IList Items { get; set; } } - public class Contact5 + public class Contact7 { [JsonProperty("facebook")] public int Facebook { get; set; } - - [JsonProperty("twitter")] - public string Twitter { get; set; } } public class Badge { + [JsonProperty("badges_to_facebook")] public int BadgesToFacebook { get; set; } + [JsonProperty("badges_to_twitter")] public int BadgesToTwitter { get; set; } } public class Checkin { + [JsonProperty("checkin_to_facebook")] public int CheckinToFacebook { get; set; } + [JsonProperty("checkin_to_twitter")] public int CheckinToTwitter { get; set; } + [JsonProperty("checkin_to_foursquare")] public int CheckinToFoursquare { get; set; } } public class Navigation { + [JsonProperty("default_to_checkin")] public int DefaultToCheckin { get; set; } } public class Settings { + [JsonProperty("badge")] public Badge Badge { get; set; } + [JsonProperty("checkin")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Checkin Checkin { get; set; } + [JsonProperty("navigation")] public Navigation Navigation { get; set; } + [JsonProperty("email_address")] public string EmailAddress { get; set; } } + public class User { @@ -805,7 +1059,7 @@ namespace Untappd.Net.Responses.UserInfo public int IsSupporter { get; set; } [JsonProperty("relationship")] - public object Relationship { get; set; } + public string Relationship { get; set; } [JsonProperty("untappd_url")] public string UntappdUrl { get; set; } @@ -820,13 +1074,14 @@ namespace Untappd.Net.Responses.UserInfo public RecentBrews RecentBrews { get; set; } [JsonProperty("checkins")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Checkins Checkins { get; set; } [JsonProperty("media")] public Media2 Media { get; set; } [JsonProperty("contact")] - public Contact5 Contact { get; set; } + public Contact7 Contact { get; set; } [JsonProperty("date_joined")] public string DateJoined { get; set; } @@ -835,28 +1090,6 @@ namespace Untappd.Net.Responses.UserInfo public Settings Settings { get; set; } } - public class UnreadCount - { - [JsonProperty("comments")] - public int Comments { get; set; } - [JsonProperty("toasts")] - public int Toasts { get; set; } - [JsonProperty("friends")] - public int Friends { get; set; } - [JsonProperty("messages")] - public int Messages { get; set; } - [JsonProperty("news")] - public int news { get; set; } - } - - public class Notifications - { - [JsonProperty("type")] - public string Type { get; set; } - [JsonProperty("unread_count")] - public UnreadCount UnreadCount { get; set; } - } - public class Response { diff --git a/src/Untappd.Net/Responses/UserWishlist.cs b/src/Untappd.Net/Responses/UserWishlist.cs index 378bce2..8edae98 100644 --- a/src/Untappd.Net/Responses/UserWishlist.cs +++ b/src/Untappd.Net/Responses/UserWishlist.cs @@ -223,6 +223,7 @@ namespace Untappd.Net.Responses.UserWishlist public Meta Meta { get; set; } [JsonProperty("notifications")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Notifications Notifications { get; set; } [JsonProperty("response")] diff --git a/src/Untappd.Net/Responses/VenueInfo.cs b/src/Untappd.Net/Responses/VenueInfo.cs index 13b6494..82fbcac 100644 --- a/src/Untappd.Net/Responses/VenueInfo.cs +++ b/src/Untappd.Net/Responses/VenueInfo.cs @@ -271,6 +271,7 @@ namespace Untappd.Net.Responses.VenueInfo public string CountryName { get; set; } [JsonProperty("contact")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Contact2 Contact { get; set; } [JsonProperty("location")] @@ -405,6 +406,7 @@ namespace Untappd.Net.Responses.VenueInfo public Location3 Location { get; set; } [JsonProperty("contact")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Contact3 Contact { get; set; } [JsonProperty("public_venue")] @@ -562,6 +564,7 @@ namespace Untappd.Net.Responses.VenueInfo public string CountryName { get; set; } [JsonProperty("contact")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Contact4 Contact { get; set; } [JsonProperty("location")] @@ -671,6 +674,7 @@ namespace Untappd.Net.Responses.VenueInfo public Location5 Location { get; set; } [JsonProperty("contact")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Contact5 Contact { get; set; } [JsonProperty("public_venue")] @@ -1074,6 +1078,7 @@ namespace Untappd.Net.Responses.VenueInfo public string CountryName { get; set; } [JsonProperty("contact")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Contact6 Contact { get; set; } [JsonProperty("location")] @@ -1150,7 +1155,7 @@ namespace Untappd.Net.Responses.VenueInfo public Categories Categories { get; set; } [JsonProperty("stats")] - public Stats Stats { get; set; } + public Stats Stats { get; set; } [JsonProperty("venue_icon")] public VenueIcon VenueIcon { get; set; } @@ -1162,6 +1167,7 @@ namespace Untappd.Net.Responses.VenueInfo public Location Location { get; set; } [JsonProperty("contact")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Contact Contact { get; set; } [JsonProperty("foursquare")] @@ -1171,6 +1177,7 @@ namespace Untappd.Net.Responses.VenueInfo public Media Media { get; set; } [JsonProperty("checkins")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Checkins Checkins { get; set; } [JsonProperty("top_beers")] @@ -1192,6 +1199,7 @@ namespace Untappd.Net.Responses.VenueInfo public Meta Meta { get; set; } [JsonProperty("notifications")] + [JsonConverter(typeof(SingleObjectArrayConverter))] public Notifications Notifications { get; set; } [JsonProperty("response")] From ea4b517eb9260448e63d3ff3aa581fbd3b143561 Mon Sep 17 00:00:00 2001 From: Tommy Parnell Date: Sun, 10 May 2015 09:15:52 -0400 Subject: [PATCH 2/2] fix broken test --- src/Untappd.Net.UnitTests/Request/TestRepository.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Untappd.Net.UnitTests/Request/TestRepository.cs b/src/Untappd.Net.UnitTests/Request/TestRepository.cs index b2ad545..585acb6 100644 --- a/src/Untappd.Net.UnitTests/Request/TestRepository.cs +++ b/src/Untappd.Net.UnitTests/Request/TestRepository.cs @@ -8,6 +8,7 @@ using Untappd.Net.Client; using Untappd.Net.Request; using Untappd.Net.Responses.BeerInfo; using Untappd.Net.Responses.Actions; +using System.IO; namespace Untappd.Net.UnitTests.Request { @@ -27,8 +28,7 @@ namespace Untappd.Net.UnitTests.Request request.Setup(a => a.AddParameter(It.IsAny(), It.IsAny())); var response = new Mock(); - var obj = JsonConvert.SerializeObject(new BeerInfo()); - response.Setup(a => a.Content).Returns(obj); + response.Setup(a => a.Content).Returns(File.ReadAllText("../../Responses/json/BeerInfo.json")); client.Setup(a => a.Execute(It.IsAny())).Callback(() => { }).Returns(response.Object);