more singleObjectConvert is required

This commit is contained in:
Tommy Parnell
2015-05-10 00:50:01 -04:00
parent 17e6997119
commit 2d1eb2233a
15 changed files with 334 additions and 68 deletions

View File

@@ -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<string, object> 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<string, object> bodyParameters = null, Method webMethod = Method.GET)
{
ConfigureRequest(endPoint, bodyParameters, webMethod);
Request.AddParameter("access_token", credentials.AccessToken);
}
private TResult ExecuteRequest<TResult>()
{
var response = Client.Execute(Request);

View File

@@ -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<TResult>();
}
@@ -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<TResult>();
}
@@ -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<TResult>();
}

View File

@@ -13,8 +13,7 @@ namespace Untappd.Net.Request
/// <returns>returns dynamic since often the return doesn't matter</returns>
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<dynamic>();
}
@@ -26,8 +25,7 @@ namespace Untappd.Net.Request
/// <returns>returns dynamic since often the return doesn't matter</returns>
public Task<dynamic> 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<dynamic>();
}
}

View File

@@ -128,6 +128,7 @@ namespace Untappd.Net.Responses.BeerInfo
public string CountryName { get; set; }
[JsonProperty("contact")]
[JsonConverter(typeof(SingleObjectArrayConverter<Contact>))]
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<Contact2>))]
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<Contact>))]
public object Contact { get; set; }
}
@@ -444,6 +447,7 @@ namespace Untappd.Net.Responses.BeerInfo
public string CountryName { get; set; }
[JsonProperty("contact")]
[JsonConverter(typeof(SingleObjectArrayConverter<Contact3>))]
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<Contact4>))]
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<Checkins>))]
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<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]

View File

@@ -264,6 +264,7 @@ namespace Untappd.Net.Responses.BeerSearch
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]

View File

@@ -892,6 +892,7 @@ namespace Untappd.Net.Responses.BreweryInfo
public Media Media { get; set; }
[JsonProperty("checkins")]
[JsonConverter(typeof(SingleObjectArrayConverter<Checkins>))]
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<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]

View File

@@ -152,6 +152,7 @@ namespace Untappd.Net.Responses.BrewerySearch
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]

View File

@@ -502,6 +502,7 @@ namespace Untappd.Net.Responses.Feeds.ActivityFeed
public bool Mg { get; set; }
[JsonProperty("checkins")]
[JsonConverter(typeof(SingleObjectArrayConverter<Checkins>))]
public Checkins Checkins { get; set; }
[JsonProperty("pagination")]

View File

@@ -472,6 +472,7 @@ namespace Untappd.Net.Responses.Feeds.UserActivityFeed
public Pagination Pagination { get; set; }
[JsonProperty("checkins")]
[JsonConverter(typeof(SingleObjectArrayConverter<Checkins>))]
public Checkins Checkins { get; set; }
}

View File

@@ -213,6 +213,7 @@ namespace Untappd.Net.Responses.UserBadges
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]

View File

@@ -231,6 +231,7 @@ namespace Untappd.Net.Responses.UserDistinctBeer
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]

View File

@@ -142,6 +142,7 @@ namespace Untappd.Net.Responses.UserFriends
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]

View File

@@ -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<Item3> 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<object> 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<Item3> Items { get; set; }
public IList<Item4> 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<Item4> Items { get; set; }
public IList<Item5> 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<Item5> Items { get; set; }
public IList<Item6> 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<Venue>))]
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<Item8> 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<Item6> Items { get; set; }
public IList<Item7> 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<Checkin>))]
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<Checkins>))]
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
{

View File

@@ -223,6 +223,7 @@ namespace Untappd.Net.Responses.UserWishlist
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]

View File

@@ -271,6 +271,7 @@ namespace Untappd.Net.Responses.VenueInfo
public string CountryName { get; set; }
[JsonProperty("contact")]
[JsonConverter(typeof(SingleObjectArrayConverter<Contact2>))]
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<Contact3>))]
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<Contact4>))]
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<Contact5>))]
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<Contact6>))]
public Contact6 Contact { get; set; }
[JsonProperty("location")]
@@ -1162,6 +1167,7 @@ namespace Untappd.Net.Responses.VenueInfo
public Location Location { get; set; }
[JsonProperty("contact")]
[JsonConverter(typeof(SingleObjectArrayConverter<Contact>))]
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<Checkins>))]
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<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]