From 4004f823067a28e46f6f8af304411029b3bfe6fa Mon Sep 17 00:00:00 2001 From: rodkings Date: Tue, 21 Apr 2015 12:58:11 -0600 Subject: [PATCH 1/5] commitAuth1 --- .../Client/AuthenticatedUntappdCredentials.cs | 4 +- .../UnAuthenticatedUntappdCredentials.cs | 18 +---- src/Untappd.Net/Properties/AssemblyInfo.cs | 4 +- .../Request/AuthenticatedRequest.cs | 9 ++- src/Untappd.Net/Request/Repository.cs | 16 ++++- src/Untappd.Net/Responses/BeerInfo.cs | 8 +-- src/Untappd.Net/Responses/BeerSearch.cs | 4 +- src/Untappd.Net/Responses/BreweryInfo.cs | 6 +- .../Responses/Feeds/UserActivityFeed.cs | 2 +- src/Untappd.Net/Responses/UserDistinctBeer.cs | 32 +++++++-- src/Untappd.Net/Responses/UserInfo.cs | 72 +++++++++++++++++-- src/Untappd.Net/Responses/VenueInfo.cs | 2 +- src/Untappd.Net/Untappd.Net.csproj | 2 + 13 files changed, 133 insertions(+), 46 deletions(-) diff --git a/src/Untappd.Net/Client/AuthenticatedUntappdCredentials.cs b/src/Untappd.Net/Client/AuthenticatedUntappdCredentials.cs index 52f6180..0d89f30 100644 --- a/src/Untappd.Net/Client/AuthenticatedUntappdCredentials.cs +++ b/src/Untappd.Net/Client/AuthenticatedUntappdCredentials.cs @@ -7,9 +7,9 @@ using Untappd.Client.Net; namespace Untappd.Net.Client { - public class AuthenticatedUntappdCredentials : UnAuthenticatedUntappdCredentials + public class AuthenticatedUntappdCredentials : UntappdCredentials, IAuthenticatedUntappdCredentials { - internal string AccessToken { get; private set; } + public string AccessToken { get; private set; } /// /// Pass your authenticated access token /// diff --git a/src/Untappd.Net/Client/UnAuthenticatedUntappdCredentials.cs b/src/Untappd.Net/Client/UnAuthenticatedUntappdCredentials.cs index 7d308cb..4729abe 100644 --- a/src/Untappd.Net/Client/UnAuthenticatedUntappdCredentials.cs +++ b/src/Untappd.Net/Client/UnAuthenticatedUntappdCredentials.cs @@ -7,28 +7,16 @@ using Untappd.Net.Client; namespace Untappd.Client.Net { - public class UnAuthenticatedUntappdCredentials : IUntappdCredentials + public class UnAuthenticatedUntappdCredentials : UntappdCredentials, IUnAuthenticadedUntappdCredentials { - public string ClientId { get; private set; } - public string ClientSecret { get; private set; } - /// /// UnAuthenticated request. Pass your API id and secret /// /// /// public UnAuthenticatedUntappdCredentials(string clientId, string clientSecret) - { - if (string.IsNullOrWhiteSpace(clientId)) - { - throw new ArgumentNullException("clientId"); - } - if (string.IsNullOrWhiteSpace(clientSecret)) - { - throw new ArgumentNullException("clientSecret"); - } - ClientId = string.Copy(clientId); - ClientSecret = string.Copy(clientSecret); + : base(clientId, clientSecret) + { } } } diff --git a/src/Untappd.Net/Properties/AssemblyInfo.cs b/src/Untappd.Net/Properties/AssemblyInfo.cs index 4334128..18cc67d 100644 --- a/src/Untappd.Net/Properties/AssemblyInfo.cs +++ b/src/Untappd.Net/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Untappd.Net/Request/AuthenticatedRequest.cs b/src/Untappd.Net/Request/AuthenticatedRequest.cs index 4f012af..ea1561f 100644 --- a/src/Untappd.Net/Request/AuthenticatedRequest.cs +++ b/src/Untappd.Net/Request/AuthenticatedRequest.cs @@ -14,9 +14,14 @@ namespace Untappd.Net.Request /// /// /// - internal string EndPoint(string parameter) + internal string EndPoint(string parameter = "") { - return string.Format(_EndPoint, parameter); + if (!String.IsNullOrEmpty(parameter)) + { + parameter = string.Format("/{0}", parameter); + return string.Format(_EndPoint, parameter); + } + return string.Format(_EndPoint, string.Empty); } } } diff --git a/src/Untappd.Net/Request/Repository.cs b/src/Untappd.Net/Request/Repository.cs index fcc6f01..322b722 100644 --- a/src/Untappd.Net/Request/Repository.cs +++ b/src/Untappd.Net/Request/Repository.cs @@ -20,7 +20,7 @@ namespace Untappd.Net.Request /// this is the main parameter for a request. ie v4/user/checkins/urlParameter. Consult the untappd docs, this can be null for a few requests /// Any additional params you wish to add to the request /// - public TResult Get (IUntappdCredentials credentials, string urlParameter, IDictionary bodyParameters = null) + public TResult Get (IUnAuthenticadedUntappdCredentials credentials, string urlParameter, IDictionary bodyParameters = null) where TResult : UnAuthenticatedRequest,new() { // throw new NotImplementedException(); @@ -40,10 +40,20 @@ namespace Untappd.Net.Request } - public TResult Get(IAuthenticatedUntappdCredentials credentials, string parameter) + public TResult Get(IAuthenticatedUntappdCredentials credentials, string parameter = "", IDictionary bodyParameters = null) where TResult : AuthenticatedRequest, new() { - throw new NotImplementedException(); + var result = new TResult(); + var client = new RestClient(Constants.BaseRequestString); + var request = new RestRequest(result.EndPoint(parameter), Method.GET); + request.AddParameter("access_token", credentials.AccessToken); + if (bodyParameters != null) + foreach (var param in bodyParameters) + request.AddParameter(param.Key, param.Value); + + var resp = client.Execute(request); + var jsonresult = JsonConvert.DeserializeObject(resp.Content); + return jsonresult; } } } diff --git a/src/Untappd.Net/Responses/BeerInfo.cs b/src/Untappd.Net/Responses/BeerInfo.cs index a7426dc..618fc3f 100644 --- a/src/Untappd.Net/Responses/BeerInfo.cs +++ b/src/Untappd.Net/Responses/BeerInfo.cs @@ -159,7 +159,7 @@ namespace Untappd.Net.Responses.BeerInfo public string BeerStyle { get; set; } [JsonProperty("auth_rating")] - public int AuthRating { get; set; } + public double AuthRating { get; set; } [JsonProperty("wish_list")] public bool WishList { get; set; } @@ -362,7 +362,7 @@ namespace Untappd.Net.Responses.BeerInfo public string BeerStyle { get; set; } [JsonProperty("auth_rating")] - public int AuthRating { get; set; } + public double AuthRating { get; set; } [JsonProperty("wish_list")] public bool WishList { get; set; } @@ -623,7 +623,7 @@ namespace Untappd.Net.Responses.BeerInfo public string BeerLabel { get; set; } [JsonProperty("auth_rating")] - public int AuthRating { get; set; } + public double AuthRating { get; set; } [JsonProperty("wish_list")] public bool WishList { get; set; } @@ -823,7 +823,7 @@ namespace Untappd.Net.Responses.BeerInfo public Brewery Brewery { get; set; } [JsonProperty("auth_rating")] - public int AuthRating { get; set; } + public double AuthRating { get; set; } [JsonProperty("wish_list")] public bool WishList { get; set; } diff --git a/src/Untappd.Net/Responses/BeerSearch.cs b/src/Untappd.Net/Responses/BeerSearch.cs index 7ec9c90..5b3d883 100644 --- a/src/Untappd.Net/Responses/BeerSearch.cs +++ b/src/Untappd.Net/Responses/BeerSearch.cs @@ -70,7 +70,7 @@ namespace Untappd.Net.Responses.BeerSearch public string BeerStyle { get; set; } [JsonProperty("auth_rating")] - public int AuthRating { get; set; } + public double AuthRating { get; set; } [JsonProperty("wish_list")] public bool WishList { get; set; } @@ -196,7 +196,7 @@ namespace Untappd.Net.Responses.BeerSearch public string BeerStyle { get; set; } [JsonProperty("auth_rating")] - public int AuthRating { get; set; } + public double AuthRating { get; set; } [JsonProperty("wish_list")] public bool WishList { get; set; } diff --git a/src/Untappd.Net/Responses/BreweryInfo.cs b/src/Untappd.Net/Responses/BreweryInfo.cs index b9e6ac6..c768278 100644 --- a/src/Untappd.Net/Responses/BreweryInfo.cs +++ b/src/Untappd.Net/Responses/BreweryInfo.cs @@ -176,7 +176,7 @@ namespace Untappd.Net.Responses.BreweryInfo public string BeerStyle { get; set; } [JsonProperty("auth_rating")] - public int AuthRating { get; set; } + public double AuthRating { get; set; } [JsonProperty("wish_list")] public bool WishList { get; set; } @@ -364,7 +364,7 @@ namespace Untappd.Net.Responses.BreweryInfo public string BeerStyle { get; set; } [JsonProperty("auth_rating")] - public int AuthRating { get; set; } + public double AuthRating { get; set; } [JsonProperty("wish_list")] public bool WishList { get; set; } @@ -764,7 +764,7 @@ namespace Untappd.Net.Responses.BreweryInfo public string CreatedAt { get; set; } [JsonProperty("auth_rating")] - public int AuthRating { get; set; } + public double AuthRating { get; set; } [JsonProperty("wish_list")] public bool WishList { get; set; } diff --git a/src/Untappd.Net/Responses/Feeds/UserActivityFeed.cs b/src/Untappd.Net/Responses/Feeds/UserActivityFeed.cs index ebc4ce3..bfa3eff 100644 --- a/src/Untappd.Net/Responses/Feeds/UserActivityFeed.cs +++ b/src/Untappd.Net/Responses/Feeds/UserActivityFeed.cs @@ -123,7 +123,7 @@ namespace Untappd.Net.Responses.Feeds public double BeerAbv { get; set; } [JsonProperty("auth_rating")] - public int AuthRating { get; set; } + public double AuthRating { get; set; } [JsonProperty("wish_list")] public bool WishList { get; set; } diff --git a/src/Untappd.Net/Responses/UserDistinctBeer.cs b/src/Untappd.Net/Responses/UserDistinctBeer.cs index da78330..3ba4d6a 100644 --- a/src/Untappd.Net/Responses/UserDistinctBeer.cs +++ b/src/Untappd.Net/Responses/UserDistinctBeer.cs @@ -73,7 +73,7 @@ namespace Untappd.Net.Responses.UserDistinctBeer public string CreatedAt { get; set; } [JsonProperty("auth_rating")] - public int AuthRating { get; set; } + public double AuthRating { get; set; } [JsonProperty("wish_list")] public bool WishList { get; set; } @@ -195,6 +195,28 @@ namespace Untappd.Net.Responses.UserDistinctBeer public IList Items { 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 { @@ -207,20 +229,16 @@ namespace Untappd.Net.Responses.UserDistinctBeer public class UserDistinctBeers : UnAuthenticatedRequest { + protected override string _EndPoint { get { return "v4/user/beers{0}"; } } [JsonProperty("meta")] public Meta Meta { get; set; } [JsonProperty("notifications")] - public IList Notifications { get; set; } + public Notifications Notifications { get; set; } [JsonProperty("response")] public Response Response { get; set; } - - protected override string _EndPoint - { - get { return "v4/user/beers/{0}"; } - } } } diff --git a/src/Untappd.Net/Responses/UserInfo.cs b/src/Untappd.Net/Responses/UserInfo.cs index 6e1650d..cf47f13 100644 --- a/src/Untappd.Net/Responses/UserInfo.cs +++ b/src/Untappd.Net/Responses/UserInfo.cs @@ -35,6 +35,12 @@ 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; } @@ -244,7 +250,7 @@ namespace Untappd.Net.Responses.UserInfo public double BeerAbv { get; set; } [JsonProperty("auth_rating")] - public int AuthRating { get; set; } + public double AuthRating { get; set; } [JsonProperty("wish_list")] public bool WishList { get; set; } @@ -722,6 +728,41 @@ namespace Untappd.Net.Responses.UserInfo 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")] + public Checkin Checkin { get; set; } + [JsonProperty("navigation")] + public Navigation Navigation { get; set; } + [JsonProperty("email_address")] + public string EmailAddress { get; set; } + } public class User { @@ -795,7 +836,29 @@ namespace Untappd.Net.Responses.UserInfo public string DateJoined { get; set; } [JsonProperty("settings")] - public IList Settings { get; set; } + 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 @@ -807,12 +870,13 @@ namespace Untappd.Net.Responses.UserInfo public class UserInfo : UnAuthenticatedRequest { - protected override string _EndPoint { get { return "v4/user/info/{0}"; } } + protected override string _EndPoint { get { return "v4/user/info{0}"; } } + [JsonProperty("meta")] public Meta Meta { get; set; } [JsonProperty("notifications")] - public IList Notifications { get; set; } + public Notifications Notifications { get; set; } [JsonProperty("response")] public Response Response { get; set; } diff --git a/src/Untappd.Net/Responses/VenueInfo.cs b/src/Untappd.Net/Responses/VenueInfo.cs index 6217574..d20d986 100644 --- a/src/Untappd.Net/Responses/VenueInfo.cs +++ b/src/Untappd.Net/Responses/VenueInfo.cs @@ -196,7 +196,7 @@ namespace Untappd.Net.Responses.VenueInfo public string BeerStyle { get; set; } [JsonProperty("auth_rating")] - public int AuthRating { get; set; } + public double AuthRating { get; set; } [JsonProperty("wish_list")] public bool WishList { get; set; } diff --git a/src/Untappd.Net/Untappd.Net.csproj b/src/Untappd.Net/Untappd.Net.csproj index 6a77633..1a16132 100644 --- a/src/Untappd.Net/Untappd.Net.csproj +++ b/src/Untappd.Net/Untappd.Net.csproj @@ -48,8 +48,10 @@ + + From 96d44bc8a0eaff83ff2b92375404d30458191789 Mon Sep 17 00:00:00 2001 From: rodkings Date: Tue, 21 Apr 2015 13:07:50 -0600 Subject: [PATCH 2/5] merge --- .../Request/AuthenticatedRequest.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Untappd.Net/Request/AuthenticatedRequest.cs b/src/Untappd.Net/Request/AuthenticatedRequest.cs index 0f766bb..ea1561f 100644 --- a/src/Untappd.Net/Request/AuthenticatedRequest.cs +++ b/src/Untappd.Net/Request/AuthenticatedRequest.cs @@ -1,4 +1,8 @@ -using Untappd.Net.Exception; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace Untappd.Net.Request { @@ -6,17 +10,18 @@ namespace Untappd.Net.Request { protected abstract string _EndPoint { get; } /// - /// Pass in the url parameter into the request...ie username, brewery, etc. + /// Pass in the parameter into the request...ie username, brewery, etc. /// - /// this can be null if request has no url params + /// /// - internal string EndPoint(string parameter) + internal string EndPoint(string parameter = "") { - if (string.IsNullOrWhiteSpace(_EndPoint)) + if (!String.IsNullOrEmpty(parameter)) { - throw new EndpointConfigurationException(); + parameter = string.Format("/{0}", parameter); + return string.Format(_EndPoint, parameter); } - return string.Format(_EndPoint, parameter); + return string.Format(_EndPoint, string.Empty); } } } From cff2559d856d60cf7b80dbd14b20a702e1eed14e Mon Sep 17 00:00:00 2001 From: rodkings Date: Tue, 21 Apr 2015 16:02:05 -0600 Subject: [PATCH 3/5] AuthenticatedRequests --- src/Untappd.Net.UnitTests/Class1.cs | 18 +- .../Request/TestRepository.cs | 2 +- .../Client/AuthenticatedUntappdCredentials.cs | 2 +- src/Untappd.Net/Properties/AssemblyInfo.cs | 3 +- ...uthenticatedRequest.cs => BasicRequest.cs} | 9 +- src/Untappd.Net/Request/IRequest.cs | 13 + .../Request/IUnAuthenticatedRequest.cs | 12 + src/Untappd.Net/Request/Repository.cs | 4 +- .../Request/UnAuthenticatedRequest.cs | 8 - src/Untappd.Net/Responses/BeerInfo.cs | 14 +- src/Untappd.Net/Responses/BeerSearch.cs | 13 +- src/Untappd.Net/Responses/BreweryInfo.cs | 6 +- src/Untappd.Net/Responses/BrewerySearch.cs | 11 +- .../Responses/Feeds/ActivityFeed.cs | 524 ++++++++++++++++++ .../Responses/Feeds/UserActivityFeed.cs | 10 +- src/Untappd.Net/Responses/UserBadges.cs | 9 +- src/Untappd.Net/Responses/UserDistinctBeer.cs | 2 +- src/Untappd.Net/Responses/UserFriends.cs | 5 +- src/Untappd.Net/Responses/UserInfo.cs | 5 +- src/Untappd.Net/Responses/UserWishlist.cs | 8 +- src/Untappd.Net/Responses/VenueInfo.cs | 10 +- src/Untappd.Net/Untappd.Net.csproj | 10 +- 22 files changed, 614 insertions(+), 84 deletions(-) rename src/Untappd.Net/Request/{AuthenticatedRequest.cs => BasicRequest.cs} (74%) create mode 100644 src/Untappd.Net/Request/IRequest.cs create mode 100644 src/Untappd.Net/Request/IUnAuthenticatedRequest.cs delete mode 100644 src/Untappd.Net/Request/UnAuthenticatedRequest.cs create mode 100644 src/Untappd.Net/Responses/Feeds/ActivityFeed.cs diff --git a/src/Untappd.Net.UnitTests/Class1.cs b/src/Untappd.Net.UnitTests/Class1.cs index 6cef4b8..acb9c3a 100644 --- a/src/Untappd.Net.UnitTests/Class1.cs +++ b/src/Untappd.Net.UnitTests/Class1.cs @@ -2,7 +2,8 @@ using NUnit.Framework; using Untappd.Net.Client; using Untappd.Net.Request; -using Untappd.Net.Responses.UserInfo; +using UserInfo = Untappd.Net.Responses.UserInfo; +using ActivityFeed = Untappd.Net.Responses.Feeds.ActivityFeed; namespace Untappd.Net.UnitTests { @@ -15,8 +16,21 @@ namespace Untappd.Net.UnitTests { var ts = new UnAuthenticatedUntappdCredentials("id", "scrt"); - var t = new Repository().Get(ts, "tparnell"); + var t = new Repository().Get(ts, "tparnell"); Console.WriteLine(t); } + + [Test] + public void GetActualJsonRequest() + { + var credentials = new AuthenticatedUntappdCredentials( + "", + "", + ""); + + var repo = new Repository(); + var activityFeed = repo.Get(credentials); + + } } } diff --git a/src/Untappd.Net.UnitTests/Request/TestRepository.cs b/src/Untappd.Net.UnitTests/Request/TestRepository.cs index 071c97c..ae876ad 100644 --- a/src/Untappd.Net.UnitTests/Request/TestRepository.cs +++ b/src/Untappd.Net.UnitTests/Request/TestRepository.cs @@ -15,7 +15,7 @@ namespace Untappd.Net.UnitTests.Request [Test] public void ConfirmRequestWorks() { - var mockCreds = new Mock(); + var mockCreds = new Mock(); mockCreds.Setup(a => a.ClientId).Returns("id"); mockCreds.Setup(a => a.ClientSecret).Returns("secret"); var bodyParam = new Dictionary {{"key", "value"}}; diff --git a/src/Untappd.Net/Client/AuthenticatedUntappdCredentials.cs b/src/Untappd.Net/Client/AuthenticatedUntappdCredentials.cs index 5247742..a0f5b41 100644 --- a/src/Untappd.Net/Client/AuthenticatedUntappdCredentials.cs +++ b/src/Untappd.Net/Client/AuthenticatedUntappdCredentials.cs @@ -2,7 +2,7 @@ namespace Untappd.Net.Client { - public class AuthenticatedUntappdCredentials : UnAuthenticatedUntappdCredentials + public class AuthenticatedUntappdCredentials : UntappdCredentials, IAuthenticatedUntappdCredentials { public string AccessToken { get; private set; } /// diff --git a/src/Untappd.Net/Properties/AssemblyInfo.cs b/src/Untappd.Net/Properties/AssemblyInfo.cs index 4590a21..b99c357 100644 --- a/src/Untappd.Net/Properties/AssemblyInfo.cs +++ b/src/Untappd.Net/Properties/AssemblyInfo.cs @@ -33,5 +33,6 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("0.2.*")] -[assembly: AssemblyFileVersion("0.2.*")] +//If AssemblyFileVersion is not explicitly set, it takes its value from the AssemblyVersion attribute. +//[assembly: AssemblyFileVersion("0.2.*")] [assembly: InternalsVisibleTo("Untappd.Net.UnitTests")] \ No newline at end of file diff --git a/src/Untappd.Net/Request/AuthenticatedRequest.cs b/src/Untappd.Net/Request/BasicRequest.cs similarity index 74% rename from src/Untappd.Net/Request/AuthenticatedRequest.cs rename to src/Untappd.Net/Request/BasicRequest.cs index ea1561f..37e5688 100644 --- a/src/Untappd.Net/Request/AuthenticatedRequest.cs +++ b/src/Untappd.Net/Request/BasicRequest.cs @@ -1,12 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace Untappd.Net.Request { - public abstract class AuthenticatedRequest + public abstract class BasicRequest { protected abstract string _EndPoint { get; } /// @@ -14,7 +9,7 @@ namespace Untappd.Net.Request /// /// /// - internal string EndPoint(string parameter = "") + public string EndPoint(string parameter = "") { if (!String.IsNullOrEmpty(parameter)) { diff --git a/src/Untappd.Net/Request/IRequest.cs b/src/Untappd.Net/Request/IRequest.cs new file mode 100644 index 0000000..44b548a --- /dev/null +++ b/src/Untappd.Net/Request/IRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Untappd.Net.Request +{ + public interface IRequest + { + string EndPoint(string parameter); + } +} diff --git a/src/Untappd.Net/Request/IUnAuthenticatedRequest.cs b/src/Untappd.Net/Request/IUnAuthenticatedRequest.cs new file mode 100644 index 0000000..a4d49b1 --- /dev/null +++ b/src/Untappd.Net/Request/IUnAuthenticatedRequest.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Untappd.Net.Request +{ + public interface IUnAuthenticatedRequest : IRequest + { + } +} diff --git a/src/Untappd.Net/Request/Repository.cs b/src/Untappd.Net/Request/Repository.cs index 64c19ee..d25cca8 100644 --- a/src/Untappd.Net/Request/Repository.cs +++ b/src/Untappd.Net/Request/Repository.cs @@ -31,7 +31,7 @@ namespace Untappd.Net.Request /// Any additional params you wish to add to the request /// public TResult Get (IUnAuthenticadedUntappdCredentials credentials, string urlParameter, IDictionary bodyParameters = null) - where TResult : UnAuthenticatedRequest,new() + where TResult : IUnAuthenticatedRequest,new() { var result = new TResult(); Request.Resource = result.EndPoint(urlParameter); @@ -50,7 +50,7 @@ namespace Untappd.Net.Request } public TResult Get(IAuthenticatedUntappdCredentials credentials, string parameter = "", IDictionary bodyParameters = null) - where TResult : AuthenticatedRequest, new() + where TResult : IAuthenticatedRequest, new() { var result = new TResult(); var client = new RestClient(Constants.BaseRequestString); diff --git a/src/Untappd.Net/Request/UnAuthenticatedRequest.cs b/src/Untappd.Net/Request/UnAuthenticatedRequest.cs deleted file mode 100644 index 420ad74..0000000 --- a/src/Untappd.Net/Request/UnAuthenticatedRequest.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Untappd.Net.Request -{ - public abstract class UnAuthenticatedRequest : AuthenticatedRequest - { - protected override abstract string _EndPoint { get; } - - } -} diff --git a/src/Untappd.Net/Responses/BeerInfo.cs b/src/Untappd.Net/Responses/BeerInfo.cs index e80f8aa..7b89470 100644 --- a/src/Untappd.Net/Responses/BeerInfo.cs +++ b/src/Untappd.Net/Responses/BeerInfo.cs @@ -847,9 +847,10 @@ namespace Untappd.Net.Responses.BeerInfo public Beer Beer { get; set; } } - public class BeerInfo : UnAuthenticatedRequest + public class BeerInfo : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest { - + protected override string _EndPoint { get { return "v4/beer/info{0}"; } + } [JsonProperty("meta")] public Meta Meta { get; set; } @@ -858,12 +859,5 @@ namespace Untappd.Net.Responses.BeerInfo [JsonProperty("response")] public Response Response { get; set; } - - protected override string _EndPoint - { - get { return "v4/beer/info/{0}"; } - } } - - -} +} \ No newline at end of file diff --git a/src/Untappd.Net/Responses/BeerSearch.cs b/src/Untappd.Net/Responses/BeerSearch.cs index 29f7e0d..4dcdb0f 100644 --- a/src/Untappd.Net/Responses/BeerSearch.cs +++ b/src/Untappd.Net/Responses/BeerSearch.cs @@ -388,9 +388,10 @@ namespace Untappd.Net.Responses.BeerSearch public Breweries Breweries { get; set; } } - public class BeerSearch : UnAuthenticatedRequest + public class BeerSearch : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest { - + protected override string _EndPoint { get { return "v4/search/beer"; } + } [JsonProperty("meta")] public Meta Meta { get; set; } @@ -399,11 +400,5 @@ namespace Untappd.Net.Responses.BeerSearch [JsonProperty("response")] public Response Response { get; set; } - - protected override string _EndPoint - { - get { return "v4/search/beer"; } - } } - -} +} \ No newline at end of file diff --git a/src/Untappd.Net/Responses/BreweryInfo.cs b/src/Untappd.Net/Responses/BreweryInfo.cs index 3c76191..15659e8 100644 --- a/src/Untappd.Net/Responses/BreweryInfo.cs +++ b/src/Untappd.Net/Responses/BreweryInfo.cs @@ -954,9 +954,9 @@ namespace Untappd.Net.Responses.BreweryInfo public Brewery Brewery { get; set; } } - public class BreweryInfo : UnAuthenticatedRequest + public class BreweryInfo : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest { - protected override string _EndPoint { get { return "v4/brewery/info/{0}"; } } + protected override string _EndPoint { get { return "v4/brewery/info{0}"; } } [JsonProperty("meta")] public Meta Meta { get; set; } @@ -967,4 +967,4 @@ namespace Untappd.Net.Responses.BreweryInfo [JsonProperty("response")] public Response Response { get; set; } } -} +} \ No newline at end of file diff --git a/src/Untappd.Net/Responses/BrewerySearch.cs b/src/Untappd.Net/Responses/BrewerySearch.cs index 8c85929..e3b57c9 100644 --- a/src/Untappd.Net/Responses/BrewerySearch.cs +++ b/src/Untappd.Net/Responses/BrewerySearch.cs @@ -115,9 +115,10 @@ namespace Untappd.Net.Responses.BrewerySearch public Brewery Brewery { get; set; } } - public class BrewerySearch : UnAuthenticatedRequest + public class BrewerySearch : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest { - + protected override string _EndPoint { get { return "v4/search/brewery"; } + } [JsonProperty("meta")] public Meta Meta { get; set; } @@ -126,11 +127,5 @@ namespace Untappd.Net.Responses.BrewerySearch [JsonProperty("response")] public Response Response { get; set; } - - protected override string _EndPoint - { - get { return "v4/search/brewery"; } - } } - } diff --git a/src/Untappd.Net/Responses/Feeds/ActivityFeed.cs b/src/Untappd.Net/Responses/Feeds/ActivityFeed.cs new file mode 100644 index 0000000..60f84f5 --- /dev/null +++ b/src/Untappd.Net/Responses/Feeds/ActivityFeed.cs @@ -0,0 +1,524 @@ +using System.Collections.Generic; +using Newtonsoft.Json; +using Untappd.Net.Request; + +namespace Untappd.Net.Responses.Feeds.ActivityFeed +{ + public class ResponseTime + { + + [JsonProperty("time")] + public double Time { get; set; } + + [JsonProperty("measure")] + public string Measure { get; set; } + } + + public class InitTime + { + + [JsonProperty("time")] + public double Time { get; set; } + + [JsonProperty("measure")] + public string Measure { get; set; } + } + + public class Meta + { + + [JsonProperty("code")] + public int Code { get; set; } + + [JsonProperty("response_time")] + public ResponseTime ResponseTime { get; set; } + + [JsonProperty("init_time")] + 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 User + { + + [JsonProperty("uid")] + public int Uid { get; set; } + + [JsonProperty("user_name")] + public string UserName { get; set; } + + [JsonProperty("first_name")] + public string FirstName { get; set; } + + [JsonProperty("last_name")] + public string LastName { get; set; } + + [JsonProperty("location")] + public string Location { get; set; } + + [JsonProperty("url")] + public string Url { get; set; } + + [JsonProperty("is_supporter")] + public int IsSupporter { get; set; } + + [JsonProperty("relationship")] + public string Relationship { get; set; } + + [JsonProperty("bio")] + public string Bio { get; set; } + + [JsonProperty("user_avatar")] + public string UserAvatar { get; set; } + } + + public class Beer + { + + [JsonProperty("bid")] + public int Bid { get; set; } + + [JsonProperty("beer_name")] + public string BeerName { get; set; } + + [JsonProperty("beer_label")] + public string BeerLabel { get; set; } + + [JsonProperty("beer_style")] + public string BeerStyle { get; set; } + + [JsonProperty("beer_abv")] + public double BeerAbv { get; set; } + + [JsonProperty("auth_rating")] + public int AuthRating { get; set; } + + [JsonProperty("wish_list")] + public bool WishList { get; set; } + + [JsonProperty("beer_active")] + public int BeerActive { get; set; } + } + + public class Contact + { + + [JsonProperty("twitter")] + public string Twitter { get; set; } + + [JsonProperty("facebook")] + public string Facebook { get; set; } + + [JsonProperty("instagram")] + public string Instagram { get; set; } + + [JsonProperty("url")] + public string Url { get; set; } + } + + public class Location + { + + [JsonProperty("brewery_city")] + public string BreweryCity { get; set; } + + [JsonProperty("brewery_state")] + public string BreweryState { get; set; } + + [JsonProperty("lat")] + public double Lat { get; set; } + + [JsonProperty("lng")] + public double Lng { get; set; } + } + + public class Brewery + { + + [JsonProperty("brewery_id")] + public int BreweryId { get; set; } + + [JsonProperty("brewery_name")] + public string BreweryName { get; set; } + + [JsonProperty("brewery_slug")] + public string BrewerySlug { get; set; } + + [JsonProperty("brewery_label")] + public string BreweryLabel { get; set; } + + [JsonProperty("country_name")] + public string CountryName { get; set; } + + [JsonProperty("contact")] + public Contact Contact { get; set; } + + [JsonProperty("location")] + public Location Location { get; set; } + + [JsonProperty("brewery_active")] + public int BreweryActive { get; set; } + } + + public class User2 + { + + [JsonProperty("uid")] + public int Uid { get; set; } + + [JsonProperty("user_name")] + public string UserName { get; set; } + + [JsonProperty("first_name")] + public string FirstName { get; set; } + + [JsonProperty("last_name")] + public string LastName { get; set; } + + [JsonProperty("bio")] + public string Bio { get; set; } + + [JsonProperty("location")] + public string Location { get; set; } + + [JsonProperty("relationship")] + public string Relationship { get; set; } + + [JsonProperty("is_supporter")] + public int IsSupporter { get; set; } + + [JsonProperty("user_avatar")] + public string UserAvatar { get; set; } + + [JsonProperty("user_link")] + public string UserLink { get; set; } + + [JsonProperty("account_type")] + public string AccountType { get; set; } + + [JsonProperty("brewery_details")] + public IList BreweryDetails { get; set; } + } + + public class Item2 + { + + [JsonProperty("user")] + public User2 User { get; set; } + + [JsonProperty("checkin_id")] + public int CheckinId { get; set; } + + [JsonProperty("comment_id")] + public int CommentId { get; set; } + + [JsonProperty("comment_owner")] + public bool CommentOwner { get; set; } + + [JsonProperty("comment_editor")] + public bool CommentEditor { get; set; } + + [JsonProperty("comment")] + public string Comment { get; set; } + + [JsonProperty("created_at")] + public string CreatedAt { get; set; } + + [JsonProperty("comment_source")] + public string CommentSource { get; set; } + } + + public class Comments + { + + [JsonProperty("total_count")] + public int TotalCount { get; set; } + + [JsonProperty("count")] + public int Count { get; set; } + + [JsonProperty("items")] + public IList Items { get; set; } + } + + public class User3 + { + + [JsonProperty("uid")] + public int Uid { get; set; } + + [JsonProperty("user_name")] + public string UserName { get; set; } + + [JsonProperty("first_name")] + public string FirstName { get; set; } + + [JsonProperty("last_name")] + public string LastName { get; set; } + + [JsonProperty("bio")] + public string Bio { get; set; } + + [JsonProperty("location")] + public string Location { get; set; } + + [JsonProperty("user_avatar")] + public string UserAvatar { get; set; } + + [JsonProperty("user_link")] + public string UserLink { get; set; } + + [JsonProperty("account_type")] + public string AccountType { get; set; } + + [JsonProperty("brewery_details")] + public IList BreweryDetails { get; set; } + } + + public class Item3 + { + + [JsonProperty("uid")] + public int Uid { get; set; } + + [JsonProperty("user")] + public User3 User { get; set; } + + [JsonProperty("like_id")] + public int LikeId { get; set; } + + [JsonProperty("like_owner")] + public bool LikeOwner { get; set; } + + [JsonProperty("created_at")] + public string CreatedAt { get; set; } + } + + public class Toasts + { + + [JsonProperty("total_count")] + public int TotalCount { get; set; } + + [JsonProperty("count")] + public int Count { get; set; } + + [JsonProperty("auth_toast")] + public bool AuthToast { get; set; } + + [JsonProperty("items")] + public IList Items { get; set; } + } + + public class Photo + { + + [JsonProperty("photo_img_sm")] + public string PhotoImgSm { get; set; } + + [JsonProperty("photo_img_md")] + public string PhotoImgMd { get; set; } + + [JsonProperty("photo_img_lg")] + public string PhotoImgLg { get; set; } + + [JsonProperty("photo_img_og")] + public string PhotoImgOg { get; set; } + } + + public class Item4 + { + + [JsonProperty("photo_id")] + public int PhotoId { get; set; } + + [JsonProperty("photo")] + public Photo Photo { get; set; } + } + + public class Media + { + + [JsonProperty("count")] + public int Count { get; set; } + + [JsonProperty("items")] + public IList Items { get; set; } + } + + public class Source + { + + [JsonProperty("app_name")] + public string AppName { get; set; } + + [JsonProperty("app_website")] + public string AppWebsite { get; set; } + } + + public class BadgeImage + { + + [JsonProperty("sm")] + public string Sm { get; set; } + + [JsonProperty("md")] + public string Md { get; set; } + + [JsonProperty("lg")] + public string Lg { get; set; } + } + + public class Item5 + { + + [JsonProperty("badge_id")] + public int BadgeId { get; set; } + + [JsonProperty("user_badge_id")] + public int UserBadgeId { get; set; } + + [JsonProperty("badge_name")] + public string BadgeName { get; set; } + + [JsonProperty("badge_description")] + public string BadgeDescription { get; set; } + + [JsonProperty("created_at")] + public string CreatedAt { get; set; } + + [JsonProperty("badge_image")] + public BadgeImage BadgeImage { get; set; } + } + + public class Badges + { + + [JsonProperty("count")] + public int Count { get; set; } + + [JsonProperty("items")] + public IList Items { get; set; } + } + + public class Item + { + + [JsonProperty("checkin_id")] + public int CheckinId { get; set; } + + [JsonProperty("created_at")] + public string CreatedAt { get; set; } + + [JsonProperty("checkin_comment")] + public string CheckinComment { get; set; } + + [JsonProperty("rating_score")] + public double RatingScore { get; set; } + + [JsonProperty("user")] + public User User { get; set; } + + [JsonProperty("beer")] + public Beer Beer { get; set; } + + [JsonProperty("brewery")] + public Brewery Brewery { get; set; } + + [JsonProperty("venue")] + public object Venue { get; set; } + + [JsonProperty("comments")] + public Comments Comments { get; set; } + + [JsonProperty("toasts")] + public Toasts Toasts { get; set; } + + [JsonProperty("media")] + public Media Media { get; set; } + + [JsonProperty("source")] + public Source Source { get; set; } + + [JsonProperty("badges")] + public Badges Badges { get; set; } + } + + public class Checkins + { + + [JsonProperty("count")] + public int Count { get; set; } + + [JsonProperty("items")] + public IList Items { get; set; } + } + + public class Pagination + { + + [JsonProperty("next_url")] + public string NextUrl { get; set; } + + [JsonProperty("max_id")] + public int MaxId { get; set; } + + [JsonProperty("since_url")] + public string SinceUrl { get; set; } + } + + public class Response + { + + [JsonProperty("mg")] + public bool Mg { get; set; } + + [JsonProperty("checkins")] + public Checkins Checkins { get; set; } + + [JsonProperty("pagination")] + public Pagination Pagination { get; set; } + } + + public class ActivityFeed : BasicRequest, IAuthenticatedRequest + { + protected override string _EndPoint { get { return "/v4/checkin/recent"; } } + + [JsonProperty("meta")] + public Meta Meta { get; set; } + + [JsonProperty("notifications")] + public Notifications Notifications { get; set; } + + [JsonProperty("response")] + public Response Response { get; set; } + } +} diff --git a/src/Untappd.Net/Responses/Feeds/UserActivityFeed.cs b/src/Untappd.Net/Responses/Feeds/UserActivityFeed.cs index 047066e..5e2d9f4 100644 --- a/src/Untappd.Net/Responses/Feeds/UserActivityFeed.cs +++ b/src/Untappd.Net/Responses/Feeds/UserActivityFeed.cs @@ -2,7 +2,7 @@ using Newtonsoft.Json; using Untappd.Net.Request; -namespace Untappd.Net.Responses.Feeds +namespace Untappd.Net.Responses.Feeds.UserActivityFeed { public sealed class ResponseTime { @@ -424,8 +424,9 @@ namespace Untappd.Net.Responses.Feeds public Checkins Checkins { get; set; } } - public class UserActivityFeed : UnAuthenticatedRequest + public class UserActivityFeed : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest { + protected override string _EndPoint { get { return "v4/user/checkins{0}"; } } [JsonProperty("meta")] public Meta Meta { get; set; } @@ -435,10 +436,5 @@ namespace Untappd.Net.Responses.Feeds [JsonProperty("response")] public Response Response { get; set; } - - protected override string _EndPoint - { - get { return "v4/user/checkins/{0}"; } - } } } diff --git a/src/Untappd.Net/Responses/UserBadges.cs b/src/Untappd.Net/Responses/UserBadges.cs index 9f6311b..46979be 100644 --- a/src/Untappd.Net/Responses/UserBadges.cs +++ b/src/Untappd.Net/Responses/UserBadges.cs @@ -126,9 +126,10 @@ namespace Untappd.Net.Responses.UserBadges public IList Items { get; set; } } - public class UserBadges : UnAuthenticatedRequest + public class UserBadges : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest { - protected override string _EndPoint { get { return "v4/user/badges/{0}"; } } + protected override string _EndPoint { get { return "v4/user/badges{0}"; } } + [JsonProperty("meta")] public Meta Meta { get; set; } @@ -138,6 +139,4 @@ namespace Untappd.Net.Responses.UserBadges [JsonProperty("response")] public Response Response { get; set; } } - - -} +} \ No newline at end of file diff --git a/src/Untappd.Net/Responses/UserDistinctBeer.cs b/src/Untappd.Net/Responses/UserDistinctBeer.cs index 61254de..5ceea9c 100644 --- a/src/Untappd.Net/Responses/UserDistinctBeer.cs +++ b/src/Untappd.Net/Responses/UserDistinctBeer.cs @@ -223,7 +223,7 @@ namespace Untappd.Net.Responses.UserDistinctBeer public Beers Beers { get; set; } } - public class UserDistinctBeers : UnAuthenticatedRequest + public class UserDistinctBeers : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest { protected override string _EndPoint { get { return "v4/user/beers{0}"; } } diff --git a/src/Untappd.Net/Responses/UserFriends.cs b/src/Untappd.Net/Responses/UserFriends.cs index 5002ef6..ebf9fc9 100644 --- a/src/Untappd.Net/Responses/UserFriends.cs +++ b/src/Untappd.Net/Responses/UserFriends.cs @@ -105,9 +105,10 @@ namespace Untappd.Net.Responses.UserFriends public IList Items { get; set; } } - public class UserFriends : UnAuthenticatedRequest + public class UserFriends : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest { - protected override string _EndPoint { get { return "v4/user/friends/{0}"; } } + protected override string _EndPoint { get { return "v4/user/friends{0}"; } } + [JsonProperty("meta")] public Meta Meta { get; set; } diff --git a/src/Untappd.Net/Responses/UserInfo.cs b/src/Untappd.Net/Responses/UserInfo.cs index 9741971..5d75338 100644 --- a/src/Untappd.Net/Responses/UserInfo.cs +++ b/src/Untappd.Net/Responses/UserInfo.cs @@ -864,7 +864,7 @@ namespace Untappd.Net.Responses.UserInfo public User User { get; set; } } - public class UserInfo : UnAuthenticatedRequest + public class UserInfo : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest { protected override string _EndPoint { get { return "v4/user/info{0}"; } } @@ -877,5 +877,4 @@ namespace Untappd.Net.Responses.UserInfo [JsonProperty("response")] public Response Response { get; set; } } - -} +} \ No newline at end of file diff --git a/src/Untappd.Net/Responses/UserWishlist.cs b/src/Untappd.Net/Responses/UserWishlist.cs index 6f7a3ac..d3e7821 100644 --- a/src/Untappd.Net/Responses/UserWishlist.cs +++ b/src/Untappd.Net/Responses/UserWishlist.cs @@ -64,9 +64,9 @@ namespace Untappd.Net.Responses.UserWishlist public Beers Beers { get; set; } } - public class UserWishList : UnAuthenticatedRequest + public class UserWishList : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest { - protected override string _EndPoint { get { return "/v4/user/wishlist/{0}"; } } + protected override string _EndPoint { get { return "/v4/user/wishlist{0}"; } } [JsonProperty("meta")] public Meta Meta { get; set; } @@ -76,6 +76,4 @@ namespace Untappd.Net.Responses.UserWishlist [JsonProperty("response")] public Response Response { get; set; } } - - -} +} \ No newline at end of file diff --git a/src/Untappd.Net/Responses/VenueInfo.cs b/src/Untappd.Net/Responses/VenueInfo.cs index 233e002..a649351 100644 --- a/src/Untappd.Net/Responses/VenueInfo.cs +++ b/src/Untappd.Net/Responses/VenueInfo.cs @@ -554,8 +554,10 @@ namespace Untappd.Net.Responses.VenueInfo public Venue Venue { get; set; } } - public class VenueInfo : UnAuthenticatedRequest + public class VenueInfo : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest { + protected override string _EndPoint { get { return "v4/venue/info{0}"; } + } [JsonProperty("meta")] public Meta Meta { get; set; } @@ -565,11 +567,5 @@ namespace Untappd.Net.Responses.VenueInfo [JsonProperty("response")] public Response Response { get; set; } - - protected override string _EndPoint - { - get { return "v4/venue/info/{0}"; } - } } - } diff --git a/src/Untappd.Net/Untappd.Net.csproj b/src/Untappd.Net/Untappd.Net.csproj index b4230cf..bf3d012 100644 --- a/src/Untappd.Net/Untappd.Net.csproj +++ b/src/Untappd.Net/Untappd.Net.csproj @@ -55,12 +55,15 @@ - - + + + + + @@ -74,6 +77,9 @@ + + +