From e5c8540e9219c902f2274c6e69536fb118e96265 Mon Sep 17 00:00:00 2001 From: Tommy Parnell Date: Fri, 1 May 2015 05:24:41 -0400 Subject: [PATCH] fix it from failing to build --- .../Request/TestRepository.cs | 6 +-- .../Responses/TestDeserializer.cs | 6 +-- .../Responses/TestResponseEndpoints.cs | 3 -- .../EndpointConfigurationException.cs | 6 ++- src/Untappd.Net/Request/IAction.cs | 6 +-- src/Untappd.Net/Request/Repository.cs | 4 +- src/Untappd.Net/Request/RepositoryGet.cs | 8 ++-- src/Untappd.Net/Request/RepositoryPost.cs | 7 +--- src/Untappd.Net/Responses/Actions/CheckIn.cs | 16 ++++---- .../Responses/Actions/PendingFriends.cs | 40 +++++++++++++++++++ .../Responses/Actions/ToastUntoast.cs | 2 +- src/Untappd.Net/SingleObjectArrayConverter.cs | 1 - src/Untappd.Net/Untappd.Net.csproj | 7 ++-- 13 files changed, 71 insertions(+), 41 deletions(-) create mode 100644 src/Untappd.Net/Responses/Actions/PendingFriends.cs diff --git a/src/Untappd.Net.UnitTests/Request/TestRepository.cs b/src/Untappd.Net.UnitTests/Request/TestRepository.cs index 9b0a87b..5b89871 100644 --- a/src/Untappd.Net.UnitTests/Request/TestRepository.cs +++ b/src/Untappd.Net.UnitTests/Request/TestRepository.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading.Tasks; using Moq; using Newtonsoft.Json; using NUnit.Framework; @@ -6,7 +7,6 @@ using RestSharp; using Untappd.Net.Client; using Untappd.Net.Request; using Untappd.Net.Responses.BeerInfo; -using System.Threading.Tasks; namespace Untappd.Net.UnitTests.Request { @@ -19,7 +19,7 @@ namespace Untappd.Net.UnitTests.Request var mockCreds = new Mock(); mockCreds.Setup(a => a.ClientId).Returns("id"); mockCreds.Setup(a => a.ClientSecret).Returns("secret"); - var bodyParam = new Dictionary {{"key", "value"}}; + var bodyParam = new Dictionary {{"key", "value"}}; var client = new Mock(); var request = new Mock(); request.Setup(a => a.AddParameter(It.IsAny(), It.IsAny())); @@ -67,7 +67,7 @@ namespace Untappd.Net.UnitTests.Request public void ConfirmConfigureGetRequestClearsParams() { var constructorTest = new Repository(); - constructorTest.Request.Parameters.Add(new Parameter(){Name = "param"}); + constructorTest.Request.Parameters.Add(new Parameter {Name = "param"}); Assert.IsTrue(constructorTest.Request.Parameters.Count > 0); constructorTest.ConfigureRequest("endpoint"); Assert.IsTrue(constructorTest.Request.Parameters.Count == 0); diff --git a/src/Untappd.Net.UnitTests/Responses/TestDeserializer.cs b/src/Untappd.Net.UnitTests/Responses/TestDeserializer.cs index 1486e1f..7a3889f 100644 --- a/src/Untappd.Net.UnitTests/Responses/TestDeserializer.cs +++ b/src/Untappd.Net.UnitTests/Responses/TestDeserializer.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using Newtonsoft.Json; using NUnit.Framework; @@ -16,7 +17,6 @@ using Untappd.Net.Responses.UserInfo; using Untappd.Net.Responses.VenueInfo; using UserDistinctBeers = Untappd.Net.Responses.UserDistinctBeer; using UserWishList = Untappd.Net.Responses.UserWishlist; -using System; namespace Untappd.Net.UnitTests { @@ -31,7 +31,7 @@ namespace Untappd.Net.UnitTests { var credentials = new AuthenticatedUntappdCredentials(""); - Dictionary parameters = new Dictionary(); + Dictionary parameters = new Dictionary(); parameters.Add("q", "wild rose"); var repo = new Repository(); diff --git a/src/Untappd.Net.UnitTests/Responses/TestResponseEndpoints.cs b/src/Untappd.Net.UnitTests/Responses/TestResponseEndpoints.cs index deba7af..d4eba9d 100644 --- a/src/Untappd.Net.UnitTests/Responses/TestResponseEndpoints.cs +++ b/src/Untappd.Net.UnitTests/Responses/TestResponseEndpoints.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using NUnit.Framework; using Untappd.Net.Request; diff --git a/src/Untappd.Net/Exception/EndpointConfigurationException.cs b/src/Untappd.Net/Exception/EndpointConfigurationException.cs index 2d9786d..14db0d5 100644 --- a/src/Untappd.Net/Exception/EndpointConfigurationException.cs +++ b/src/Untappd.Net/Exception/EndpointConfigurationException.cs @@ -1,6 +1,8 @@ -namespace Untappd.Net.Exception +using System; + +namespace Untappd.Net.Exception { - [System.Serializable] + [Serializable] public class EndpointConfigurationException : BaseUntappdException { /// diff --git a/src/Untappd.Net/Request/IAction.cs b/src/Untappd.Net/Request/IAction.cs index e353c26..c169757 100644 --- a/src/Untappd.Net/Request/IAction.cs +++ b/src/Untappd.Net/Request/IAction.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using RestSharp; namespace Untappd.Net.Request diff --git a/src/Untappd.Net/Request/Repository.cs b/src/Untappd.Net/Request/Repository.cs index 961bef1..ad0af81 100644 --- a/src/Untappd.Net/Request/Repository.cs +++ b/src/Untappd.Net/Request/Repository.cs @@ -1,9 +1,7 @@ using System.Collections.Generic; +using System.Threading.Tasks; using Newtonsoft.Json; using RestSharp; -using Untappd.Net.Client; -using System.Threading.Tasks; -using System.Threading; namespace Untappd.Net.Request { diff --git a/src/Untappd.Net/Request/RepositoryGet.cs b/src/Untappd.Net/Request/RepositoryGet.cs index e945116..08a21c4 100644 --- a/src/Untappd.Net/Request/RepositoryGet.cs +++ b/src/Untappd.Net/Request/RepositoryGet.cs @@ -14,7 +14,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(IUnAuthenticatedUntappdCredentials credentials, string urlParameter, IDictionary bodyParameters = null) + public TResult Get(IUnAuthenticatedUntappdCredentials credentials, string urlParameter, IDictionary bodyParameters = null) where TResult : IUnAuthenticatedRequest, new() { var result = new TResult(); @@ -32,7 +32,7 @@ namespace Untappd.Net.Request /// /// /// - public Task GetAsync(IUnAuthenticatedUntappdCredentials credentials, string urlParameter, IDictionary bodyParameters = null) + public Task GetAsync(IUnAuthenticatedUntappdCredentials credentials, string urlParameter, IDictionary bodyParameters = null) where TResult : IUnAuthenticatedRequest, new() { var result = new TResult(); @@ -50,7 +50,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(IAuthenticatedUntappdCredentials credentials, string urlParameter = "", IDictionary bodyParameters = null) + public TResult Get(IAuthenticatedUntappdCredentials credentials, string urlParameter = "", IDictionary bodyParameters = null) where TResult : IAuthenticatedRequest, new() { var result = new TResult(); @@ -67,7 +67,7 @@ namespace Untappd.Net.Request /// /// /// - public Task GetAsync(IAuthenticatedUntappdCredentials credentials, string urlParameter = "", IDictionary bodyParameters = null) + public Task GetAsync(IAuthenticatedUntappdCredentials credentials, string urlParameter = "", IDictionary bodyParameters = null) where TResult : IAuthenticatedRequest, new() { var result = new TResult(); diff --git a/src/Untappd.Net/Request/RepositoryPost.cs b/src/Untappd.Net/Request/RepositoryPost.cs index a23a5d3..3e341c7 100644 --- a/src/Untappd.Net/Request/RepositoryPost.cs +++ b/src/Untappd.Net/Request/RepositoryPost.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Untappd.Net.Client; +using Untappd.Net.Client; namespace Untappd.Net.Request { diff --git a/src/Untappd.Net/Responses/Actions/CheckIn.cs b/src/Untappd.Net/Responses/Actions/CheckIn.cs index c648956..4a25c65 100644 --- a/src/Untappd.Net/Responses/Actions/CheckIn.cs +++ b/src/Untappd.Net/Responses/Actions/CheckIn.cs @@ -10,23 +10,25 @@ namespace Untappd.Net.Responses.Actions private short _rating; private string _shout; public Method RequestMethod { get{ return Method.POST;} } - public string EndPoint { get { return "/v4/checkin/add"; } } + public string EndPoint { get { return "v4/checkin/add"; } } public IDictionary BodyParameters { get { - var dict = new Dictionary(); - dict.Add("gmt_offset", gmt_offset); - dict.Add("timezone", timezone); - dict.Add("bid", bid); + var dict = new Dictionary + { + {"gmt_offset", gmt_offset}, + {"timezone", timezone}, + {"bid", bid} + }; if (geolat.HasValue) { - dict.Add("geolat", geolat); + dict.Add("geolat", geolat.Value); } if (geolng.HasValue) { - dict.Add("geolng", geolat); + dict.Add("geolng", geolng.Value); } if (!string.IsNullOrWhiteSpace(shout) && shout.Length <= 140) { diff --git a/src/Untappd.Net/Responses/Actions/PendingFriends.cs b/src/Untappd.Net/Responses/Actions/PendingFriends.cs new file mode 100644 index 0000000..efcd8ba --- /dev/null +++ b/src/Untappd.Net/Responses/Actions/PendingFriends.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RestSharp; +using Untappd.Net.Request; + +namespace Untappd.Net.Responses.Actions +{ + public class PendingFriends : IAction + { + public Method RequestMethod { get; private set; } + public string EndPoint { get { return "v4/user/pending"; }} + + public IDictionary BodyParameters + { + get + { + var dict = new Dictionary(); + if (Offset.HasValue) + { + dict.Add("offset", Offset.Value); + } + if (Limit.HasValue) + { + dict.Add("limit", Limit.Value); + } + return dict; + } + } + + public int? Offset { get; set; } + public int? Limit { get; set; } + public PendingFriends() + { + + } + } +} diff --git a/src/Untappd.Net/Responses/Actions/ToastUntoast.cs b/src/Untappd.Net/Responses/Actions/ToastUntoast.cs index 39d43d5..19d5640 100644 --- a/src/Untappd.Net/Responses/Actions/ToastUntoast.cs +++ b/src/Untappd.Net/Responses/Actions/ToastUntoast.cs @@ -10,7 +10,7 @@ namespace Untappd.Net.Responses.Actions public Method RequestMethod { get; private set; } public IDictionary BodyParameters { get; private set; } public string CheckinId { get; private set; } - public string EndPoint { get { return string.Format(" /v4/checkin/toast/{0}", CheckinId); } } + public string EndPoint { get { return string.Format("v4/checkin/toast/{0}", CheckinId); } } /// /// /// diff --git a/src/Untappd.Net/SingleObjectArrayConverter.cs b/src/Untappd.Net/SingleObjectArrayConverter.cs index cbfc17e..1d5ce7b 100644 --- a/src/Untappd.Net/SingleObjectArrayConverter.cs +++ b/src/Untappd.Net/SingleObjectArrayConverter.cs @@ -1,6 +1,5 @@ using System; using Newtonsoft.Json; -using Untappd.Net.Request; namespace Untappd.Net { diff --git a/src/Untappd.Net/Untappd.Net.csproj b/src/Untappd.Net/Untappd.Net.csproj index 27f251b..f79e080 100644 --- a/src/Untappd.Net/Untappd.Net.csproj +++ b/src/Untappd.Net/Untappd.Net.csproj @@ -50,6 +50,9 @@ + + + @@ -82,9 +85,7 @@ - - - +