format the code so its less crappy looking

This commit is contained in:
Tommy Parnell
2015-09-05 12:32:14 -04:00
parent de595043ed
commit 6cb1d99da6
56 changed files with 5617 additions and 5968 deletions

View File

@@ -4,24 +4,25 @@ using Untappd.Net.Authentication;
namespace Untappd.Net.UnitTests.Authentication namespace Untappd.Net.UnitTests.Authentication
{ {
[TestFixture] [TestFixture]
public class TestAuthenticatedUntappdCredentials public class TestAuthenticatedUntappdCredentials
{ {
[Test] [Test]
[ExpectedException(typeof(ArgumentNullException))] [ExpectedException(typeof(ArgumentNullException))]
public void ExpectException() public void ExpectException()
{ {
var t = new AuthenticatedUntappdCredentials(null); var t = new AuthenticatedUntappdCredentials(null);
} }
[Test]
public void ExpectValid() [Test]
{ public void ExpectValid()
var token = "awesome"; {
var t = new AuthenticatedUntappdCredentials(token); var token = "awesome";
Assert.AreEqual(token, "awesome"); var t = new AuthenticatedUntappdCredentials(token);
token = "newString"; Assert.AreEqual(token, "awesome");
//Make sure the reference is not copied over token = "newString";
Assert.AreEqual("awesome", t.AuthenticationData["access_token"]); //Make sure the reference is not copied over
} Assert.AreEqual("awesome", t.AuthenticationData["access_token"]);
} }
} }
}

View File

@@ -5,60 +5,56 @@ using Untappd.Net.OAuth;
namespace Untappd.Net.UnitTests.Authentication namespace Untappd.Net.UnitTests.Authentication
{ {
[TestFixture] [TestFixture]
public class TestAuthenticationHelper public class TestAuthenticationHelper
{ {
[Test] [Test]
[ExpectedException(typeof(ArgumentNullException))] [ExpectedException(typeof(ArgumentNullException))]
public void TestRedirectUserToException1() public void TestRedirectUserToException1()
{ {
AuthenticationHelper.RedirectUserTo(null, "url");
}
AuthenticationHelper.RedirectUserTo(null, "url"); [Test]
} [ExpectedException(typeof(ArgumentNullException))]
[Test] public void TestRedirectUserToException2()
[ExpectedException(typeof(ArgumentNullException))] {
public void TestRedirectUserToException2() AuthenticationHelper.RedirectUserTo(new UnAuthenticatedUntappdCredentials("d", "d"), string.Empty);
{ }
AuthenticationHelper.RedirectUserTo(new UnAuthenticatedUntappdCredentials("d", "d"), string.Empty); [Test]
} [ExpectedException(typeof(ArgumentNullException))]
[Test] public void TestTokenUrlException1()
[ExpectedException(typeof(ArgumentNullException))] {
public void TestTokenUrlException1() AuthenticationHelper.TokenUrl(null, "some", "code");
{ }
AuthenticationHelper.TokenUrl(null, "some", "code"); [Test]
} [ExpectedException(typeof(ArgumentNullException))]
[Test] public void TestTokenUrlException2()
[ExpectedException(typeof(ArgumentNullException))] {
public void TestTokenUrlException2() AuthenticationHelper.TokenUrl(new UnAuthenticatedUntappdCredentials("d", "d"), string.Empty, "code");
{ }
AuthenticationHelper.TokenUrl(new UnAuthenticatedUntappdCredentials("d", "d"), string.Empty, "code"); [Test]
} [ExpectedException(typeof(ArgumentNullException))]
[Test] public void TestTokenUrlException3()
[ExpectedException(typeof(ArgumentNullException))] {
public void TestTokenUrlException3() AuthenticationHelper.TokenUrl(new UnAuthenticatedUntappdCredentials("d", "d"), "ds", string.Empty);
{ }
AuthenticationHelper.TokenUrl(new UnAuthenticatedUntappdCredentials("d", "d"), "ds", string.Empty); [Test]
} public void TestTokenUrl()
{
var s = AuthenticationHelper.TokenUrl(new UnAuthenticatedUntappdCredentials("d", "d"), "ds", "code");
Assert.AreEqual(s, Constants.OAuthTokenEndPoint + "/?client_id=d&client_secret=d&response_type=code&redirect_url=ds&code=code");
}
[Test] [Test]
public void TestTokenUrl() public void TestRedirectUrl()
{ {
var s = AuthenticationHelper.RedirectUserTo(new UnAuthenticatedUntappdCredentials("d", "d"), "ds");
var s = AuthenticationHelper.TokenUrl(new UnAuthenticatedUntappdCredentials("d", "d"), "ds", "code"); Assert.AreEqual(s, Constants.BaseRequestString + "/?client_id=d&response_type=code&redirect_url=ds");
Assert.AreEqual(s, Constants.OAuthTokenEndPoint + "/?client_id=d&client_secret=d&response_type=code&redirect_url=ds&code=code"); }
}
} }
[Test]
public void TestRedirectUrl()
{
var s = AuthenticationHelper.RedirectUserTo(new UnAuthenticatedUntappdCredentials("d", "d"), "ds");
Assert.AreEqual(s, Constants.BaseRequestString + "/?client_id=d&response_type=code&redirect_url=ds");
}
}
}

View File

@@ -4,20 +4,21 @@ using Untappd.Net.Authentication;
namespace Untappd.Net.UnitTests.Authentication namespace Untappd.Net.UnitTests.Authentication
{ {
[TestFixture] [TestFixture]
public class TestUnAuthenticatedUntappdCredentials public class TestUnAuthenticatedUntappdCredentials
{ {
[Test] [Test]
[ExpectedException(typeof(ArgumentNullException))] [ExpectedException(typeof(ArgumentNullException))]
public void ExpectClientIdException() public void ExpectClientIdException()
{ {
var t = new UnAuthenticatedUntappdCredentials(string.Empty, "t"); var t = new UnAuthenticatedUntappdCredentials(string.Empty, "t");
} }
[Test]
[ExpectedException(typeof(ArgumentNullException))] [Test]
public void ExpectClientSecretException() [ExpectedException(typeof(ArgumentNullException))]
{ public void ExpectClientSecretException()
var t = new UnAuthenticatedUntappdCredentials("t", string.Empty); {
} var t = new UnAuthenticatedUntappdCredentials("t", string.Empty);
} }
} }
}

View File

@@ -1,29 +1,30 @@
using NUnit.Framework; using NUnit.Framework;
using Untappd.Net.Exception; using Untappd.Net.Exception;
namespace Untappd.Net.UnitTests.Exception namespace Untappd.Net.UnitTests.Exception
{ {
[TestFixture] [TestFixture]
public class TestBaseUntappdException public class TestBaseUntappdException
{ {
[ExpectedException(typeof (BaseUntappdException))] [ExpectedException(typeof(BaseUntappdException))]
[Test] [Test]
public void TestStandardException() public void TestStandardException()
{ {
throw new BaseUntappdException(); throw new BaseUntappdException();
} }
[ExpectedException(typeof(BaseUntappdException), ExpectedMessage = "messageHere")]
[Test]
public void TestStandardExceptionWithMessage()
{
throw new BaseUntappdException("messageHere");
}
[ExpectedException(typeof(BaseUntappdException), ExpectedMessage = "messageHere")]
[Test]
public void TestStandardExceptionWithInner()
{
throw new BaseUntappdException("messageHere", new System.Exception("innerException!"));
}
[ExpectedException(typeof(BaseUntappdException), ExpectedMessage = "messageHere")]
[Test]
public void TestStandardExceptionWithMessage()
{
throw new BaseUntappdException("messageHere");
}
} [ExpectedException(typeof(BaseUntappdException), ExpectedMessage = "messageHere")]
} [Test]
public void TestStandardExceptionWithInner()
{
throw new BaseUntappdException("messageHere", new System.Exception("innerException!"));
}
}
}

View File

@@ -3,15 +3,14 @@ using Untappd.Net.Exception;
namespace Untappd.Net.UnitTests.Exception namespace Untappd.Net.UnitTests.Exception
{ {
[TestFixture] [TestFixture]
public class TestEndpointConfigurationException public class TestEndpointConfigurationException
{ {
[Test] [Test]
[ExpectedException(typeof(EndpointConfigurationException), ExpectedMessage = "Invalid endpoint configured")] [ExpectedException(typeof(EndpointConfigurationException), ExpectedMessage = "Invalid endpoint configured")]
public void TestThrownExeption() public void TestThrownExeption()
{ {
throw new EndpointConfigurationException(); throw new EndpointConfigurationException();
} }
}
} }
}

View File

@@ -1,32 +1,30 @@
using System; using System;
using NUnit.Framework;
using Untappd.Net.Exception;
using Moq; using Moq;
using NUnit.Framework;
using RestSharp; using RestSharp;
using Untappd.Net.Exception;
namespace Untappd.Net.UnitTests.Exception namespace Untappd.Net.UnitTests.Exception
{ {
[TestFixture] [TestFixture]
public class TestHttpErrorException public class TestHttpErrorException
{ {
[Test] [Test]
public void ConfirmNullExceptions() public void ConfirmNullExceptions()
{ {
var mockRequest = new Mock<IRestRequest>(); var mockRequest = new Mock<IRestRequest>();
var mockResponse = new Mock<IRestResponse>(); var mockResponse = new Mock<IRestResponse>();
Assert.Throws<ArgumentNullException>(()=>{
var t = new HttpErrorException(mockRequest.Object, null);
Console.WriteLine(t);
});
Assert.Throws<ArgumentNullException>(()=>{
var t = new HttpErrorException(null, mockResponse.Object);
Console.WriteLine(t);
});
}
}
}
Assert.Throws<ArgumentNullException>(() =>
{
var t = new HttpErrorException(mockRequest.Object, null);
Console.WriteLine(t);
});
Assert.Throws<ArgumentNullException>(() =>
{
var t = new HttpErrorException(null, mockResponse.Object);
Console.WriteLine(t);
});
}
}
}

View File

@@ -1,7 +1,7 @@
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Untappd.Net.UnitTests")] [assembly: AssemblyTitle("Untappd.Net.UnitTests")]
@@ -13,8 +13,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
@@ -24,12 +24,12 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -6,102 +6,103 @@ using Moq;
using NUnit.Framework; using NUnit.Framework;
using RestSharp; using RestSharp;
using Untappd.Net.Authentication; using Untappd.Net.Authentication;
using Untappd.Net.Exception;
using Untappd.Net.Request; using Untappd.Net.Request;
using Untappd.Net.Responses.Actions; using Untappd.Net.Responses.Actions;
using Untappd.Net.Responses.BeerInfo; using Untappd.Net.Responses.BeerInfo;
using Untappd.Net.Exception;
namespace Untappd.Net.UnitTests.Request namespace Untappd.Net.UnitTests.Request
{ {
[TestFixture] [TestFixture]
public class TestRepository public class TestRepository
{ {
[Test] [Test]
public void ConfirmRequestWorks() public void ConfirmRequestWorks()
{ {
var mockCreds = new Mock<IUnAuthenticatedUntappdCredentials>(); var mockCreds = new Mock<IUnAuthenticatedUntappdCredentials>();
mockCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>() mockCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()
{ {
{"client_id", "id"}, {"client_id", "id"},
{"client_secret", "secret"} {"client_secret", "secret"}
})); }));
var bodyParam = new Dictionary<string, object> {{"key", "value"}}; var bodyParam = new Dictionary<string, object> { { "key", "value" } };
var client = new Mock<IRestClient>(); var client = new Mock<IRestClient>();
var request = new Mock<IRestRequest>(); var request = new Mock<IRestRequest>();
request.Setup(a => a.AddParameter(It.IsAny<string>(), It.IsAny<string>())); request.Setup(a => a.AddParameter(It.IsAny<string>(), It.IsAny<string>()));
request.Setup(a => a.AddParameter(It.IsAny<string>(), It.IsAny<string>())); request.Setup(a => a.AddParameter(It.IsAny<string>(), It.IsAny<string>()));
var response = new Mock<IRestResponse>();
response.Setup(a => a.Content).Returns(File.ReadAllText("../../Responses/Json/BeerInfo.json"));
client.Setup(a => a.Execute(It.IsAny<IRestRequest>())).Callback(() =>
{
}).Returns(response.Object);
client.Setup(a => a.ExecuteTaskAsync(It.IsAny<IRestRequest>())).Callback(() =>
{
}).Returns(Task.Run(()=> response.Object));
var repository = new Repository(client.Object, request.Object);
repository.Get<BeerInfo>(mockCreds.Object, "awesome", bodyParam);
request.Verify(a => a.AddParameter("client_id", mockCreds.Object.AuthenticationData["client_id"]));
request.Verify(a => a.AddParameter("client_secret", mockCreds.Object.AuthenticationData["client_secret"]));
request.Verify(a => a.AddParameter("key", "value"));
repository.GetAsync<BeerInfo>(mockCreds.Object, "awesome", bodyParam).Wait();
request.Verify(a => a.AddParameter("client_id", mockCreds.Object.AuthenticationData["client_id"]));
request.Verify(a => a.AddParameter("client_secret", mockCreds.Object.AuthenticationData["client_secret"]));
request.Verify(a => a.AddParameter("key", "value"));
var mockAuthCreds = new Mock<IAuthenticatedUntappdCredentials>(); var response = new Mock<IRestResponse>();
mockAuthCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>() response.Setup(a => a.Content).Returns(File.ReadAllText("../../Responses/Json/BeerInfo.json"));
{ client.Setup(a => a.Execute(It.IsAny<IRestRequest>())).Callback(() =>
{"access_token", "accessToken"} {
})); }).Returns(response.Object);
client.Setup(a => a.ExecuteTaskAsync(It.IsAny<IRestRequest>())).Callback(() =>
{
}).Returns(Task.Run(() => response.Object));
var repository = new Repository(client.Object, request.Object);
repository.Get<BeerInfo>(mockAuthCreds.Object, "awesome", bodyParam); repository.Get<BeerInfo>(mockCreds.Object, "awesome", bodyParam);
request.Verify(a => a.AddParameter("key", "value")); request.Verify(a => a.AddParameter("client_id", mockCreds.Object.AuthenticationData["client_id"]));
request.Verify(a => a.AddParameter("access_token", "accessToken")); request.Verify(a => a.AddParameter("client_secret", mockCreds.Object.AuthenticationData["client_secret"]));
repository.GetAsync<BeerInfo>(mockAuthCreds.Object, "awesome", bodyParam).Wait(); request.Verify(a => a.AddParameter("key", "value"));
request.Verify(a => a.AddParameter("key", "value")); repository.GetAsync<BeerInfo>(mockCreds.Object, "awesome", bodyParam).Wait();
request.Verify(a => a.AddParameter("access_token", "accessToken")); request.Verify(a => a.AddParameter("client_id", mockCreds.Object.AuthenticationData["client_id"]));
request.Verify(a => a.AddParameter("client_secret", mockCreds.Object.AuthenticationData["client_secret"]));
request.Verify(a => a.AddParameter("key", "value"));
mockAuthCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>() var mockAuthCreds = new Mock<IAuthenticatedUntappdCredentials>();
{ mockAuthCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()
{"access_token", "PostaccessToken"} {
})); {"access_token", "accessToken"}
var checkin = new CheckIn("-5", "EST", 1044097) { Shout = "Awesome Brew", Rating = 4 }; }));
repository.FailFast = true;
repository.OnExceptionThrown += (sender, e) =>
{
Assert.IsNotNull(sender);
Assert.IsNotNull(e);
};
Assert.Throws<HttpErrorException>(()=>repository.Post(mockAuthCreds.Object, checkin));
repository.FailFast = false;
repository.Post(mockAuthCreds.Object, checkin);
request.Verify(a => a.AddParameter("access_token", "PostaccessToken"));
mockAuthCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>() repository.Get<BeerInfo>(mockAuthCreds.Object, "awesome", bodyParam);
{ request.Verify(a => a.AddParameter("key", "value"));
{"access_token", "PostAsyncaccessToken"} request.Verify(a => a.AddParameter("access_token", "accessToken"));
})); repository.GetAsync<BeerInfo>(mockAuthCreds.Object, "awesome", bodyParam).Wait();
repository.PostAsync(mockAuthCreds.Object, checkin).Wait(); request.Verify(a => a.AddParameter("key", "value"));
request.Verify(a => a.AddParameter("access_token", "PostAsyncaccessToken")); request.Verify(a => a.AddParameter("access_token", "accessToken"));
}
[Test] mockAuthCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()
public void ConfirmBasicConstructorWorks() {
{ {"access_token", "PostaccessToken"}
var constructorTest = new Repository(); }));
Assert.IsTrue(constructorTest.Client != null); var checkin = new CheckIn("-5", "EST", 1044097) { Shout = "Awesome Brew", Rating = 4 };
Assert.IsTrue(constructorTest.Request != null); repository.FailFast = true;
} repository.OnExceptionThrown += (sender, e) =>
[Test] {
public void ConfirmConfigureGetRequestClearsParams() Assert.IsNotNull(sender);
{ Assert.IsNotNull(e);
var constructorTest = new Repository(); };
constructorTest.Request.Parameters.Add(new Parameter {Name = "param"}); Assert.Throws<HttpErrorException>(() => repository.Post(mockAuthCreds.Object, checkin));
Assert.IsTrue(constructorTest.Request.Parameters.Count > 0); repository.FailFast = false;
constructorTest.ConfigureRequest("endpoint"); repository.Post(mockAuthCreds.Object, checkin);
Assert.IsTrue(constructorTest.Request.Parameters.Count == 0); request.Verify(a => a.AddParameter("access_token", "PostaccessToken"));
}
} mockAuthCreds.Setup(a => a.AuthenticationData).Returns(new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()
} {
{"access_token", "PostAsyncaccessToken"}
}));
repository.PostAsync(mockAuthCreds.Object, checkin).Wait();
request.Verify(a => a.AddParameter("access_token", "PostAsyncaccessToken"));
}
[Test]
public void ConfirmBasicConstructorWorks()
{
var constructorTest = new Repository();
Assert.IsTrue(constructorTest.Client != null);
Assert.IsTrue(constructorTest.Request != null);
}
[Test]
public void ConfirmConfigureGetRequestClearsParams()
{
var constructorTest = new Repository();
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);
}
}
}

View File

@@ -4,58 +4,54 @@ using Untappd.Net.Responses.Actions;
namespace Untappd.Net.UnitTests.Responses.Actions namespace Untappd.Net.UnitTests.Responses.Actions
{ {
[TestFixture] [TestFixture]
public class TestCheckInAction public class TestCheckInAction
{ {
[Test] [Test]
public void TestAccessors() public void TestAccessors()
{ {
Assert.Throws<ArgumentNullException>(() => { new CheckIn(string.Empty, "timezone", 1); }); Assert.Throws<ArgumentNullException>(() => { new CheckIn(string.Empty, "timezone", 1); });
Assert.Throws<ArgumentNullException>(() => { new CheckIn("1", string.Empty, 1); }); Assert.Throws<ArgumentNullException>(() => { new CheckIn("1", string.Empty, 1); });
var checkin = new CheckIn("offset", "timezone", 1); var checkin = new CheckIn("offset", "timezone", 1);
Assert.IsNotNullOrEmpty(checkin.RequestMethod.ToString()); Assert.IsNotNullOrEmpty(checkin.RequestMethod.ToString());
Assert.Throws<ArgumentOutOfRangeException>(() => { checkin.Rating = -1; }); Assert.Throws<ArgumentOutOfRangeException>(() => { checkin.Rating = -1; });
Assert.Throws<ArgumentOutOfRangeException>(() => { checkin.Rating = 6; }); Assert.Throws<ArgumentOutOfRangeException>(() => { checkin.Rating = 6; });
Assert.Throws<ArgumentOutOfRangeException>(() => { checkin.Shout = new String('d', 141); }); Assert.Throws<ArgumentOutOfRangeException>(() => { checkin.Shout = new String('d', 141); });
checkin.Rating = 3; checkin.Rating = 3;
Assert.AreEqual(3, checkin.Rating); Assert.AreEqual(3, checkin.Rating);
var t = "tst"; var t = "tst";
checkin.Shout = t; checkin.Shout = t;
Assert.IsNotNullOrEmpty(checkin.EndPoint); Assert.IsNotNullOrEmpty(checkin.EndPoint);
Assert.AreEqual(checkin.Shout, t); Assert.AreEqual(checkin.Shout, t);
} }
[Test] [Test]
public void TestDictionaryGeneration() public void TestDictionaryGeneration()
{ {
var checkin = new CheckIn("offset", "timezone", 1); var checkin = new CheckIn("offset", "timezone", 1);
Assert.AreEqual(checkin.BodyParameters["gmt_offset"], "offset"); Assert.AreEqual(checkin.BodyParameters["gmt_offset"], "offset");
Assert.AreEqual(checkin.BodyParameters["timezone"], "timezone"); Assert.AreEqual(checkin.BodyParameters["timezone"], "timezone");
Assert.AreEqual(checkin.BodyParameters["bid"], 1); Assert.AreEqual(checkin.BodyParameters["bid"], 1);
Assert.IsFalse(checkin.BodyParameters.ContainsKey("geolat")); Assert.IsFalse(checkin.BodyParameters.ContainsKey("geolat"));
checkin.Geolat = 4; checkin.Geolat = 4;
Assert.IsTrue(checkin.BodyParameters.ContainsKey("geolat")); Assert.IsTrue(checkin.BodyParameters.ContainsKey("geolat"));
Assert.AreEqual(checkin.BodyParameters["geolat"], 4); Assert.AreEqual(checkin.BodyParameters["geolat"], 4);
Assert.IsFalse(checkin.BodyParameters.ContainsKey("geolng")); Assert.IsFalse(checkin.BodyParameters.ContainsKey("geolng"));
checkin.Geolng = 4; checkin.Geolng = 4;
Assert.IsTrue(checkin.BodyParameters.ContainsKey("geolng")); Assert.IsTrue(checkin.BodyParameters.ContainsKey("geolng"));
Assert.AreEqual(checkin.BodyParameters["geolng"], 4); Assert.AreEqual(checkin.BodyParameters["geolng"], 4);
Assert.IsFalse(checkin.BodyParameters.ContainsKey("shout")); Assert.IsFalse(checkin.BodyParameters.ContainsKey("shout"));
checkin.Shout = "shout"; checkin.Shout = "shout";
Assert.IsTrue(checkin.BodyParameters.ContainsKey("shout")); Assert.IsTrue(checkin.BodyParameters.ContainsKey("shout"));
Assert.AreEqual(checkin.BodyParameters["shout"], "shout"); Assert.AreEqual(checkin.BodyParameters["shout"], "shout");
Assert.IsFalse(checkin.BodyParameters.ContainsKey("rating")); Assert.IsFalse(checkin.BodyParameters.ContainsKey("rating"));
checkin.Rating = 2; checkin.Rating = 2;
Assert.IsTrue(checkin.BodyParameters.ContainsKey("rating")); Assert.IsTrue(checkin.BodyParameters.ContainsKey("rating"));
Assert.AreEqual(checkin.BodyParameters["rating"], 2); Assert.AreEqual(checkin.BodyParameters["rating"], 2);
}
}
}
}
}
}

View File

@@ -4,74 +4,73 @@ using Untappd.Net.Responses.Actions;
namespace Untappd.Net.UnitTests.Responses.Actions namespace Untappd.Net.UnitTests.Responses.Actions
{ {
[TestFixture] [TestFixture]
public class TestSimpleActions public class TestSimpleActions
{ {
[Test] [Test]
public void TestFriends() public void TestFriends()
{ {
var accept = new AcceptFriend("targetid"); var accept = new AcceptFriend("targetid");
Assert.IsNotNullOrEmpty(accept.RequestMethod.ToString()); Assert.IsNotNullOrEmpty(accept.RequestMethod.ToString());
Assert.IsTrue(accept.EndPoint.Contains("targetid")); Assert.IsTrue(accept.EndPoint.Contains("targetid"));
Assert.IsNotNull(accept.BodyParameters); Assert.IsNotNull(accept.BodyParameters);
var add = new AddFriend("targetid"); var add = new AddFriend("targetid");
Assert.IsNotNullOrEmpty(add.RequestMethod.ToString()); Assert.IsNotNullOrEmpty(add.RequestMethod.ToString());
Assert.IsTrue(add.EndPoint.Contains("targetid")); Assert.IsTrue(add.EndPoint.Contains("targetid"));
Assert.IsNotNull(add.BodyParameters); Assert.IsNotNull(add.BodyParameters);
var toast = new ToastUntoast("targetid"); var toast = new ToastUntoast("targetid");
Assert.IsNotNullOrEmpty(toast.RequestMethod.ToString()); Assert.IsNotNullOrEmpty(toast.RequestMethod.ToString());
Assert.IsTrue(toast.EndPoint.Contains("targetid")); Assert.IsTrue(toast.EndPoint.Contains("targetid"));
Assert.IsNotNull(toast.BodyParameters); Assert.IsNotNull(toast.BodyParameters);
var remove = new RemoveFriend("targetid"); var remove = new RemoveFriend("targetid");
Assert.IsNotNullOrEmpty(remove.RequestMethod.ToString()); Assert.IsNotNullOrEmpty(remove.RequestMethod.ToString());
Assert.IsTrue(remove.EndPoint.Contains("targetid")); Assert.IsTrue(remove.EndPoint.Contains("targetid"));
Assert.IsNotNull(remove.BodyParameters); Assert.IsNotNull(remove.BodyParameters);
var removeWish = new RemoveFromWishList(1); var removeWish = new RemoveFromWishList(1);
Assert.IsNotNullOrEmpty(removeWish.RequestMethod.ToString()); Assert.IsNotNullOrEmpty(removeWish.RequestMethod.ToString());
Assert.IsNotNullOrEmpty(removeWish.EndPoint); Assert.IsNotNullOrEmpty(removeWish.EndPoint);
Assert.AreEqual(removeWish.BodyParameters["bid"], 1); Assert.AreEqual(removeWish.BodyParameters["bid"], 1);
var addWish = new AddToWishList(1);
Assert.IsNotNullOrEmpty(addWish.RequestMethod.ToString());
Assert.IsNotNullOrEmpty(addWish.EndPoint);
Assert.AreEqual(addWish.BodyParameters["bid"], 1);
var addWish = new AddToWishList(1); var comment = new AddComment("checkin", "shout");
Assert.IsNotNullOrEmpty(addWish.RequestMethod.ToString()); Assert.IsNotNullOrEmpty(comment.RequestMethod.ToString());
Assert.IsNotNullOrEmpty(addWish.EndPoint); Assert.IsTrue(comment.EndPoint.Contains("checkin"));
Assert.AreEqual(addWish.BodyParameters["bid"], 1); Assert.AreEqual(comment.BodyParameters["shout"], "shout");
}
var comment = new AddComment("checkin", "shout"); [Test]
Assert.IsNotNullOrEmpty(comment.RequestMethod.ToString()); public void TestPendingFriends()
Assert.IsTrue(comment.EndPoint.Contains("checkin")); {
Assert.AreEqual(comment.BodyParameters["shout"], "shout"); var pending = new PendingFriends();
} Assert.IsNotNullOrEmpty(pending.RequestMethod.ToString());
Assert.IsNotNullOrEmpty(pending.EndPoint);
Assert.IsNotNull(pending.BodyParameters);
Assert.IsFalse(pending.BodyParameters.ContainsKey("limit"));
pending.Limit = 1;
Assert.IsTrue(pending.BodyParameters.ContainsKey("limit"));
Assert.IsFalse(pending.BodyParameters.ContainsKey("offset"));
pending.Offset = 1;
Assert.IsTrue(pending.BodyParameters.ContainsKey("offset"));
}
[Test] [Test]
public void TestPendingFriends() public void TestArgumentNull()
{ {
var pending = new PendingFriends(); Assert.Throws<ArgumentNullException>(() => { new AcceptFriend(string.Empty); });
Assert.IsNotNullOrEmpty(pending.RequestMethod.ToString()); Assert.Throws<ArgumentNullException>(() => { new AddFriend(string.Empty); });
Assert.IsNotNullOrEmpty(pending.EndPoint); Assert.Throws<ArgumentNullException>(() => { new RemoveFriend(string.Empty); });
Assert.IsNotNull(pending.BodyParameters); Assert.Throws<ArgumentNullException>(() => { new ToastUntoast(string.Empty); });
Assert.IsFalse(pending.BodyParameters.ContainsKey("limit")); Assert.Throws<ArgumentNullException>(() => { new AddComment(string.Empty, "ds"); });
pending.Limit = 1; Assert.Throws<ArgumentNullException>(() => { new AddComment("ds", string.Empty); });
Assert.IsTrue(pending.BodyParameters.ContainsKey("limit")); Assert.Throws<ArgumentOutOfRangeException>(() => { new AddComment("ds", new String('d', 141)); });
Assert.IsFalse(pending.BodyParameters.ContainsKey("offset")); }
pending.Offset = 1; }
Assert.IsTrue(pending.BodyParameters.ContainsKey("offset")); }
}
[Test]
public void TestArgumentNull()
{
Assert.Throws<ArgumentNullException>(() => { new AcceptFriend(string.Empty); });
Assert.Throws<ArgumentNullException>(() => { new AddFriend(string.Empty); });
Assert.Throws<ArgumentNullException>(() => { new RemoveFriend(string.Empty); });
Assert.Throws<ArgumentNullException>(() => { new ToastUntoast(string.Empty); });
Assert.Throws<ArgumentNullException>(() => { new AddComment(string.Empty, "ds"); });
Assert.Throws<ArgumentNullException>(() => { new AddComment("ds", string.Empty); });
Assert.Throws<ArgumentOutOfRangeException>(() => { new AddComment("ds", new String('d', 141)); });
}
}
}

View File

@@ -20,121 +20,121 @@ using UserWishList = Untappd.Net.Responses.UserWishlist;
namespace Untappd.Net.UnitTests.Responses namespace Untappd.Net.UnitTests.Responses
{ {
[TestFixture] [TestFixture]
public class TestDeserializer public class TestDeserializer
{ {
private static string ResponsePath = "../../Responses/Json/{0}"; private static string ResponsePath = "../../Responses/Json/{0}";
[Test] [Test]
[Ignore] [Ignore]
public void GetActualJsonRequest() public void GetActualJsonRequest()
{ {
var credentials = new AuthenticatedUntappdCredentials(""); var credentials = new AuthenticatedUntappdCredentials("");
Dictionary<string, object> parameters = new Dictionary<string, object>(); Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("q", "wild rose"); parameters.Add("q", "wild rose");
var repo = new Repository(); var repo = new Repository();
//var resp = repo.Get<ActivityFeed.ActivityFeed>(credentials); //var resp = repo.Get<ActivityFeed.ActivityFeed>(credentials);
var resp3 = repo.Get<BrewerySearch>(credentials, "", parameters); var resp3 = repo.Get<BrewerySearch>(credentials, "", parameters);
var resp2 = repo.Get<UserActivityFeed>(credentials); var resp2 = repo.Get<UserActivityFeed>(credentials);
} }
[Test] [Test]
public void TestJsonDeserializeUserBadges() public void TestJsonDeserializeUserBadges()
{ {
var json = File.ReadAllText(string.Format(ResponsePath, "UserBadges.json")); var json = File.ReadAllText(string.Format(ResponsePath, "UserBadges.json"));
var jsonresult = JsonConvert.DeserializeObject<UserBadges>(json); var jsonresult = JsonConvert.DeserializeObject<UserBadges>(json);
} }
[Test] [Test]
public void TestJsonDeserializerBeerInfo() public void TestJsonDeserializerBeerInfo()
{ {
var json = File.ReadAllText(string.Format(ResponsePath, "BeerInfo.json")); var json = File.ReadAllText(string.Format(ResponsePath, "BeerInfo.json"));
var jsonresult = JsonConvert.DeserializeObject<BeerInfo>(json); var jsonresult = JsonConvert.DeserializeObject<BeerInfo>(json);
} }
[Test] [Test]
public void TestJsonDeserializerBeerSearch() public void TestJsonDeserializerBeerSearch()
{ {
var json = File.ReadAllText(string.Format(ResponsePath, "BeerSearch.json")); var json = File.ReadAllText(string.Format(ResponsePath, "BeerSearch.json"));
var jsonresult = JsonConvert.DeserializeObject<BeerSearch>(json); var jsonresult = JsonConvert.DeserializeObject<BeerSearch>(json);
} }
[Test] [Test]
public void TestJsonDeserializerBreweryInfo() public void TestJsonDeserializerBreweryInfo()
{ {
var json = File.ReadAllText(string.Format(ResponsePath, "BreweryInfo.json")); var json = File.ReadAllText(string.Format(ResponsePath, "BreweryInfo.json"));
var jsonresult = JsonConvert.DeserializeObject<BreweryInfo>(json); var jsonresult = JsonConvert.DeserializeObject<BreweryInfo>(json);
} }
[Test] [Test]
public void TestJsonDeserializerBrewerySearch() public void TestJsonDeserializerBrewerySearch()
{ {
var json = File.ReadAllText(string.Format(ResponsePath, "BrewerySearch.json")); var json = File.ReadAllText(string.Format(ResponsePath, "BrewerySearch.json"));
var jsonresult = JsonConvert.DeserializeObject<BrewerySearch>(json); var jsonresult = JsonConvert.DeserializeObject<BrewerySearch>(json);
} }
[Test] [Test]
public void TestJsonDeserializerUserDistinctBeers() public void TestJsonDeserializerUserDistinctBeers()
{ {
var json = File.ReadAllText(string.Format(ResponsePath, "UserDistinctBeers.json")); var json = File.ReadAllText(string.Format(ResponsePath, "UserDistinctBeers.json"));
var jsonresult = JsonConvert.DeserializeObject<UserDistinctBeers.UserDistinctBeers>(json); var jsonresult = JsonConvert.DeserializeObject<UserDistinctBeers.UserDistinctBeers>(json);
} }
[Test] [Test]
public void TestJsonDeserializerUserFriends() public void TestJsonDeserializerUserFriends()
{ {
var json = File.ReadAllText(string.Format(ResponsePath, "UserFriends.json")); var json = File.ReadAllText(string.Format(ResponsePath, "UserFriends.json"));
var jsonresult = JsonConvert.DeserializeObject<UserFriends>(json); var jsonresult = JsonConvert.DeserializeObject<UserFriends>(json);
} }
[Test] [Test]
public void TestJsonDeserializerUserInfo() public void TestJsonDeserializerUserInfo()
{ {
var json = File.ReadAllText(string.Format(ResponsePath, "UserInfo.json")); var json = File.ReadAllText(string.Format(ResponsePath, "UserInfo.json"));
var jsonresult = JsonConvert.DeserializeObject<UserInfo>(json); var jsonresult = JsonConvert.DeserializeObject<UserInfo>(json);
} }
[Test] [Test]
public void TestJsonDeserializerUserWishList() public void TestJsonDeserializerUserWishList()
{ {
var json = File.ReadAllText(string.Format(ResponsePath, "UserWishList.json")); var json = File.ReadAllText(string.Format(ResponsePath, "UserWishList.json"));
var jsonresult = JsonConvert.DeserializeObject<UserWishList.UserWishList>(json); var jsonresult = JsonConvert.DeserializeObject<UserWishList.UserWishList>(json);
} }
[Test] [Test]
public void TestJsonDeserializerVenueInfo() public void TestJsonDeserializerVenueInfo()
{ {
var json = File.ReadAllText(string.Format(ResponsePath, "VenueInfo.json")); var json = File.ReadAllText(string.Format(ResponsePath, "VenueInfo.json"));
var jsonresult = JsonConvert.DeserializeObject<VenueInfo>(json); var jsonresult = JsonConvert.DeserializeObject<VenueInfo>(json);
} }
[Test] [Test]
public void TestJsonDeserializerActivityFeed() public void TestJsonDeserializerActivityFeed()
{ {
var json = File.ReadAllText(string.Format(ResponsePath, "ActivityFeed.json")); var json = File.ReadAllText(string.Format(ResponsePath, "ActivityFeed.json"));
var jsonresult = JsonConvert.DeserializeObject<ActivityFeed>(json); var jsonresult = JsonConvert.DeserializeObject<ActivityFeed>(json);
} }
[Test] [Test]
public void TestJsonDeserializerUserActivityFeed() public void TestJsonDeserializerUserActivityFeed()
{ {
var json = File.ReadAllText(string.Format(ResponsePath, "UserActivityFeed.json")); var json = File.ReadAllText(string.Format(ResponsePath, "UserActivityFeed.json"));
var jsonresult = JsonConvert.DeserializeObject<UserActivityFeed>(json); var jsonresult = JsonConvert.DeserializeObject<UserActivityFeed>(json);
} }
[Test] [Test]
[ExpectedException(typeof(NotImplementedException))] [ExpectedException(typeof(NotImplementedException))]
public void testNotImplementedException() public void testNotImplementedException()
{ {
new SingleObjectArrayConverter<UserActivityFeed>().WriteJson(null, null, null); new SingleObjectArrayConverter<UserActivityFeed>().WriteJson(null, null, null);
} }
[Test] [Test]
public void testTypeValid() public void testTypeValid()
{ {
Assert.IsTrue(new SingleObjectArrayConverter<UserActivityFeed>().CanConvert(typeof(UserActivityFeed))); Assert.IsTrue(new SingleObjectArrayConverter<UserActivityFeed>().CanConvert(typeof(UserActivityFeed)));
} }
} }
} }

View File

@@ -6,33 +6,31 @@ using Untappd.Net.Request;
namespace Untappd.Net.UnitTests.Responses namespace Untappd.Net.UnitTests.Responses
{ {
[TestFixture] [TestFixture]
public class TestResponseEndpoints public class TestResponseEndpoints
{ {
/// <summary>
/// Run through all the endpoints to make sure they all atleast do not error out.
/// This is so we can get a high code coverage, while also covering new types that get added.
/// </summary>
[Test]
public void RunAllEndpoints()
{
var objects = Assembly.GetAssembly(typeof(IRequest)).GetTypes().Where(myType =>
myType.IsClass
&& !myType.IsAbstract
&& myType.GetInterface("IRequest") != null).Select(type => (IRequest)Activator.CreateInstance(type)).ToList();
objects.ForEach(a => Assert.IsNotNullOrEmpty(a.EndPoint("t")));
}
/// <summary> [Test]
/// Run through all the endpoints to make sure they all atleast do not error out. public void RunAllEndpointsWithEmptyString()
/// This is so we can get a high code coverage, while also covering new types that get added. {
/// </summary> var objects = Assembly.GetAssembly(typeof(IRequest)).GetTypes().Where(myType =>
[Test] myType.IsClass
public void RunAllEndpoints() && !myType.IsAbstract
{ && myType.GetInterface("IRequest") != null).Select(type => (IRequest)Activator.CreateInstance(type)).ToList();
objects.ForEach(a => Assert.IsNotNullOrEmpty(a.EndPoint(string.Empty)));
var objects = Assembly.GetAssembly(typeof (IRequest)).GetTypes().Where(myType => }
myType.IsClass }
&& !myType.IsAbstract }
&& myType.GetInterface("IRequest") != null).Select(type => (IRequest) Activator.CreateInstance(type)).ToList();
objects.ForEach(a=>Assert.IsNotNullOrEmpty(a.EndPoint("t")));
}
[Test]
public void RunAllEndpointsWithEmptyString()
{
var objects = Assembly.GetAssembly(typeof (IRequest)).GetTypes().Where(myType =>
myType.IsClass
&& !myType.IsAbstract
&& myType.GetInterface("IRequest") != null).Select(type => (IRequest) Activator.CreateInstance(type)).ToList();
objects.ForEach(a=>Assert.IsNotNullOrEmpty(a.EndPoint(string.Empty)));
}
}
}

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Moq" version="4.2.1502.0911" targetFramework="net45" /> <package id="Moq" version="4.2.1502.0911" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" /> <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="NUnit" version="2.6.4" targetFramework="net45" /> <package id="NUnit" version="2.6.4" targetFramework="net45" />
<package id="NUnitTestAdapter" version="1.2" targetFramework="net45" /> <package id="NUnitTestAdapter" version="1.2" targetFramework="net45" />
<package id="RestSharp" version="105.0.1" targetFramework="net45" /> <package id="RestSharp" version="105.0.1" targetFramework="net45" />
</packages> </packages>

View File

@@ -4,22 +4,22 @@ using System.Collections.ObjectModel;
namespace Untappd.Net.Authentication namespace Untappd.Net.Authentication
{ {
public sealed class AuthenticatedUntappdCredentials : UntappdCredentials, IAuthenticatedUntappdCredentials public sealed class AuthenticatedUntappdCredentials : UntappdCredentials, IAuthenticatedUntappdCredentials
{ {
/// <summary> /// <summary>
/// Pass your authenticated access token /// Pass your authenticated access token
/// </summary> /// </summary>
/// <param name="accessToken"></param> /// <param name="accessToken"></param>
public AuthenticatedUntappdCredentials(string accessToken) public AuthenticatedUntappdCredentials(string accessToken)
{ {
if (string.IsNullOrWhiteSpace(accessToken)) if (string.IsNullOrWhiteSpace(accessToken))
{ {
throw new ArgumentNullException("accessToken"); throw new ArgumentNullException("accessToken");
} }
AuthenticationData = new ReadOnlyDictionary<string, string>(new Dictionary<string, string>() AuthenticationData = new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()
{ {
{"access_token", accessToken} {"access_token", accessToken}
}); });
} }
} }
} }

View File

@@ -1,6 +1,6 @@
namespace Untappd.Net.Authentication namespace Untappd.Net.Authentication
{ {
public interface IAuthenticatedUntappdCredentials : IUntappdCredentials public interface IAuthenticatedUntappdCredentials : IUntappdCredentials
{ {
} }
} }

View File

@@ -1,7 +1,6 @@
namespace Untappd.Net.Authentication
namespace Untappd.Net.Authentication
{ {
public interface IUnAuthenticatedUntappdCredentials : IUntappdCredentials public interface IUnAuthenticatedUntappdCredentials : IUntappdCredentials
{ {
} }
} }

View File

@@ -2,8 +2,8 @@
namespace Untappd.Net.Authentication namespace Untappd.Net.Authentication
{ {
public interface IUntappdCredentials public interface IUntappdCredentials
{ {
IReadOnlyDictionary<string, string> AuthenticationData { get; } IReadOnlyDictionary<string, string> AuthenticationData { get; }
} }
} }

View File

@@ -4,27 +4,27 @@ using System.Collections.ObjectModel;
namespace Untappd.Net.Authentication namespace Untappd.Net.Authentication
{ {
public sealed class UnAuthenticatedUntappdCredentials : UntappdCredentials, IUnAuthenticatedUntappdCredentials public sealed class UnAuthenticatedUntappdCredentials : UntappdCredentials, IUnAuthenticatedUntappdCredentials
{ {
/// <summary> /// <summary>
/// UnAuthenticated request. Pass your API id and secret /// UnAuthenticated request. Pass your API id and secret
/// </summary> /// </summary>
/// <param name="clientId"></param> /// <param name="clientId"></param>
/// <param name="clientSecret"></param> /// <param name="clientSecret"></param>
public UnAuthenticatedUntappdCredentials(string clientId, string clientSecret) public UnAuthenticatedUntappdCredentials(string clientId, string clientSecret)
{ {
if (string.IsNullOrWhiteSpace(clientId)) if (string.IsNullOrWhiteSpace(clientId))
{ {
throw new ArgumentNullException("clientId"); throw new ArgumentNullException("clientId");
} }
if (string.IsNullOrWhiteSpace(clientSecret)) if (string.IsNullOrWhiteSpace(clientSecret))
{ {
throw new ArgumentNullException("clientSecret"); throw new ArgumentNullException("clientSecret");
} }
AuthenticationData = new ReadOnlyDictionary<string, string>(new Dictionary<string, string>() AuthenticationData = new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()
{ {
{"client_id", clientId}, {"client_secret", clientSecret} {"client_id", clientId}, {"client_secret", clientSecret}
}); });
} }
} }
} }

View File

@@ -2,8 +2,8 @@
namespace Untappd.Net.Authentication namespace Untappd.Net.Authentication
{ {
public abstract class UntappdCredentials : IUntappdCredentials public abstract class UntappdCredentials : IUntappdCredentials
{ {
public IReadOnlyDictionary<string, string> AuthenticationData { get; protected set; } public IReadOnlyDictionary<string, string> AuthenticationData { get; protected set; }
} }
} }

View File

@@ -1,8 +1,8 @@
namespace Untappd.Net namespace Untappd.Net
{ {
public struct Constants public struct Constants
{ {
public const string BaseRequestString = "https://api.untappd.com"; public const string BaseRequestString = "https://api.untappd.com";
public const string OAuthTokenEndPoint = "https://untappd.com/oauth/authorize"; public const string OAuthTokenEndPoint = "https://untappd.com/oauth/authorize";
} }
} }

View File

@@ -2,19 +2,19 @@
namespace Untappd.Net.Exception namespace Untappd.Net.Exception
{ {
[Serializable] [Serializable]
public class BaseUntappdException : System.Exception public class BaseUntappdException : System.Exception
{ {
public BaseUntappdException() public BaseUntappdException()
{ {
} }
public BaseUntappdException(string message) : base(message)
{
}
public BaseUntappdException(string message, System.Exception inner) : base(message, inner) public BaseUntappdException(string message) : base(message)
{ {
} }
}
} public BaseUntappdException(string message, System.Exception inner) : base(message, inner)
{
}
}
}

View File

@@ -2,17 +2,16 @@
namespace Untappd.Net.Exception namespace Untappd.Net.Exception
{ {
[Serializable] [Serializable]
public sealed class EndpointConfigurationException : BaseUntappdException public sealed class EndpointConfigurationException : BaseUntappdException
{ {
/// <summary> /// <summary>
/// Called when a class has an empty endpoint /// Called when a class has an empty endpoint
/// </summary> /// </summary>
/// <param name="type"></param> /// <param name="type"></param>
public EndpointConfigurationException() public EndpointConfigurationException()
:base("Invalid endpoint configured") : base("Invalid endpoint configured")
{ {
}
} }
} }
}

View File

@@ -4,39 +4,40 @@ using RestSharp;
namespace Untappd.Net.Exception namespace Untappd.Net.Exception
{ {
[Serializable] [Serializable]
public sealed class HttpErrorException : BaseUntappdException public sealed class HttpErrorException : BaseUntappdException
{ {
public override string Message public override string Message
{ {
get get
{ {
return _message; return _message;
} }
} }
private readonly string _message; private readonly string _message;
public HttpErrorException(IRestRequest request, IRestResponse response)
{
if(request == null)
{
throw new ArgumentNullException("request");
}
if (response == null)
{
throw new ArgumentNullException("response");
}
var code = (int) response.StatusCode;
if (code == 200)
{
throw new BaseUntappdException(
"HttpError is being throw with a 200 error. Something has gone horribly wrong");
}
_message = string.Format("HttpError {0} was returned with Message: {1}{2}", code, Environment.NewLine, public HttpErrorException(IRestRequest request, IRestResponse response)
response.ErrorMessage); {
Data.Add("Request Object", JsonConvert.SerializeObject(request)); if (request == null)
Data.Add("Response Object", JsonConvert.SerializeObject(response)); {
} throw new ArgumentNullException("request");
} }
} if (response == null)
{
throw new ArgumentNullException("response");
}
var code = (int)response.StatusCode;
if (code == 200)
{
throw new BaseUntappdException(
"HttpError is being throw with a 200 error. Something has gone horribly wrong");
}
_message = string.Format("HttpError {0} was returned with Message: {1}{2}", code, Environment.NewLine,
response.ErrorMessage);
Data.Add("Request Object", JsonConvert.SerializeObject(request));
Data.Add("Response Object", JsonConvert.SerializeObject(response));
}
}
}

View File

@@ -3,58 +3,58 @@ using Untappd.Net.Authentication;
namespace Untappd.Net.OAuth namespace Untappd.Net.OAuth
{ {
public static class AuthenticationHelper public static class AuthenticationHelper
{ {
/// <summary> /// <summary>
/// Redirect the user to this string. /// Redirect the user to this string.
/// </summary> /// </summary>
/// <param name="credentials"></param> /// <param name="credentials"></param>
/// <param name="redirectUrl">The URL to redirect back to your application. Should listen on code as a string param</param> /// <param name="redirectUrl">The URL to redirect back to your application. Should listen on code as a string param</param>
/// <returns></returns> /// <returns></returns>
public static string RedirectUserTo(IUnAuthenticatedUntappdCredentials credentials, string redirectUrl) public static string RedirectUserTo(IUnAuthenticatedUntappdCredentials credentials, string redirectUrl)
{ {
if (credentials == null) if (credentials == null)
{ {
throw new ArgumentNullException("credentials"); throw new ArgumentNullException("credentials");
} }
if (string.IsNullOrWhiteSpace(redirectUrl)) if (string.IsNullOrWhiteSpace(redirectUrl))
{ {
throw new ArgumentNullException("redirectUrl"); throw new ArgumentNullException("redirectUrl");
} }
return string.Format("{0}/?client_id={1}&response_type=code&redirect_url={2}", Constants.BaseRequestString,
credentials.AuthenticationData["client_id"], redirectUrl);
}
/// <summary> return string.Format("{0}/?client_id={1}&response_type=code&redirect_url={2}", Constants.BaseRequestString,
/// Url to get the OAuth token. credentials.AuthenticationData["client_id"], redirectUrl);
/// </summary> }
/// <param name="credentials"></param>
/// <param name="redirectUrl"></param>
/// <param name="code">Data returned by the initial request(see: RedirectUserTo)</param>
/// <returns></returns>
public static string TokenUrl(IUnAuthenticatedUntappdCredentials credentials, string redirectUrl, string code)
{
if (credentials == null)
{
throw new ArgumentNullException("credentials");
}
if (string.IsNullOrWhiteSpace(redirectUrl)) /// <summary>
{ /// Url to get the OAuth token.
throw new ArgumentNullException("redirectUrl"); /// </summary>
} /// <param name="credentials"></param>
if (string.IsNullOrWhiteSpace(code)) /// <param name="redirectUrl"></param>
{ /// <param name="code">Data returned by the initial request(see: RedirectUserTo)</param>
throw new ArgumentNullException("code"); /// <returns></returns>
} public static string TokenUrl(IUnAuthenticatedUntappdCredentials credentials, string redirectUrl, string code)
return string.Format("{0}/?client_id={1}&client_secret={2}&response_type=code&redirect_url={3}&code={4}", {
Constants.OAuthTokenEndPoint, if (credentials == null)
credentials.AuthenticationData["client_id"], {
credentials.AuthenticationData["client_secret"], throw new ArgumentNullException("credentials");
redirectUrl, }
code);
} if (string.IsNullOrWhiteSpace(redirectUrl))
} {
} throw new ArgumentNullException("redirectUrl");
}
if (string.IsNullOrWhiteSpace(code))
{
throw new ArgumentNullException("code");
}
return string.Format("{0}/?client_id={1}&client_secret={2}&response_type=code&redirect_url={3}&code={4}",
Constants.OAuthTokenEndPoint,
credentials.AuthenticationData["client_id"],
credentials.AuthenticationData["client_secret"],
redirectUrl,
code);
}
}
}

View File

@@ -1,12 +1,10 @@
using System.Reflection; // General Information about an assembly is controlled through the following
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
using System; using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Untappd.Net")] [assembly: AssemblyTitle("Untappd.Net")]
[assembly: AssemblyDescription("C# Untappd Wrapper")] [assembly: AssemblyDescription("C# Untappd Wrapper")]
@@ -18,8 +16,8 @@ using System;
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: CLSCompliantAttribute(true)] [assembly: CLSCompliantAttribute(true)]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
@@ -29,14 +27,14 @@ using System;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.2.*")] [assembly: AssemblyVersion("0.2.*")]
//If AssemblyFileVersion is not explicitly set, it takes its value from the AssemblyVersion attribute. //If AssemblyFileVersion is not explicitly set, it takes its value from the AssemblyVersion attribute.
//[assembly: AssemblyFileVersion("0.2.*")] //[assembly: AssemblyFileVersion("0.2.*")]
[assembly: InternalsVisibleTo("Untappd.Net.UnitTests")] [assembly: InternalsVisibleTo("Untappd.Net.UnitTests")]

View File

@@ -2,22 +2,23 @@
namespace Untappd.Net.Request namespace Untappd.Net.Request
{ {
public abstract class BasicRequest public abstract class BasicRequest
{ {
protected abstract string EndPointWithConfiguration { get; } protected abstract string EndPointWithConfiguration { get; }
/// <summary>
/// Pass in the parameter into the request...ie username, brewery, etc. /// <summary>
/// </summary> /// Pass in the parameter into the request...ie username, brewery, etc.
/// <param name="parameter"></param> /// </summary>
/// <returns></returns> /// <param name="parameter"></param>
public string EndPoint(string parameter = "") /// <returns></returns>
{ public string EndPoint(string parameter = "")
if (!String.IsNullOrEmpty(parameter)) {
{ if (!String.IsNullOrEmpty(parameter))
parameter = string.Format("/{0}", parameter); {
return string.Format(EndPointWithConfiguration, parameter); parameter = string.Format("/{0}", parameter);
} return string.Format(EndPointWithConfiguration, parameter);
return string.Format(EndPointWithConfiguration, string.Empty); }
} return string.Format(EndPointWithConfiguration, string.Empty);
} }
} }
}

View File

@@ -3,10 +3,10 @@ using RestSharp;
namespace Untappd.Net.Request namespace Untappd.Net.Request
{ {
public interface IAction public interface IAction
{ {
Method RequestMethod { get; } Method RequestMethod { get; }
string EndPoint { get; } string EndPoint { get; }
IDictionary<string, object> BodyParameters { get; } IDictionary<string, object> BodyParameters { get; }
} }
} }

View File

@@ -1,6 +1,6 @@
namespace Untappd.Net.Request namespace Untappd.Net.Request
{ {
public interface IAuthenticatedRequest : IRequest public interface IAuthenticatedRequest : IRequest
{ {
} }
} }

View File

@@ -1,7 +1,7 @@
namespace Untappd.Net.Request namespace Untappd.Net.Request
{ {
public interface IRequest public interface IRequest
{ {
string EndPoint(string parameter); string EndPoint(string parameter);
} }
} }

View File

@@ -1,6 +1,6 @@
namespace Untappd.Net.Request namespace Untappd.Net.Request
{ {
public interface IUnAuthenticatedRequest : IRequest public interface IUnAuthenticatedRequest : IRequest
{ {
} }
} }

View File

@@ -9,113 +9,114 @@ using Untappd.Net.Exception;
namespace Untappd.Net.Request namespace Untappd.Net.Request
{ {
public sealed partial class Repository public sealed partial class Repository
{ {
internal IRestClient Client; internal IRestClient Client;
internal IRestRequest Request; internal IRestRequest Request;
public bool FailFast { get; set; } public bool FailFast { get; set; }
/// <summary>
/// Event to listen to when failFast is set to false
/// This allows you to capture the excpetion, before its swallowed
/// </summary>
public event UnhandledExceptionEventHandler OnExceptionThrown;
/// <summary> /// <summary>
/// Make a repository /// Event to listen to when failFast is set to false
/// </summary> /// This allows you to capture the excpetion, before its swallowed
/// <param name="failFast">Should we throw exceptions? or just return null</param> /// </summary>
public Repository(bool failFast = true) public event UnhandledExceptionEventHandler OnExceptionThrown;
{
Client = new RestClient(Constants.BaseRequestString);
Request = new RestRequest();
FailFast = failFast;
}
[Obsolete("This constructor is used for mocking purposes only", false)] /// <summary>
internal Repository(IRestClient client, IRestRequest request) /// Make a repository
{ /// </summary>
Client = client; /// <param name="failFast">Should we throw exceptions? or just return null</param>
Request = request; public Repository(bool failFast = true)
} {
Client = new RestClient(Constants.BaseRequestString);
Request = new RestRequest();
FailFast = failFast;
}
internal Repository ConfigureRequest(string endPoint, IDictionary<string, object> bodyParameters = null, Method webMethod = Method.GET) [Obsolete("This constructor is used for mocking purposes only", false)]
{ internal Repository(IRestClient client, IRestRequest request)
Request.Resource = endPoint; {
Request.Method = webMethod; Client = client;
if (Request.Parameters != null && Request.Parameters.Count > 0) Request = request;
{ }
Request.Parameters.Clear();
}
if (bodyParameters == null) return this; internal Repository ConfigureRequest(string endPoint, IDictionary<string, object> bodyParameters = null, Method webMethod = Method.GET)
foreach (var param in bodyParameters) {
{ Request.Resource = endPoint;
Request.AddParameter(param.Key, param.Value); Request.Method = webMethod;
} if (Request.Parameters != null && Request.Parameters.Count > 0)
return this; {
} Request.Parameters.Clear();
}
internal Repository ConfigureRequest(IUntappdCredentials credentials, string endPoint, IDictionary<string, object> bodyParameters = null, Method webMethod = Method.GET) if (bodyParameters == null) return this;
{ foreach (var param in bodyParameters)
ConfigureRequest(endPoint, bodyParameters, webMethod); {
foreach (var untappdCredential in credentials.AuthenticationData) Request.AddParameter(param.Key, param.Value);
{ }
Request.AddParameter(untappdCredential.Key, untappdCredential.Value); return this;
} }
return this;
}
TResult ExecuteRequest<TResult>() internal Repository ConfigureRequest(IUntappdCredentials credentials, string endPoint, IDictionary<string, object> bodyParameters = null, Method webMethod = Method.GET)
where TResult : class {
{ ConfigureRequest(endPoint, bodyParameters, webMethod);
return ProcessExecution<TResult>(Client.Execute(Request)); foreach (var untappdCredential in credentials.AuthenticationData)
} {
Request.AddParameter(untappdCredential.Key, untappdCredential.Value);
}
return this;
}
async Task<TResult> ExecuteRequestAsync<TResult>() private TResult ExecuteRequest<TResult>()
where TResult : class where TResult : class
{ {
return ProcessExecution<TResult>(await Client.ExecuteTaskAsync(Request)); return ProcessExecution<TResult>(Client.Execute(Request));
} }
TResult ProcessExecution<TResult>(IRestResponse response) private async Task<TResult> ExecuteRequestAsync<TResult>()
where TResult : class where TResult : class
{ {
//if the return type is not 200 throw errors return ProcessExecution<TResult>(await Client.ExecuteTaskAsync(Request));
if (response.StatusCode != HttpStatusCode.OK) }
{
var excpetion = new HttpErrorException(Request, response);
var eventThrow = OnExceptionThrown;
if (eventThrow != null) private TResult ProcessExecution<TResult>(IRestResponse response)
{ where TResult : class
eventThrow(this, new UnhandledExceptionEventArgs(excpetion, FailFast)); {
} //if the return type is not 200 throw errors
if (FailFast) if (response.StatusCode != HttpStatusCode.OK)
{ {
throw excpetion; var excpetion = new HttpErrorException(Request, response);
} var eventThrow = OnExceptionThrown;
return null;
}
//try to deserialize
try
{
return JsonConvert.DeserializeObject<TResult>(response.Content);
}
catch(System.Exception e)
{
var eventThrow = OnExceptionThrown;
if (eventThrow != null) if (eventThrow != null)
{ {
eventThrow(this, new UnhandledExceptionEventArgs(e, FailFast)); eventThrow(this, new UnhandledExceptionEventArgs(excpetion, FailFast));
} }
if (FailFast) if (FailFast)
{ {
throw; throw excpetion;
} }
return null;
return null; }
} //try to deserialize
} try
} {
} return JsonConvert.DeserializeObject<TResult>(response.Content);
}
catch (System.Exception e)
{
var eventThrow = OnExceptionThrown;
if (eventThrow != null)
{
eventThrow(this, new UnhandledExceptionEventArgs(e, FailFast));
}
if (FailFast)
{
throw;
}
return null;
}
}
}
}

View File

@@ -1,78 +1,77 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Untappd.Net.Authentication; using Untappd.Net.Authentication;
using Untappd.Net.Exception;
namespace Untappd.Net.Request namespace Untappd.Net.Request
{ {
public sealed partial class Repository public sealed partial class Repository
{ {
/// <summary> /// <summary>
/// Get the things! /// Get the things!
/// </summary> /// </summary>
/// <typeparam name="TResult">What you want to request</typeparam> /// <typeparam name="TResult">What you want to request</typeparam>
/// <param name="credentials">Pass in a credentials object</param> /// <param name="credentials">Pass in a credentials object</param>
/// <param name="urlParameter">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</param> /// <param name="urlParameter">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</param>
/// <param name="bodyParameters">Any additional params you wish to add to the request</param> /// <param name="bodyParameters">Any additional params you wish to add to the request</param>
/// <exception cref="HttpErrorException"></exception> /// <exception cref="HttpErrorException"></exception>
/// <returns></returns> /// <returns></returns>
public TResult Get<TResult>(IUnAuthenticatedUntappdCredentials credentials, string urlParameter, IDictionary<string, object> bodyParameters = null) public TResult Get<TResult>(IUnAuthenticatedUntappdCredentials credentials, string urlParameter, IDictionary<string, object> bodyParameters = null)
where TResult : class, IUnAuthenticatedRequest, new() where TResult : class, IUnAuthenticatedRequest, new()
{ {
var result = new TResult(); var result = new TResult();
return ConfigureRequest(credentials, result.EndPoint(urlParameter), bodyParameters) return ConfigureRequest(credentials, result.EndPoint(urlParameter), bodyParameters)
.ExecuteRequest<TResult>(); .ExecuteRequest<TResult>();
} }
/// <summary> /// <summary>
/// Get the things! Async! /// Get the things! Async!
/// </summary> /// </summary>
/// <typeparam name="TResult"></typeparam> /// <typeparam name="TResult"></typeparam>
/// <param name="credentials"></param> /// <param name="credentials"></param>
/// <param name="urlParameter"></param> /// <param name="urlParameter"></param>
/// <param name="bodyParameters"></param> /// <param name="bodyParameters"></param>
/// <exception cref="HttpErrorException"></exception> /// <exception cref="HttpErrorException"></exception>
/// <returns></returns> /// <returns></returns>
public Task<TResult> GetAsync<TResult>(IUnAuthenticatedUntappdCredentials credentials, string urlParameter, IDictionary<string, object> bodyParameters = null) public Task<TResult> GetAsync<TResult>(IUnAuthenticatedUntappdCredentials credentials, string urlParameter, IDictionary<string, object> bodyParameters = null)
where TResult : class, IUnAuthenticatedRequest, new() where TResult : class, IUnAuthenticatedRequest, new()
{ {
var result = new TResult(); var result = new TResult();
return ConfigureRequest(credentials, result.EndPoint(urlParameter), bodyParameters) return ConfigureRequest(credentials, result.EndPoint(urlParameter), bodyParameters)
.ExecuteRequestAsync<TResult>(); .ExecuteRequestAsync<TResult>();
} }
/// <summary> /// <summary>
/// Get the things! authenticated! /// Get the things! authenticated!
/// </summary> /// </summary>
/// <typeparam name="TResult"></typeparam> /// <typeparam name="TResult"></typeparam>
/// <param name="credentials">Pass in a credentials object</param> /// <param name="credentials">Pass in a credentials object</param>
/// <param name="urlParameter">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</param> /// <param name="urlParameter">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</param>
/// <param name="bodyParameters">Any additional params you wish to add to the request</param> /// <param name="bodyParameters">Any additional params you wish to add to the request</param>
/// <exception cref="HttpErrorException"></exception> /// <exception cref="HttpErrorException"></exception>
/// <returns></returns> /// <returns></returns>
public TResult Get<TResult>(IAuthenticatedUntappdCredentials credentials, string urlParameter = "", IDictionary<string, object> bodyParameters = null) public TResult Get<TResult>(IAuthenticatedUntappdCredentials credentials, string urlParameter = "", IDictionary<string, object> bodyParameters = null)
where TResult : class,IAuthenticatedRequest, new() where TResult : class, IAuthenticatedRequest, new()
{ {
var result = new TResult(); var result = new TResult();
return ConfigureRequest(credentials, result.EndPoint(urlParameter), bodyParameters) return ConfigureRequest(credentials, result.EndPoint(urlParameter), bodyParameters)
.ExecuteRequest<TResult>(); .ExecuteRequest<TResult>();
} }
/// <summary> /// <summary>
/// Get the things Authenticated! Async!! /// Get the things Authenticated! Async!!
/// </summary> /// </summary>
/// <typeparam name="TResult"></typeparam> /// <typeparam name="TResult"></typeparam>
/// <param name="credentials"></param> /// <param name="credentials"></param>
/// <param name="urlParameter"></param> /// <param name="urlParameter"></param>
/// <param name="bodyParameters"></param> /// <param name="bodyParameters"></param>
/// <exception cref="HttpErrorException"></exception> /// <exception cref="HttpErrorException"></exception>
/// <returns></returns> /// <returns></returns>
public Task<TResult> GetAsync<TResult>(IAuthenticatedUntappdCredentials credentials, string urlParameter = "", IDictionary<string, object> bodyParameters = null) public Task<TResult> GetAsync<TResult>(IAuthenticatedUntappdCredentials credentials, string urlParameter = "", IDictionary<string, object> bodyParameters = null)
where TResult : class,IAuthenticatedRequest, new() where TResult : class, IAuthenticatedRequest, new()
{ {
var result = new TResult(); var result = new TResult();
return ConfigureRequest(credentials, result.EndPoint(urlParameter), bodyParameters) return ConfigureRequest(credentials, result.EndPoint(urlParameter), bodyParameters)
.ExecuteRequestAsync<TResult>(); .ExecuteRequestAsync<TResult>();
} }
} }
} }

View File

@@ -1,51 +1,51 @@
using System.Threading.Tasks; using System;
using System.Threading.Tasks;
using Untappd.Net.Authentication; using Untappd.Net.Authentication;
using System;
namespace Untappd.Net.Request namespace Untappd.Net.Request
{ {
public sealed partial class Repository public sealed partial class Repository
{ {
/// <summary> /// <summary>
/// do a post with actions /// do a post with actions
/// </summary> /// </summary>
/// <param name="credentials"></param> /// <param name="credentials"></param>
/// <param name="action"></param> /// <param name="action"></param>
/// <returns>returns dynamic since often the return doesn't matter</returns> /// <returns>returns dynamic since often the return doesn't matter</returns>
public dynamic Post(IAuthenticatedUntappdCredentials credentials, IAction action) public dynamic Post(IAuthenticatedUntappdCredentials credentials, IAction action)
{ {
if (credentials == null) if (credentials == null)
{ {
throw new ArgumentNullException("credentials"); throw new ArgumentNullException("credentials");
} }
if (action == null) if (action == null)
{ {
throw new ArgumentNullException("action"); throw new ArgumentNullException("action");
} }
return ConfigureRequest(credentials, action.EndPoint, action.BodyParameters, action.RequestMethod) return ConfigureRequest(credentials, action.EndPoint, action.BodyParameters, action.RequestMethod)
.ExecuteRequest<dynamic>(); .ExecuteRequest<dynamic>();
} }
/// <summary> /// <summary>
/// do a post with actions, Async! /// do a post with actions, Async!
/// </summary> /// </summary>
/// <param name="credentials"></param> /// <param name="credentials"></param>
/// <param name="action"></param> /// <param name="action"></param>
/// <returns>returns dynamic since often the return doesn't matter</returns> /// <returns>returns dynamic since often the return doesn't matter</returns>
public Task<dynamic> PostAsync(IAuthenticatedUntappdCredentials credentials, IAction action) public Task<dynamic> PostAsync(IAuthenticatedUntappdCredentials credentials, IAction action)
{ {
if (credentials == null) if (credentials == null)
{ {
throw new ArgumentNullException("credentials"); throw new ArgumentNullException("credentials");
} }
if (action == null) if (action == null)
{ {
throw new ArgumentNullException("action"); throw new ArgumentNullException("action");
} }
return ConfigureRequest(credentials, action.EndPoint, action.BodyParameters, action.RequestMethod) return ConfigureRequest(credentials, action.EndPoint, action.BodyParameters, action.RequestMethod)
.ExecuteRequestAsync<dynamic>(); .ExecuteRequestAsync<dynamic>();
} }
} }
} }

View File

@@ -5,18 +5,19 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.Actions namespace Untappd.Net.Responses.Actions
{ {
public class AcceptFriend : IAction public class AcceptFriend : IAction
{ {
public Method RequestMethod { get { return Method.GET; } } public Method RequestMethod { get { return Method.GET; } }
public string EndPoint { get; private set; } public string EndPoint { get; private set; }
public IDictionary<string, object> BodyParameters { get { return new Dictionary<string, object>(); } } public IDictionary<string, object> BodyParameters { get { return new Dictionary<string, object>(); } }
public AcceptFriend(string target_id)
{ public AcceptFriend(string target_id)
if (string.IsNullOrWhiteSpace(target_id)) {
{ if (string.IsNullOrWhiteSpace(target_id))
throw new ArgumentNullException("target_id"); {
} throw new ArgumentNullException("target_id");
EndPoint = string.Format("v4/friend/accept/{0}", target_id); }
} EndPoint = string.Format("v4/friend/accept/{0}", target_id);
} }
} }
}

View File

@@ -5,28 +5,28 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.Actions namespace Untappd.Net.Responses.Actions
{ {
public class AddComment : IAction public class AddComment : IAction
{ {
public Method RequestMethod { get {return Method.POST;} } public Method RequestMethod { get { return Method.POST; } }
public string EndPoint { get; private set; } public string EndPoint { get; private set; }
public IDictionary<string, object> BodyParameters { get; private set; } public IDictionary<string, object> BodyParameters { get; private set; }
public AddComment(string checkinId, string shout)
{
if (string.IsNullOrWhiteSpace(checkinId))
{
throw new ArgumentNullException("checkinId");
}
if (string.IsNullOrWhiteSpace(shout))
{
throw new ArgumentNullException("shout");
}
if (shout.Length > 140)
{
throw new ArgumentOutOfRangeException("shout", shout, "Shout cannot be more than 140 characters");
}
EndPoint = string.Format("v4/checkin/addcomment/{0}", checkinId);
BodyParameters = new Dictionary<string, object> {{shout, shout}};
} public AddComment(string checkinId, string shout)
} {
} if (string.IsNullOrWhiteSpace(checkinId))
{
throw new ArgumentNullException("checkinId");
}
if (string.IsNullOrWhiteSpace(shout))
{
throw new ArgumentNullException("shout");
}
if (shout.Length > 140)
{
throw new ArgumentOutOfRangeException("shout", shout, "Shout cannot be more than 140 characters");
}
EndPoint = string.Format("v4/checkin/addcomment/{0}", checkinId);
BodyParameters = new Dictionary<string, object> { { shout, shout } };
}
}
}

View File

@@ -5,18 +5,19 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.Actions namespace Untappd.Net.Responses.Actions
{ {
public class AddFriend : IAction public class AddFriend : IAction
{ {
public Method RequestMethod { get{return Method.GET;} } public Method RequestMethod { get { return Method.GET; } }
public string EndPoint { get; private set; } public string EndPoint { get; private set; }
public IDictionary<string, object> BodyParameters { get{ return new Dictionary<string, object>();} } public IDictionary<string, object> BodyParameters { get { return new Dictionary<string, object>(); } }
public AddFriend(string target_id)
{ public AddFriend(string target_id)
if (string.IsNullOrWhiteSpace(target_id)) {
{ if (string.IsNullOrWhiteSpace(target_id))
throw new ArgumentNullException("target_id"); {
} throw new ArgumentNullException("target_id");
EndPoint = string.Format("v4/friend/request/{0}", target_id); }
} EndPoint = string.Format("v4/friend/request/{0}", target_id);
} }
} }
}

View File

@@ -4,15 +4,15 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.Actions namespace Untappd.Net.Responses.Actions
{ {
public class AddToWishList : IAction public class AddToWishList : IAction
{ {
public Method RequestMethod { get {return Method.GET;} } public Method RequestMethod { get { return Method.GET; } }
public string EndPoint { get { return "v4/user/wishlist/add"; } } public string EndPoint { get { return "v4/user/wishlist/add"; } }
public IDictionary<string, object> BodyParameters { get; private set; } public IDictionary<string, object> BodyParameters { get; private set; }
public AddToWishList(int beerId)
{
BodyParameters = new Dictionary<string, object>() { { "bid", beerId } };
} public AddToWishList(int beerId)
} {
} BodyParameters = new Dictionary<string, object>() { { "bid", beerId } };
}
}
}

View File

@@ -5,93 +5,92 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.Actions namespace Untappd.Net.Responses.Actions
{ {
public class CheckIn : IAction public class CheckIn : IAction
{ {
private short _rating; private short _rating;
private string _shout; private string _shout;
public Method RequestMethod { get{ return Method.POST;} } 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<string, object> BodyParameters public IDictionary<string, object> BodyParameters
{ {
get get
{ {
var dict = new Dictionary<string, object> var dict = new Dictionary<string, object>
{ {
{"gmt_offset", GmtOffset}, {"gmt_offset", GmtOffset},
{"timezone", Timezone}, {"timezone", Timezone},
{"bid", Bid} {"bid", Bid}
}; };
if (Geolat.HasValue) if (Geolat.HasValue)
{ {
dict.Add("geolat", Geolat.Value); dict.Add("geolat", Geolat.Value);
} }
if (Geolng.HasValue) if (Geolng.HasValue)
{ {
dict.Add("geolng", Geolng.Value); dict.Add("geolng", Geolng.Value);
} }
if (!string.IsNullOrWhiteSpace(Shout) && Shout.Length <= 140) if (!string.IsNullOrWhiteSpace(Shout) && Shout.Length <= 140)
{ {
dict.Add("shout", Shout); dict.Add("shout", Shout);
} }
if (Rating > 0 && Rating < 6) if (Rating > 0 && Rating < 6)
{ {
dict.Add("rating", Rating); dict.Add("rating", Rating);
} }
return dict; return dict;
} }
} }
public string GmtOffset { get; private set; } public string GmtOffset { get; private set; }
public string Timezone { get; private set; } public string Timezone { get; private set; }
public int Bid { get; private set; } public int Bid { get; private set; }
public int? Geolat { get; set; } public int? Geolat { get; set; }
public int? Geolng { get; set; } public int? Geolng { get; set; }
public string Shout public string Shout
{ {
get { return _shout; } get { return _shout; }
set set
{ {
if (value == null) if (value == null)
{ {
throw new ArgumentNullException("value"); throw new ArgumentNullException("value");
} }
if (value.Length > 140) if (value.Length > 140)
{ {
throw new ArgumentOutOfRangeException("value", value,"Shout can be no more than 140 characters"); throw new ArgumentOutOfRangeException("value", value, "Shout can be no more than 140 characters");
} }
_shout = string.Copy(value); _shout = string.Copy(value);
} }
} }
public short Rating public short Rating
{ {
get { return _rating; } get { return _rating; }
set set
{ {
if (value < 1 || value > 5) if (value < 1 || value > 5)
{ {
throw new ArgumentOutOfRangeException("value", value, "Ratings should be between 1 and 5"); throw new ArgumentOutOfRangeException("value", value, "Ratings should be between 1 and 5");
} }
_rating = value; _rating = value;
} }
} }
public CheckIn(string gmtOffset, string timezone, int bid)
public CheckIn(string gmtOffset, string timezone, int bid) {
{ if (string.IsNullOrWhiteSpace(gmtOffset))
if (string.IsNullOrWhiteSpace(gmtOffset)) {
{ throw new ArgumentNullException("gmtOffset");
throw new ArgumentNullException("gmtOffset"); }
} if (string.IsNullOrWhiteSpace(timezone))
if (string.IsNullOrWhiteSpace(timezone)) {
{ throw new ArgumentNullException("timezone");
throw new ArgumentNullException("timezone"); }
} GmtOffset = string.Copy(gmtOffset);
GmtOffset = string.Copy(gmtOffset); Timezone = string.Copy(timezone);
Timezone = string.Copy(timezone); Bid = bid;
Bid = bid; }
} }
} }
}

View File

@@ -4,29 +4,29 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.Actions namespace Untappd.Net.Responses.Actions
{ {
public class PendingFriends : IAction public class PendingFriends : IAction
{ {
public Method RequestMethod { get {return Method.GET;} } public Method RequestMethod { get { return Method.GET; } }
public string EndPoint { get { return "v4/user/pending"; }} public string EndPoint { get { return "v4/user/pending"; } }
public IDictionary<string, object> BodyParameters public IDictionary<string, object> BodyParameters
{ {
get get
{ {
var dict = new Dictionary<string, object>(); var dict = new Dictionary<string, object>();
if (Offset.HasValue) if (Offset.HasValue)
{ {
dict.Add("offset", Offset.Value); dict.Add("offset", Offset.Value);
} }
if (Limit.HasValue) if (Limit.HasValue)
{ {
dict.Add("limit", Limit.Value); dict.Add("limit", Limit.Value);
} }
return dict; return dict;
} }
} }
public int? Offset { get; set; } public int? Offset { get; set; }
public int? Limit { get; set; } public int? Limit { get; set; }
} }
} }

View File

@@ -5,18 +5,19 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.Actions namespace Untappd.Net.Responses.Actions
{ {
public class RemoveFriend : IAction public class RemoveFriend : IAction
{ {
public Method RequestMethod { get { return Method.GET; } } public Method RequestMethod { get { return Method.GET; } }
public string EndPoint { get; private set; } public string EndPoint { get; private set; }
public IDictionary<string, object> BodyParameters { get { return new Dictionary<string, object>(); } } public IDictionary<string, object> BodyParameters { get { return new Dictionary<string, object>(); } }
public RemoveFriend(string target_id)
{ public RemoveFriend(string target_id)
if (string.IsNullOrWhiteSpace(target_id)) {
{ if (string.IsNullOrWhiteSpace(target_id))
throw new ArgumentNullException("target_id"); {
} throw new ArgumentNullException("target_id");
EndPoint = string.Format("v4/friend/reject/{0}", target_id); }
} EndPoint = string.Format("v4/friend/reject/{0}", target_id);
} }
} }
}

View File

@@ -4,15 +4,15 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.Actions namespace Untappd.Net.Responses.Actions
{ {
public class RemoveFromWishList : IAction public class RemoveFromWishList : IAction
{ {
public Method RequestMethod { get {return Method.GET;} } public Method RequestMethod { get { return Method.GET; } }
public string EndPoint { get { return "v4/user/wishlist/delete"; } } public string EndPoint { get { return "v4/user/wishlist/delete"; } }
public IDictionary<string, object> BodyParameters { get; private set; } public IDictionary<string, object> BodyParameters { get; private set; }
public RemoveFromWishList(int beerId)
{
BodyParameters = new Dictionary<string, object>() { { "bid", beerId } };
} public RemoveFromWishList(int beerId)
} {
} BodyParameters = new Dictionary<string, object>() { { "bid", beerId } };
}
}
}

View File

@@ -5,23 +5,24 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.Actions namespace Untappd.Net.Responses.Actions
{ {
public class ToastUntoast : IAction public class ToastUntoast : IAction
{ {
public Method RequestMethod { get { return Method.POST; } } public Method RequestMethod { get { return Method.POST; } }
public IDictionary<string, object> BodyParameters { get { return new Dictionary<string, object>(); } } public IDictionary<string, object> BodyParameters { get { return new Dictionary<string, object>(); } }
public string EndPoint { get; private set; } public string EndPoint { get; private set; }
/// <summary>
/// /// <summary>
/// </summary> ///
/// <param name="checkinId"></param> /// </summary>
/// <exception cref="ArgumentNullException"></exception> /// <param name="checkinId"></param>
public ToastUntoast(string checkinId) /// <exception cref="ArgumentNullException"></exception>
{ public ToastUntoast(string checkinId)
if (string.IsNullOrWhiteSpace(checkinId)) {
{ if (string.IsNullOrWhiteSpace(checkinId))
throw new ArgumentNullException("checkinId"); {
} throw new ArgumentNullException("checkinId");
EndPoint = string.Format("v4/checkin/toast/{0}", checkinId); }
} EndPoint = string.Format("v4/checkin/toast/{0}", checkinId);
} }
} }
}

File diff suppressed because it is too large Load Diff

View File

@@ -4,270 +4,255 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.BeerSearch namespace Untappd.Net.Responses.BeerSearch
{ {
public class ResponseTime
{
[JsonProperty("time")]
public double Time { get; set; }
public class ResponseTime [JsonProperty("measure")]
{ public string Measure { get; set; }
}
[JsonProperty("time")] public class InitTime
public double Time { get; set; } {
[JsonProperty("time")]
public double Time { get; set; }
[JsonProperty("measure")] [JsonProperty("measure")]
public string Measure { get; set; } public string Measure { get; set; }
} }
public class InitTime public class Meta
{ {
[JsonProperty("code")]
public int Code { get; set; }
[JsonProperty("time")] [JsonProperty("response_time")]
public double Time { get; set; } public ResponseTime ResponseTime { get; set; }
[JsonProperty("measure")] [JsonProperty("init_time")]
public string Measure { get; set; } public InitTime InitTime { get; set; }
} }
public class Meta public class UnreadCount
{ {
[JsonProperty("comments")]
public int Comments { get; set; }
[JsonProperty("code")] [JsonProperty("toasts")]
public int Code { get; set; } public int Toasts { get; set; }
[JsonProperty("response_time")] [JsonProperty("friends")]
public ResponseTime ResponseTime { get; set; } public int Friends { get; set; }
[JsonProperty("init_time")] [JsonProperty("messages")]
public InitTime InitTime { get; set; } public int Messages { get; set; }
}
public class UnreadCount [JsonProperty("news")]
{ public int News { get; set; }
}
[JsonProperty("comments")] public class Notifications
public int Comments { get; set; } {
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("toasts")] [JsonProperty("unread_count")]
public int Toasts { get; set; } public UnreadCount UnreadCount { get; set; }
}
[JsonProperty("friends")] public class Beer
public int Friends { get; set; } {
[JsonProperty("bid")]
public int Bid { get; set; }
[JsonProperty("messages")] [JsonProperty("beer_name")]
public int Messages { get; set; } public string BeerName { get; set; }
[JsonProperty("news")] [JsonProperty("beer_label")]
public int News { get; set; } public string BeerLabel { get; set; }
}
public class Notifications [JsonProperty("beer_abv")]
{ public double BeerAbv { get; set; }
[JsonProperty("type")] [JsonProperty("beer_ibu")]
public string Type { get; set; } public int BeerIbu { get; set; }
[JsonProperty("unread_count")] [JsonProperty("beer_description")]
public UnreadCount UnreadCount { get; set; } public string BeerDescription { get; set; }
}
public class Beer [JsonProperty("created_at")]
{ public string CreatedAt { get; set; }
[JsonProperty("bid")] [JsonProperty("beer_style")]
public int Bid { get; set; } public string BeerStyle { get; set; }
[JsonProperty("beer_name")] [JsonProperty("auth_rating")]
public string BeerName { get; set; } public double AuthRating { get; set; }
[JsonProperty("beer_label")] [JsonProperty("wish_list")]
public string BeerLabel { get; set; } public bool WishList { get; set; }
[JsonProperty("beer_abv")] [JsonProperty("in_production")]
public double BeerAbv { get; set; } public int InProduction { get; set; }
}
[JsonProperty("beer_ibu")] public class Contact
public int BeerIbu { get; set; } {
[JsonProperty("twitter")]
public string Twitter { get; set; }
[JsonProperty("beer_description")] [JsonProperty("facebook")]
public string BeerDescription { get; set; } public string Facebook { get; set; }
[JsonProperty("created_at")] [JsonProperty("instagram")]
public string CreatedAt { get; set; } public string Instagram { get; set; }
[JsonProperty("beer_style")] [JsonProperty("url")]
public string BeerStyle { get; set; } public string Url { get; set; }
}
[JsonProperty("auth_rating")] public class Location
public double AuthRating { get; set; } {
[JsonProperty("brewery_city")]
public string BreweryCity { get; set; }
[JsonProperty("wish_list")] [JsonProperty("brewery_state")]
public bool WishList { get; set; } public string BreweryState { get; set; }
[JsonProperty("in_production")] [JsonProperty("lat")]
public int InProduction { get; set; } public double Lat { get; set; }
}
public class Contact [JsonProperty("lng")]
{ public double Lng { get; set; }
}
[JsonProperty("twitter")] public class Brewery
public string Twitter { get; set; } {
[JsonProperty("brewery_id")]
public int BreweryId { get; set; }
[JsonProperty("facebook")] [JsonProperty("brewery_name")]
public string Facebook { get; set; } public string BreweryName { get; set; }
[JsonProperty("instagram")] [JsonProperty("brewery_slug")]
public string Instagram { get; set; } public string BrewerySlug { get; set; }
[JsonProperty("url")] [JsonProperty("brewery_label")]
public string Url { get; set; } public string BreweryLabel { get; set; }
}
public class Location [JsonProperty("country_name")]
{ public string CountryName { get; set; }
[JsonProperty("brewery_city")] [JsonProperty("contact")]
public string BreweryCity { get; set; } public Contact Contact { get; set; }
[JsonProperty("brewery_state")] [JsonProperty("location")]
public string BreweryState { get; set; } public Location Location { get; set; }
[JsonProperty("lat")] [JsonProperty("brewery_active")]
public double Lat { get; set; } public int BreweryActive { get; set; }
}
[JsonProperty("lng")] public class Item
public double Lng { get; set; } {
} [JsonProperty("checkin_count")]
public int CheckinCount { get; set; }
public class Brewery [JsonProperty("have_had")]
{ public bool HaveHad { get; set; }
[JsonProperty("brewery_id")] [JsonProperty("your_count")]
public int BreweryId { get; set; } public int YourCount { get; set; }
[JsonProperty("brewery_name")] [JsonProperty("beer")]
public string BreweryName { get; set; } public Beer Beer { get; set; }
[JsonProperty("brewery_slug")] [JsonProperty("brewery")]
public string BrewerySlug { get; set; } public Brewery Brewery { get; set; }
}
[JsonProperty("brewery_label")] public class Beers
public string BreweryLabel { get; set; } {
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("country_name")] [JsonProperty("items")]
public string CountryName { get; set; } public IList<Item> Items { get; set; }
}
[JsonProperty("contact")] public class Homebrew
public Contact Contact { get; set; } {
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("location")] [JsonProperty("items")]
public Location Location { get; set; } public IList<object> Items { get; set; }
}
[JsonProperty("brewery_active")] public class Breweries
public int BreweryActive { get; set; } {
} [JsonProperty("items")]
public IList<object> Items { get; set; }
public class Item [JsonProperty("count")]
{ public int Count { get; set; }
}
[JsonProperty("checkin_count")] public class Response
public int CheckinCount { get; set; } {
[JsonProperty("message")]
public string Message { get; set; }
[JsonProperty("have_had")] [JsonProperty("brewery_id")]
public bool HaveHad { get; set; } public bool BreweryId { get; set; }
[JsonProperty("your_count")] [JsonProperty("search_type")]
public int YourCount { get; set; } public string SearchType { get; set; }
[JsonProperty("beer")] [JsonProperty("type_id")]
public Beer Beer { get; set; } public int TypeId { get; set; }
[JsonProperty("brewery")] [JsonProperty("search_version")]
public Brewery Brewery { get; set; } public int SearchVersion { get; set; }
}
public class Beers [JsonProperty("found")]
{ public int Found { get; set; }
[JsonProperty("count")] [JsonProperty("offset")]
public int Count { get; set; } public int Offset { get; set; }
[JsonProperty("items")] [JsonProperty("limit")]
public IList<Item> Items { get; set; } public int Limit { get; set; }
}
public class Homebrew [JsonProperty("term")]
{ public string Term { get; set; }
[JsonProperty("count")] [JsonProperty("parsed_term")]
public int Count { get; set; } public string ParsedTerm { get; set; }
[JsonProperty("items")] [JsonProperty("beers")]
public IList<object> Items { get; set; } public Beers Beers { get; set; }
}
public class Breweries [JsonProperty("homebrew")]
{ public Homebrew Homebrew { get; set; }
[JsonProperty("items")] [JsonProperty("breweries")]
public IList<object> Items { get; set; } public Breweries Breweries { get; set; }
}
[JsonProperty("count")] public class BeerSearch : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
public int Count { get; set; } {
} protected override string EndPointWithConfiguration { get { return "v4/search/beer"; } }
public class Response [JsonProperty("meta")]
{ public Meta Meta { get; set; }
[JsonProperty("message")] [JsonProperty("notifications")]
public string Message { get; set; } [JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("brewery_id")] [JsonProperty("response")]
public bool BreweryId { get; set; } public Response Response { get; set; }
}
[JsonProperty("search_type")]
public string SearchType { get; set; }
[JsonProperty("type_id")]
public int TypeId { get; set; }
[JsonProperty("search_version")]
public int SearchVersion { get; set; }
[JsonProperty("found")]
public int Found { get; set; }
[JsonProperty("offset")]
public int Offset { get; set; }
[JsonProperty("limit")]
public int Limit { get; set; }
[JsonProperty("term")]
public string Term { get; set; }
[JsonProperty("parsed_term")]
public string ParsedTerm { get; set; }
[JsonProperty("beers")]
public Beers Beers { get; set; }
[JsonProperty("homebrew")]
public Homebrew Homebrew { get; set; }
[JsonProperty("breweries")]
public Breweries Breweries { get; set; }
}
public class BeerSearch : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
{
protected override string EndPointWithConfiguration { get { return "v4/search/beer"; } }
[JsonProperty("meta")]
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]
public Response Response { get; set; }
}
} }

File diff suppressed because it is too large Load Diff

View File

@@ -4,158 +4,147 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.BrewerySearch namespace Untappd.Net.Responses.BrewerySearch
{ {
public class ResponseTime
{
[JsonProperty("time")]
public double Time { get; set; }
public class ResponseTime [JsonProperty("measure")]
{ public string Measure { get; set; }
}
[JsonProperty("time")] public class InitTime
public double Time { get; set; } {
[JsonProperty("time")]
public double Time { get; set; }
[JsonProperty("measure")] [JsonProperty("measure")]
public string Measure { get; set; } public string Measure { get; set; }
} }
public class InitTime public class Meta
{ {
[JsonProperty("code")]
public int Code { get; set; }
[JsonProperty("time")] [JsonProperty("response_time")]
public double Time { get; set; } public ResponseTime ResponseTime { get; set; }
[JsonProperty("measure")] [JsonProperty("init_time")]
public string Measure { get; set; } public InitTime InitTime { get; set; }
} }
public class Meta public class UnreadCount
{ {
[JsonProperty("comments")]
public int Comments { get; set; }
[JsonProperty("code")] [JsonProperty("toasts")]
public int Code { get; set; } public int Toasts { get; set; }
[JsonProperty("response_time")] [JsonProperty("friends")]
public ResponseTime ResponseTime { get; set; } public int Friends { get; set; }
[JsonProperty("init_time")] [JsonProperty("messages")]
public InitTime InitTime { get; set; } public int Messages { get; set; }
}
public class UnreadCount [JsonProperty("news")]
{ public int News { get; set; }
}
[JsonProperty("comments")] public class Notifications
public int Comments { get; set; } {
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("toasts")] [JsonProperty("unread_count")]
public int Toasts { get; set; } public UnreadCount UnreadCount { get; set; }
}
[JsonProperty("friends")] public class Location
public int Friends { get; set; } {
[JsonProperty("brewery_city")]
public string BreweryCity { get; set; }
[JsonProperty("messages")] [JsonProperty("brewery_state")]
public int Messages { get; set; } public string BreweryState { get; set; }
[JsonProperty("news")] [JsonProperty("lat")]
public int News { get; set; } public int Lat { get; set; }
}
public class Notifications [JsonProperty("lng")]
{ public int Lng { get; set; }
}
[JsonProperty("type")] public class Brewery2
public string Type { get; set; } {
[JsonProperty("brewery_id")]
public int BreweryId { get; set; }
[JsonProperty("unread_count")] [JsonProperty("beer_count")]
public UnreadCount UnreadCount { get; set; } public int BeerCount { get; set; }
}
public class Location [JsonProperty("brewery_name")]
{ public string BreweryName { get; set; }
[JsonProperty("brewery_city")] [JsonProperty("brewery_label")]
public string BreweryCity { get; set; } public string BreweryLabel { get; set; }
[JsonProperty("brewery_state")] [JsonProperty("country_name")]
public string BreweryState { get; set; } public string CountryName { get; set; }
[JsonProperty("lat")] [JsonProperty("location")]
public int Lat { get; set; } public Location Location { get; set; }
}
[JsonProperty("lng")] public class Item
public int Lng { get; set; } {
} [JsonProperty("brewery")]
public Brewery2 Brewery { get; set; }
}
public class Brewery2 public class Brewery
{ {
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("brewery_id")] [JsonProperty("items")]
public int BreweryId { get; set; } public IList<Item> Items { get; set; }
}
[JsonProperty("beer_count")] public class Response
public int BeerCount { get; set; } {
[JsonProperty("search_type")]
public string SearchType { get; set; }
[JsonProperty("brewery_name")] [JsonProperty("sort")]
public string BreweryName { get; set; } public string Sort { get; set; }
[JsonProperty("brewery_label")] [JsonProperty("term")]
public string BreweryLabel { get; set; } public string Term { get; set; }
[JsonProperty("country_name")] [JsonProperty("key")]
public string CountryName { get; set; } public string Key { get; set; }
[JsonProperty("location")] [JsonProperty("found")]
public Location Location { get; set; } public int Found { get; set; }
}
public class Item [JsonProperty("brewery")]
{ public Brewery Brewery { get; set; }
}
[JsonProperty("brewery")] public class BrewerySearch : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
public Brewery2 Brewery { get; set; } {
} protected override string EndPointWithConfiguration { get { return "v4/search/brewery"; } }
public class Brewery [JsonProperty("meta")]
{ public Meta Meta { get; set; }
[JsonProperty("count")] [JsonProperty("notifications")]
public int Count { get; set; } [JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("items")] [JsonProperty("response")]
public IList<Item> Items { get; set; } public Response Response { get; set; }
} }
}
public class Response
{
[JsonProperty("search_type")]
public string SearchType { get; set; }
[JsonProperty("sort")]
public string Sort { get; set; }
[JsonProperty("term")]
public string Term { get; set; }
[JsonProperty("key")]
public string Key { get; set; }
[JsonProperty("found")]
public int Found { get; set; }
[JsonProperty("brewery")]
public Brewery Brewery { get; set; }
}
public class BrewerySearch : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
{
protected override string EndPointWithConfiguration { get { return "v4/search/brewery"; } }
[JsonProperty("meta")]
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]
public Response Response { get; set; }
}
}

View File

@@ -4,523 +4,496 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.Feeds.ActivityFeed namespace Untappd.Net.Responses.Feeds.ActivityFeed
{ {
public class ResponseTime public class ResponseTime
{ {
[JsonProperty("time")]
public double Time { get; set; }
[JsonProperty("time")] [JsonProperty("measure")]
public double Time { get; set; } public string Measure { get; set; }
}
[JsonProperty("measure")] public class InitTime
public string Measure { get; set; } {
} [JsonProperty("time")]
public double Time { get; set; }
public class InitTime [JsonProperty("measure")]
{ public string Measure { get; set; }
}
[JsonProperty("time")] public class Meta
public double Time { get; set; } {
[JsonProperty("code")]
public int Code { get; set; }
[JsonProperty("measure")] [JsonProperty("response_time")]
public string Measure { get; set; } public ResponseTime ResponseTime { get; set; }
}
public class Meta [JsonProperty("init_time")]
{ public InitTime InitTime { get; set; }
}
[JsonProperty("code")] public class UnreadCount
public int Code { get; set; } {
[JsonProperty("comments")]
public int Comments { get; set; }
[JsonProperty("response_time")] [JsonProperty("toasts")]
public ResponseTime ResponseTime { get; set; } public int Toasts { get; set; }
[JsonProperty("init_time")] [JsonProperty("friends")]
public InitTime InitTime { get; set; } public int Friends { get; set; }
}
public class UnreadCount [JsonProperty("messages")]
{ public int Messages { get; set; }
[JsonProperty("comments")] [JsonProperty("news")]
public int Comments { get; set; } public int News { get; set; }
}
[JsonProperty("toasts")] public class Notifications
public int Toasts { get; set; } {
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("friends")] [JsonProperty("unread_count")]
public int Friends { get; set; } public UnreadCount UnreadCount { get; set; }
}
[JsonProperty("messages")] public class User
public int Messages { get; set; } {
[JsonProperty("uid")]
public int Uid { get; set; }
[JsonProperty("news")] [JsonProperty("user_name")]
public int News { get; set; } public string UserName { get; set; }
}
public class Notifications [JsonProperty("first_name")]
{ public string FirstName { get; set; }
[JsonProperty("type")] [JsonProperty("last_name")]
public string Type { get; set; } public string LastName { get; set; }
[JsonProperty("unread_count")] [JsonProperty("location")]
public UnreadCount UnreadCount { get; set; } public string Location { get; set; }
}
public class User [JsonProperty("url")]
{ public string Url { get; set; }
[JsonProperty("uid")] [JsonProperty("is_supporter")]
public int Uid { get; set; } public int IsSupporter { get; set; }
[JsonProperty("user_name")] [JsonProperty("relationship")]
public string UserName { get; set; } public string Relationship { get; set; }
[JsonProperty("first_name")] [JsonProperty("bio")]
public string FirstName { get; set; } public string Bio { get; set; }
[JsonProperty("last_name")] [JsonProperty("user_avatar")]
public string LastName { get; set; } public string UserAvatar { get; set; }
}
[JsonProperty("location")] public class Beer
public string Location { get; set; } {
[JsonProperty("bid")]
public int Bid { get; set; }
[JsonProperty("url")] [JsonProperty("beer_name")]
public string Url { get; set; } public string BeerName { get; set; }
[JsonProperty("is_supporter")] [JsonProperty("beer_label")]
public int IsSupporter { get; set; } public string BeerLabel { get; set; }
[JsonProperty("relationship")] [JsonProperty("beer_style")]
public string Relationship { get; set; } public string BeerStyle { get; set; }
[JsonProperty("bio")] [JsonProperty("beer_abv")]
public string Bio { get; set; } public double BeerAbv { get; set; }
[JsonProperty("user_avatar")] [JsonProperty("auth_rating")]
public string UserAvatar { get; set; } public double AuthRating { get; set; }
}
public class Beer [JsonProperty("wish_list")]
{ public bool WishList { get; set; }
[JsonProperty("bid")] [JsonProperty("beer_active")]
public int Bid { get; set; } public int BeerActive { get; set; }
}
[JsonProperty("beer_name")] public class Contact
public string BeerName { get; set; } {
[JsonProperty("twitter")]
public string Twitter { get; set; }
[JsonProperty("beer_label")] [JsonProperty("facebook")]
public string BeerLabel { get; set; } public string Facebook { get; set; }
[JsonProperty("beer_style")] [JsonProperty("instagram")]
public string BeerStyle { get; set; } public string Instagram { get; set; }
[JsonProperty("beer_abv")] [JsonProperty("url")]
public double BeerAbv { get; set; } public string Url { get; set; }
}
[JsonProperty("auth_rating")] public class Location
public double AuthRating { get; set; } {
[JsonProperty("brewery_city")]
public string BreweryCity { get; set; }
[JsonProperty("wish_list")] [JsonProperty("brewery_state")]
public bool WishList { get; set; } public string BreweryState { get; set; }
[JsonProperty("beer_active")] [JsonProperty("lat")]
public int BeerActive { get; set; } public double Lat { get; set; }
}
public class Contact [JsonProperty("lng")]
{ public double Lng { get; set; }
}
[JsonProperty("twitter")] public class Brewery
public string Twitter { get; set; } {
[JsonProperty("brewery_id")]
public int BreweryId { get; set; }
[JsonProperty("facebook")] [JsonProperty("brewery_name")]
public string Facebook { get; set; } public string BreweryName { get; set; }
[JsonProperty("instagram")] [JsonProperty("brewery_slug")]
public string Instagram { get; set; } public string BrewerySlug { get; set; }
[JsonProperty("url")] [JsonProperty("brewery_label")]
public string Url { get; set; } public string BreweryLabel { get; set; }
}
public class Location [JsonProperty("country_name")]
{ public string CountryName { get; set; }
[JsonProperty("brewery_city")] [JsonProperty("contact")]
public string BreweryCity { get; set; } public Contact Contact { get; set; }
[JsonProperty("brewery_state")] [JsonProperty("location")]
public string BreweryState { get; set; } public Location Location { get; set; }
[JsonProperty("lat")] [JsonProperty("brewery_active")]
public double Lat { get; set; } public int BreweryActive { get; set; }
}
[JsonProperty("lng")] public class User2
public double Lng { get; set; } {
} [JsonProperty("uid")]
public int Uid { get; set; }
public class Brewery [JsonProperty("user_name")]
{ public string UserName { get; set; }
[JsonProperty("brewery_id")] [JsonProperty("first_name")]
public int BreweryId { get; set; } public string FirstName { get; set; }
[JsonProperty("brewery_name")] [JsonProperty("last_name")]
public string BreweryName { get; set; } public string LastName { get; set; }
[JsonProperty("brewery_slug")] [JsonProperty("bio")]
public string BrewerySlug { get; set; } public string Bio { get; set; }
[JsonProperty("brewery_label")] [JsonProperty("location")]
public string BreweryLabel { get; set; } public string Location { get; set; }
[JsonProperty("country_name")] [JsonProperty("relationship")]
public string CountryName { get; set; } public string Relationship { get; set; }
[JsonProperty("contact")] [JsonProperty("is_supporter")]
public Contact Contact { get; set; } public int IsSupporter { get; set; }
[JsonProperty("location")] [JsonProperty("user_avatar")]
public Location Location { get; set; } public string UserAvatar { get; set; }
[JsonProperty("brewery_active")] [JsonProperty("user_link")]
public int BreweryActive { get; set; } public string UserLink { get; set; }
}
public class User2 [JsonProperty("account_type")]
{ public string AccountType { get; set; }
[JsonProperty("uid")] [JsonProperty("brewery_details")]
public int Uid { get; set; } public IList<object> BreweryDetails { get; set; }
}
[JsonProperty("user_name")] public class Item2
public string UserName { get; set; } {
[JsonProperty("user")]
public User2 User { get; set; }
[JsonProperty("first_name")] [JsonProperty("checkin_id")]
public string FirstName { get; set; } public int CheckinId { get; set; }
[JsonProperty("last_name")] [JsonProperty("comment_id")]
public string LastName { get; set; } public int CommentId { get; set; }
[JsonProperty("bio")] [JsonProperty("comment_owner")]
public string Bio { get; set; } public bool CommentOwner { get; set; }
[JsonProperty("location")] [JsonProperty("comment_editor")]
public string Location { get; set; } public bool CommentEditor { get; set; }
[JsonProperty("relationship")] [JsonProperty("comment")]
public string Relationship { get; set; } public string Comment { get; set; }
[JsonProperty("is_supporter")] [JsonProperty("created_at")]
public int IsSupporter { get; set; } public string CreatedAt { get; set; }
[JsonProperty("user_avatar")] [JsonProperty("comment_source")]
public string UserAvatar { get; set; } public string CommentSource { get; set; }
}
[JsonProperty("user_link")] public class Comments
public string UserLink { get; set; } {
[JsonProperty("total_count")]
public int TotalCount { get; set; }
[JsonProperty("account_type")] [JsonProperty("count")]
public string AccountType { get; set; } public int Count { get; set; }
[JsonProperty("brewery_details")] [JsonProperty("items")]
public IList<object> BreweryDetails { get; set; } public IList<Item2> Items { get; set; }
} }
public class Item2 public class User3
{ {
[JsonProperty("uid")]
public int Uid { get; set; }
[JsonProperty("user")] [JsonProperty("user_name")]
public User2 User { get; set; } public string UserName { get; set; }
[JsonProperty("checkin_id")] [JsonProperty("first_name")]
public int CheckinId { get; set; } public string FirstName { get; set; }
[JsonProperty("comment_id")] [JsonProperty("last_name")]
public int CommentId { get; set; } public string LastName { get; set; }
[JsonProperty("comment_owner")] [JsonProperty("bio")]
public bool CommentOwner { get; set; } public string Bio { get; set; }
[JsonProperty("comment_editor")] [JsonProperty("location")]
public bool CommentEditor { get; set; } public string Location { get; set; }
[JsonProperty("comment")] [JsonProperty("user_avatar")]
public string Comment { get; set; } public string UserAvatar { get; set; }
[JsonProperty("created_at")] [JsonProperty("user_link")]
public string CreatedAt { get; set; } public string UserLink { get; set; }
[JsonProperty("comment_source")] [JsonProperty("account_type")]
public string CommentSource { get; set; } public string AccountType { get; set; }
}
public class Comments [JsonProperty("brewery_details")]
{ public IList<object> BreweryDetails { get; set; }
}
[JsonProperty("total_count")] public class Item3
public int TotalCount { get; set; } {
[JsonProperty("uid")]
public int Uid { get; set; }
[JsonProperty("count")] [JsonProperty("user")]
public int Count { get; set; } public User3 User { get; set; }
[JsonProperty("items")] [JsonProperty("like_id")]
public IList<Item2> Items { get; set; } public int LikeId { get; set; }
}
public class User3 [JsonProperty("like_owner")]
{ public bool LikeOwner { get; set; }
[JsonProperty("uid")] [JsonProperty("created_at")]
public int Uid { get; set; } public string CreatedAt { get; set; }
}
[JsonProperty("user_name")] public class Toasts
public string UserName { get; set; } {
[JsonProperty("total_count")]
public int TotalCount { get; set; }
[JsonProperty("first_name")] [JsonProperty("count")]
public string FirstName { get; set; } public int Count { get; set; }
[JsonProperty("last_name")] [JsonProperty("auth_toast", NullValueHandling = NullValueHandling.Ignore)]
public string LastName { get; set; } public bool AuthToast { get; set; }
[JsonProperty("bio")] [JsonProperty("items")]
public string Bio { get; set; } public IList<Item3> Items { get; set; }
}
[JsonProperty("location")] public class Photo
public string Location { get; set; } {
[JsonProperty("photo_img_sm")]
public string PhotoImgSm { get; set; }
[JsonProperty("user_avatar")] [JsonProperty("photo_img_md")]
public string UserAvatar { get; set; } public string PhotoImgMd { get; set; }
[JsonProperty("user_link")] [JsonProperty("photo_img_lg")]
public string UserLink { get; set; } public string PhotoImgLg { get; set; }
[JsonProperty("account_type")] [JsonProperty("photo_img_og")]
public string AccountType { get; set; } public string PhotoImgOg { get; set; }
}
[JsonProperty("brewery_details")] public class Item4
public IList<object> BreweryDetails { get; set; } {
} [JsonProperty("photo_id")]
public int PhotoId { get; set; }
public class Item3 [JsonProperty("photo")]
{ public Photo Photo { get; set; }
}
[JsonProperty("uid")] public class Media
public int Uid { get; set; } {
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("user")] [JsonProperty("items")]
public User3 User { get; set; } public IList<Item4> Items { get; set; }
}
[JsonProperty("like_id")] public class Source
public int LikeId { get; set; } {
[JsonProperty("app_name")]
public string AppName { get; set; }
[JsonProperty("like_owner")] [JsonProperty("app_website")]
public bool LikeOwner { get; set; } public string AppWebsite { get; set; }
}
[JsonProperty("created_at")] public class BadgeImage
public string CreatedAt { get; set; } {
} [JsonProperty("sm")]
public string Sm { get; set; }
public class Toasts [JsonProperty("md")]
{ public string Md { get; set; }
[JsonProperty("total_count")] [JsonProperty("lg")]
public int TotalCount { get; set; } public string Lg { get; set; }
}
[JsonProperty("count")] public class Item5
public int Count { get; set; } {
[JsonProperty("badge_id")]
public int BadgeId { get; set; }
[JsonProperty("auth_toast", NullValueHandling = NullValueHandling.Ignore)] [JsonProperty("user_badge_id")]
public bool AuthToast { get; set; } public int UserBadgeId { get; set; }
[JsonProperty("items")] [JsonProperty("badge_name")]
public IList<Item3> Items { get; set; } public string BadgeName { get; set; }
}
public class Photo [JsonProperty("badge_description")]
{ public string BadgeDescription { get; set; }
[JsonProperty("photo_img_sm")] [JsonProperty("created_at")]
public string PhotoImgSm { get; set; } public string CreatedAt { get; set; }
[JsonProperty("photo_img_md")] [JsonProperty("badge_image")]
public string PhotoImgMd { get; set; } public BadgeImage BadgeImage { get; set; }
}
[JsonProperty("photo_img_lg")] public class Badges
public string PhotoImgLg { get; set; } {
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("photo_img_og")] [JsonProperty("items")]
public string PhotoImgOg { get; set; } public IList<Item5> Items { get; set; }
} }
public class Item4 public class Item
{ {
[JsonProperty("checkin_id")]
public int CheckinId { get; set; }
[JsonProperty("photo_id")] [JsonProperty("created_at")]
public int PhotoId { get; set; } public string CreatedAt { get; set; }
[JsonProperty("photo")] [JsonProperty("checkin_comment")]
public Photo Photo { get; set; } public string CheckinComment { get; set; }
}
public class Media [JsonProperty("rating_score")]
{ public double RatingScore { get; set; }
[JsonProperty("count")] [JsonProperty("user")]
public int Count { get; set; } public User User { get; set; }
[JsonProperty("items")] [JsonProperty("beer")]
public IList<Item4> Items { get; set; } public Beer Beer { get; set; }
}
public class Source [JsonProperty("brewery")]
{ public Brewery Brewery { get; set; }
[JsonProperty("app_name")] [JsonProperty("venue")]
public string AppName { get; set; } public object Venue { get; set; }
[JsonProperty("app_website")] [JsonProperty("comments")]
public string AppWebsite { get; set; } public Comments Comments { get; set; }
}
public class BadgeImage [JsonProperty("toasts")]
{ public Toasts Toasts { get; set; }
[JsonProperty("sm")] [JsonProperty("media")]
public string Sm { get; set; } public Media Media { get; set; }
[JsonProperty("md")] [JsonProperty("source")]
public string Md { get; set; } public Source Source { get; set; }
[JsonProperty("lg")] [JsonProperty("badges")]
public string Lg { get; set; } public Badges Badges { get; set; }
} }
public class Item5 public class Checkins
{ {
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("badge_id")] [JsonProperty("items")]
public int BadgeId { get; set; } public IList<Item> Items { get; set; }
}
[JsonProperty("user_badge_id")] public class Pagination
public int UserBadgeId { get; set; } {
[JsonProperty("next_url")]
public string NextUrl { get; set; }
[JsonProperty("badge_name")] [JsonProperty("max_id")]
public string BadgeName { get; set; } public int MaxId { get; set; }
[JsonProperty("badge_description")] [JsonProperty("since_url")]
public string BadgeDescription { get; set; } public string SinceUrl { get; set; }
}
[JsonProperty("created_at")] public class Response
public string CreatedAt { get; set; } {
[JsonProperty("mg")]
public bool Mg { get; set; }
[JsonProperty("badge_image")] [JsonProperty("checkins")]
public BadgeImage BadgeImage { get; set; } [JsonConverter(typeof(SingleObjectArrayConverter<Checkins>))]
} public Checkins Checkins { get; set; }
public class Badges [JsonProperty("pagination")]
{ public Pagination Pagination { get; set; }
}
[JsonProperty("count")] public class ActivityFeed : BasicRequest, IAuthenticatedRequest
public int Count { get; set; } {
protected override string EndPointWithConfiguration { get { return "/v4/checkin/recent"; } }
[JsonProperty("items")] [JsonProperty("meta")]
public IList<Item5> Items { get; set; } public Meta Meta { get; set; }
}
public class Item [JsonProperty("notifications")]
{ [JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("checkin_id")] [JsonProperty("response")]
public int CheckinId { get; set; } public Response Response { 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<Item> 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")]
[JsonConverter(typeof(SingleObjectArrayConverter<Checkins>))]
public Checkins Checkins { get; set; }
[JsonProperty("pagination")]
public Pagination Pagination { get; set; }
}
public class ActivityFeed : BasicRequest, IAuthenticatedRequest
{
protected override string EndPointWithConfiguration { get { return "/v4/checkin/recent"; } }
[JsonProperty("meta")]
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]
public Response Response { get; set; }
}
}

View File

@@ -4,490 +4,461 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.Feeds.UserActivityFeed namespace Untappd.Net.Responses.Feeds.UserActivityFeed
{ {
public class ResponseTime public class ResponseTime
{ {
[JsonProperty("time")]
public double Time { get; set; }
[JsonProperty("time")] [JsonProperty("measure")]
public double Time { get; set; } public string Measure { get; set; }
}
[JsonProperty("measure")] public class InitTime
public string Measure { get; set; } {
} [JsonProperty("time")]
public double Time { get; set; }
public class InitTime [JsonProperty("measure")]
{ public string Measure { get; set; }
}
[JsonProperty("time")] public class Meta
public double Time { get; set; } {
[JsonProperty("code")]
public int Code { get; set; }
[JsonProperty("measure")] [JsonProperty("response_time")]
public string Measure { get; set; } public ResponseTime ResponseTime { get; set; }
}
public class Meta [JsonProperty("init_time")]
{ public InitTime InitTime { get; set; }
}
[JsonProperty("code")] public class UnreadCount
public int Code { get; set; } {
[JsonProperty("comments")]
public int Comments { get; set; }
[JsonProperty("response_time")] [JsonProperty("toasts")]
public ResponseTime ResponseTime { get; set; } public int Toasts { get; set; }
[JsonProperty("init_time")] [JsonProperty("friends")]
public InitTime InitTime { get; set; } public int Friends { get; set; }
}
public class UnreadCount [JsonProperty("messages")]
{ public int Messages { get; set; }
[JsonProperty("comments")] [JsonProperty("news")]
public int Comments { get; set; } public int News { get; set; }
}
[JsonProperty("toasts")] public class Notifications
public int Toasts { get; set; } {
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("friends")] [JsonProperty("unread_count")]
public int Friends { get; set; } public UnreadCount UnreadCount { get; set; }
}
[JsonProperty("messages")] public class Pagination
public int Messages { get; set; } {
[JsonProperty("since_url")]
public string SinceUrl { get; set; }
[JsonProperty("news")] [JsonProperty("next_url")]
public int News { get; set; } public string NextUrl { get; set; }
}
public class Notifications [JsonProperty("max_id")]
{ public int MaxId { get; set; }
}
[JsonProperty("type")] public class Contact
public string Type { get; set; } {
[JsonProperty("facebook")]
public string Facebook { get; set; }
}
[JsonProperty("unread_count")] public class User
public UnreadCount UnreadCount { get; set; } {
} [JsonProperty("uid")]
public int Uid { get; set; }
public class Pagination [JsonProperty("user_name")]
{ public string UserName { get; set; }
[JsonProperty("since_url")] [JsonProperty("first_name")]
public string SinceUrl { get; set; } public string FirstName { get; set; }
[JsonProperty("next_url")] [JsonProperty("last_name")]
public string NextUrl { get; set; } public string LastName { get; set; }
[JsonProperty("max_id")] [JsonProperty("location")]
public int MaxId { get; set; } public string Location { get; set; }
}
public class Contact [JsonProperty("is_supporter")]
{ public int IsSupporter { get; set; }
[JsonProperty("facebook")] [JsonProperty("url")]
public string Facebook { get; set; } public string Url { get; set; }
}
public class User [JsonProperty("bio")]
{ public string Bio { get; set; }
[JsonProperty("uid")] [JsonProperty("relationship")]
public int Uid { get; set; } public string Relationship { get; set; }
[JsonProperty("user_name")] [JsonProperty("user_avatar")]
public string UserName { get; set; } public string UserAvatar { get; set; }
[JsonProperty("first_name")] [JsonProperty("is_private")]
public string FirstName { get; set; } public int IsPrivate { get; set; }
[JsonProperty("last_name")] [JsonProperty("contact")]
public string LastName { get; set; } public Contact Contact { get; set; }
}
[JsonProperty("location")] public class Beer
public string Location { get; set; } {
[JsonProperty("bid")]
public int Bid { get; set; }
[JsonProperty("is_supporter")] [JsonProperty("beer_name")]
public int IsSupporter { get; set; } public string BeerName { get; set; }
[JsonProperty("url")] [JsonProperty("beer_label")]
public string Url { get; set; } public string BeerLabel { get; set; }
[JsonProperty("bio")] [JsonProperty("beer_style")]
public string Bio { get; set; } public string BeerStyle { get; set; }
[JsonProperty("relationship")] [JsonProperty("beer_abv")]
public string Relationship { get; set; } public double BeerAbv { get; set; }
[JsonProperty("user_avatar")] [JsonProperty("auth_rating")]
public string UserAvatar { get; set; } public double AuthRating { get; set; }
[JsonProperty("is_private")] [JsonProperty("wish_list")]
public int IsPrivate { get; set; } public bool WishList { get; set; }
[JsonProperty("contact")] [JsonProperty("beer_active")]
public Contact Contact { get; set; } public int BeerActive { get; set; }
} }
public class Beer public class Contact2
{ {
[JsonProperty("twitter")]
public string Twitter { get; set; }
[JsonProperty("bid")] [JsonProperty("facebook")]
public int Bid { get; set; } public string Facebook { get; set; }
[JsonProperty("beer_name")] [JsonProperty("instagram")]
public string BeerName { get; set; } public string Instagram { get; set; }
[JsonProperty("beer_label")] [JsonProperty("url")]
public string BeerLabel { get; set; } public string Url { get; set; }
}
[JsonProperty("beer_style")] public class Location
public string BeerStyle { get; set; } {
[JsonProperty("brewery_city")]
public string BreweryCity { get; set; }
[JsonProperty("beer_abv")] [JsonProperty("brewery_state")]
public double BeerAbv { get; set; } public string BreweryState { get; set; }
[JsonProperty("auth_rating")] [JsonProperty("lat")]
public double AuthRating { get; set; } public double Lat { get; set; }
[JsonProperty("wish_list")] [JsonProperty("lng")]
public bool WishList { get; set; } public double Lng { get; set; }
}
[JsonProperty("beer_active")] public class Brewery
public int BeerActive { get; set; } {
} [JsonProperty("brewery_id")]
public int BreweryId { get; set; }
public class Contact2 [JsonProperty("brewery_name")]
{ public string BreweryName { get; set; }
[JsonProperty("twitter")] [JsonProperty("brewery_slug")]
public string Twitter { get; set; } public string BrewerySlug { get; set; }
[JsonProperty("facebook")] [JsonProperty("brewery_label")]
public string Facebook { get; set; } public string BreweryLabel { get; set; }
[JsonProperty("instagram")] [JsonProperty("country_name")]
public string Instagram { get; set; } public string CountryName { get; set; }
[JsonProperty("url")] [JsonProperty("contact")]
public string Url { get; set; } public Contact2 Contact { get; set; }
}
public class Location [JsonProperty("location")]
{ public Location Location { get; set; }
[JsonProperty("brewery_city")] [JsonProperty("brewery_active")]
public string BreweryCity { get; set; } public int BreweryActive { get; set; }
}
[JsonProperty("brewery_state")] public class Item2
public string BreweryState { get; set; } {
[JsonProperty("category_name")]
public string CategoryName { get; set; }
[JsonProperty("lat")] [JsonProperty("category_id")]
public double Lat { get; set; } public string CategoryId { get; set; }
[JsonProperty("lng")] [JsonProperty("is_primary")]
public double Lng { get; set; } public bool IsPrimary { get; set; }
} }
public class Brewery public class Categories
{ {
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("brewery_id")] [JsonProperty("items")]
public int BreweryId { get; set; } public IList<Item2> Items { get; set; }
}
[JsonProperty("brewery_name")] public class Location2
public string BreweryName { get; set; } {
[JsonProperty("venue_address")]
public string VenueAddress { get; set; }
[JsonProperty("brewery_slug")] [JsonProperty("venue_city")]
public string BrewerySlug { get; set; } public string VenueCity { get; set; }
[JsonProperty("brewery_label")] [JsonProperty("venue_state")]
public string BreweryLabel { get; set; } public string VenueState { get; set; }
[JsonProperty("country_name")] [JsonProperty("venue_country")]
public string CountryName { get; set; } public string VenueCountry { get; set; }
[JsonProperty("contact")] [JsonProperty("lat")]
public Contact2 Contact { get; set; } public double Lat { get; set; }
[JsonProperty("location")] [JsonProperty("lng")]
public Location Location { get; set; } public double Lng { get; set; }
}
[JsonProperty("brewery_active")] public class Contact3
public int BreweryActive { get; set; } {
} [JsonProperty("twitter")]
public string Twitter { get; set; }
public class Item2 [JsonProperty("venue_url")]
{ public string VenueUrl { get; set; }
}
[JsonProperty("category_name")] public class Foursquare
public string CategoryName { get; set; } {
[JsonProperty("foursquare_id")]
public string FoursquareId { get; set; }
[JsonProperty("category_id")] [JsonProperty("foursquare_url")]
public string CategoryId { get; set; } public string FoursquareUrl { get; set; }
}
[JsonProperty("is_primary")] public class VenueIcon
public bool IsPrimary { get; set; } {
} [JsonProperty("sm")]
public string Sm { get; set; }
public class Categories [JsonProperty("md")]
{ public string Md { get; set; }
[JsonProperty("count")] [JsonProperty("lg")]
public int Count { get; set; } public string Lg { get; set; }
}
[JsonProperty("items")] public class Venue
public IList<Item2> Items { get; set; } {
} [JsonProperty("venue_id")]
public int VenueId { get; set; }
public class Location2 [JsonProperty("venue_name")]
{ public string VenueName { get; set; }
[JsonProperty("venue_address")] [JsonProperty("primary_category")]
public string VenueAddress { get; set; } public string PrimaryCategory { get; set; }
[JsonProperty("venue_city")] [JsonProperty("parent_category_id")]
public string VenueCity { get; set; } public string ParentCategoryId { get; set; }
[JsonProperty("venue_state")] [JsonProperty("categories")]
public string VenueState { get; set; } public Categories Categories { get; set; }
[JsonProperty("venue_country")] [JsonProperty("location")]
public string VenueCountry { get; set; } public Location2 Location { get; set; }
[JsonProperty("lat")] [JsonProperty("contact")]
public double Lat { get; set; } public Contact3 Contact { get; set; }
[JsonProperty("lng")] [JsonProperty("public_venue")]
public double Lng { get; set; } public bool PublicVenue { get; set; }
}
public class Contact3 [JsonProperty("foursquare")]
{ public Foursquare Foursquare { get; set; }
[JsonProperty("twitter")] [JsonProperty("venue_icon")]
public string Twitter { get; set; } public VenueIcon VenueIcon { get; set; }
}
[JsonProperty("venue_url")] public class Comments
public string VenueUrl { get; set; } {
} [JsonProperty("total_count")]
public int TotalCount { get; set; }
public class Foursquare [JsonProperty("count")]
{ public int Count { get; set; }
[JsonProperty("foursquare_id")] [JsonProperty("items")]
public string FoursquareId { get; set; } public IList<object> Items { get; set; }
}
[JsonProperty("foursquare_url")] public class Toasts
public string FoursquareUrl { get; set; } {
} [JsonProperty("total_count")]
public int TotalCount { get; set; }
public class VenueIcon [JsonProperty("count")]
{ public int Count { get; set; }
[JsonProperty("sm")] [JsonProperty("auth_toast", NullValueHandling = NullValueHandling.Ignore)]
public string Sm { get; set; } public bool AuthToast { get; set; }
[JsonProperty("md")] [JsonProperty("items")]
public string Md { get; set; } public IList<object> Items { get; set; }
}
[JsonProperty("lg")] public class Photo
public string Lg { get; set; } {
} [JsonProperty("photo_img_sm")]
public string PhotoImgSm { get; set; }
public class Venue [JsonProperty("photo_img_md")]
{ public string PhotoImgMd { get; set; }
[JsonProperty("venue_id")] [JsonProperty("photo_img_lg")]
public int VenueId { get; set; } public string PhotoImgLg { get; set; }
[JsonProperty("venue_name")] [JsonProperty("photo_img_og")]
public string VenueName { get; set; } public string PhotoImgOg { get; set; }
}
[JsonProperty("primary_category")] public class Item3
public string PrimaryCategory { get; set; } {
[JsonProperty("photo_id")]
public int PhotoId { get; set; }
[JsonProperty("parent_category_id")] [JsonProperty("photo")]
public string ParentCategoryId { get; set; } public Photo Photo { get; set; }
}
[JsonProperty("categories")] public class Media
public Categories Categories { get; set; } {
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("location")] [JsonProperty("items")]
public Location2 Location { get; set; } public IList<Item3> Items { get; set; }
}
[JsonProperty("contact")] public class Source
public Contact3 Contact { get; set; } {
[JsonProperty("app_name")]
public string AppName { get; set; }
[JsonProperty("public_venue")] [JsonProperty("app_website")]
public bool PublicVenue { get; set; } public string AppWebsite { get; set; }
}
[JsonProperty("foursquare")] public class Badges
public Foursquare Foursquare { get; set; } {
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("venue_icon")] [JsonProperty("items")]
public VenueIcon VenueIcon { get; set; } public IList<object> Items { get; set; }
} }
public class Comments public class Item
{ {
[JsonProperty("checkin_id")]
public int CheckinId { get; set; }
[JsonProperty("total_count")] [JsonProperty("created_at")]
public int TotalCount { get; set; } public string CreatedAt { get; set; }
[JsonProperty("count")] [JsonProperty("checkin_comment")]
public int Count { get; set; } public string CheckinComment { get; set; }
[JsonProperty("items")] [JsonProperty("rating_score")]
public IList<object> Items { get; set; } public double RatingScore { get; set; }
}
public class Toasts [JsonProperty("user")]
{ public User User { get; set; }
[JsonProperty("total_count")] [JsonProperty("beer")]
public int TotalCount { get; set; } public Beer Beer { get; set; }
[JsonProperty("count")] [JsonProperty("brewery")]
public int Count { get; set; } public Brewery Brewery { get; set; }
[JsonProperty("auth_toast", NullValueHandling = NullValueHandling.Ignore)] [JsonProperty("venue")]
public bool AuthToast { get; set; } [JsonConverter(typeof(SingleObjectArrayConverter<Venue>))]
public Venue Venue { get; set; }
[JsonProperty("items")] [JsonProperty("comments")]
public IList<object> Items { get; set; } public Comments Comments { get; set; }
}
public class Photo [JsonProperty("toasts")]
{ public Toasts Toasts { get; set; }
[JsonProperty("photo_img_sm")] [JsonProperty("media")]
public string PhotoImgSm { get; set; } public Media Media { get; set; }
[JsonProperty("photo_img_md")] [JsonProperty("source")]
public string PhotoImgMd { get; set; } public Source Source { get; set; }
[JsonProperty("photo_img_lg")] [JsonProperty("badges")]
public string PhotoImgLg { get; set; } public Badges Badges { get; set; }
}
[JsonProperty("photo_img_og")] public class Checkins
public string PhotoImgOg { get; set; } {
} [JsonProperty("count")]
public int Count { get; set; }
public class Item3 [JsonProperty("items")]
{ public IList<Item> Items { get; set; }
}
[JsonProperty("photo_id")] public class Response
public int PhotoId { get; set; } {
[JsonProperty("pagination")]
public Pagination Pagination { get; set; }
[JsonProperty("photo")] [JsonProperty("checkins")]
public Photo Photo { get; set; } [JsonConverter(typeof(SingleObjectArrayConverter<Checkins>))]
} public Checkins Checkins { get; set; }
}
public class Media public class UserActivityFeed : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
{ {
protected override string EndPointWithConfiguration { get { return "v4/user/checkins{0}"; } }
[JsonProperty("count")] [JsonProperty("meta")]
public int Count { get; set; } public Meta Meta { get; set; }
[JsonProperty("items")] [JsonProperty("notifications")]
public IList<Item3> Items { get; set; } [JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
} public Notifications Notifications { get; set; }
public class Source [JsonProperty("response")]
{ public Response Response { get; set; }
}
[JsonProperty("app_name")] }
public string AppName { get; set; }
[JsonProperty("app_website")]
public string AppWebsite { get; set; }
}
public class Badges
{
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("items")]
public IList<object> 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")]
[JsonConverter(typeof(SingleObjectArrayConverter<Venue>))]
public Venue 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<Item> Items { get; set; }
}
public class Response
{
[JsonProperty("pagination")]
public Pagination Pagination { get; set; }
[JsonProperty("checkins")]
[JsonConverter(typeof(SingleObjectArrayConverter<Checkins>))]
public Checkins Checkins { get; set; }
}
public class UserActivityFeed : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
{
protected override string EndPointWithConfiguration { get { return "v4/user/checkins{0}"; } }
[JsonProperty("meta")]
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]
public Response Response { get; set; }
}
}

View File

@@ -4,225 +4,215 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.UserBadges namespace Untappd.Net.Responses.UserBadges
{ {
public class ResponseTime
{
[JsonProperty("time")]
public double Time { get; set; }
public class ResponseTime [JsonProperty("measure")]
{ public string Measure { get; set; }
}
[JsonProperty("time")] public class InitTime
public double Time { get; set; } {
[JsonProperty("time")]
public double Time { get; set; }
[JsonProperty("measure")] [JsonProperty("measure")]
public string Measure { get; set; } public string Measure { get; set; }
} }
public class InitTime public class Meta
{ {
[JsonProperty("code")]
public int Code { get; set; }
[JsonProperty("time")] [JsonProperty("response_time")]
public double Time { get; set; } public ResponseTime ResponseTime { get; set; }
[JsonProperty("measure")] [JsonProperty("init_time")]
public string Measure { get; set; } public InitTime InitTime { get; set; }
} }
public class Meta public class UnreadCount
{ {
[JsonProperty("comments")]
public int Comments { get; set; }
[JsonProperty("code")] [JsonProperty("toasts")]
public int Code { get; set; } public int Toasts { get; set; }
[JsonProperty("response_time")] [JsonProperty("friends")]
public ResponseTime ResponseTime { get; set; } public int Friends { get; set; }
[JsonProperty("init_time")] [JsonProperty("messages")]
public InitTime InitTime { get; set; } public int Messages { get; set; }
}
public class UnreadCount [JsonProperty("news")]
{ public int News { get; set; }
}
[JsonProperty("comments")] public class Notifications
public int Comments { get; set; } {
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("toasts")] [JsonProperty("unread_count")]
public int Toasts { get; set; } public UnreadCount UnreadCount { get; set; }
}
[JsonProperty("friends")] public class Media
public int Friends { get; set; } {
[JsonProperty("badge_image_sm")]
public string BadgeImageSm { get; set; }
[JsonProperty("messages")] [JsonProperty("badge_image_md")]
public int Messages { get; set; } public string BadgeImageMd { get; set; }
[JsonProperty("news")] [JsonProperty("badge_image_lg")]
public int News { get; set; } public string BadgeImageLg { get; set; }
} }
public class Notifications public class BadgePackProgress
{ {
[JsonProperty("completed")]
public int Completed { get; set; }
[JsonProperty("type")] [JsonProperty("total")]
public string Type { get; set; } public int Total { get; set; }
}
[JsonProperty("unread_count")] public class BadgeLevel
public UnreadCount UnreadCount { get; set; } {
} [JsonProperty("actual_badge_id")]
public int ActualBadgeId { get; set; }
public class Media [JsonProperty("badge_id")]
{ public int BadgeId { get; set; }
[JsonProperty("badge_image_sm")] [JsonProperty("checkin_id")]
public string BadgeImageSm { get; set; } public int CheckinId { get; set; }
[JsonProperty("badge_image_md")] [JsonProperty("badge_name")]
public string BadgeImageMd { get; set; } public string BadgeName { get; set; }
[JsonProperty("badge_image_lg")] [JsonProperty("badge_description")]
public string BadgeImageLg { get; set; } public string BadgeDescription { get; set; }
}
public class BadgePackProgress [JsonProperty("badge_hint")]
{ public string BadgeHint { get; set; }
[JsonProperty("completed")] [JsonProperty("badge_active_status")]
public int Completed { get; set; } public int BadgeActiveStatus { get; set; }
[JsonProperty("total")] [JsonProperty("media")]
public int Total { get; set; } public Media Media { get; set; }
}
public class BadgeLevel [JsonProperty("created_at")]
{ public string CreatedAt { get; set; }
[JsonProperty("actual_badge_id")] }
public int ActualBadgeId { get; set; }
[JsonProperty("badge_id")] public class Levels
public int BadgeId { get; set; } {
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("checkin_id")] [JsonProperty("items")]
public int CheckinId { get; set; } public IList<BadgeLevel> Items { get; set; }
}
[JsonProperty("badge_name")] public class Item
public string BadgeName { get; set; } {
[JsonProperty("user_badge_id")]
public int UserBadgeId { get; set; }
[JsonProperty("badge_description")] [JsonProperty("badge_id")]
public string BadgeDescription { get; set; } public int BadgeId { get; set; }
[JsonProperty("badge_hint")] [JsonProperty("checkin_id")]
public string BadgeHint { get; set; } public int CheckinId { get; set; }
[JsonProperty("badge_active_status")] [JsonProperty("badge_name")]
public int BadgeActiveStatus { get; set; } public string BadgeName { get; set; }
[JsonProperty("media")] [JsonProperty("badge_description")]
public Media Media { get; set; } public string BadgeDescription { get; set; }
[JsonProperty("created_at")] [JsonProperty("badge_hint")]
public string CreatedAt { get; set; } public string BadgeHint { get; set; }
}
public class Levels [JsonProperty("badge_active_status")]
{ public int BadgeActiveStatus { get; set; }
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("items")] [JsonProperty("media")]
public IList<BadgeLevel> Items { get; set; } public Media Media { get; set; }
}
public class Item [JsonProperty("created_at")]
{ public string CreatedAt { get; set; }
[JsonProperty("user_badge_id")] [JsonProperty("is_level")]
public int UserBadgeId { get; set; } public bool IsLevel { get; set; }
[JsonProperty("badge_id")] [JsonProperty("badge_type")]
public int BadgeId { get; set; } public string BadgeType { get; set; }
[JsonProperty("checkin_id")] [JsonProperty("has_badge")]
public int CheckinId { get; set; } public bool HasBadge { get; set; }
[JsonProperty("badge_name")] [JsonProperty("category_id")]
public string BadgeName { get; set; } public int CategoryId { get; set; }
[JsonProperty("badge_description")] /// <summary>
public string BadgeDescription { get; set; } /// Issue with bad json responses
/// levels might come as object levels : { ... }
/// or an empty array levels : []
/// </summary>
[JsonProperty(PropertyName = "levels")]
[JsonConverter(typeof(SingleObjectArrayConverter<Levels>))]
public Levels Levels { get; set; }
[JsonProperty("badge_hint")] [JsonProperty("badge_pack")]
public string BadgeHint { get; set; } public bool BadgePack { get; set; }
[JsonProperty("badge_active_status")] [JsonProperty("badge_pack_name")]
public int BadgeActiveStatus { get; set; } public bool BadgePackName { get; set; }
[JsonProperty("media")] [JsonProperty("badge_pack_progress")]
public Media Media { get; set; } public BadgePackProgress BadgePackProgress { get; set; }
}
[JsonProperty("created_at")] public class Response
public string CreatedAt { get; set; } {
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("is_level")] [JsonProperty("sort")]
public bool IsLevel { get; set; } public string Sort { get; set; }
[JsonProperty("badge_type")] [JsonProperty("count")]
public string BadgeType { get; set; } public int Count { get; set; }
[JsonProperty("has_badge")] [JsonProperty("items")]
public bool HasBadge { get; set; } public IList<Item> Items { get; set; }
}
[JsonProperty("category_id")] /// <summary>
public int CategoryId { get; set; } /// jsonutils.com fails to parse Untappd response for this requests
/// It fails getting the badge levels.
/// added manually.
/// </summary>
public class UserBadges : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
{
protected override string EndPointWithConfiguration { get { return "v4/user/badges{0}"; } }
/// <summary> [JsonProperty("meta")]
/// Issue with bad json responses public Meta Meta { get; set; }
/// levels might come as object levels : { ... }
/// or an empty array levels : []
/// </summary>
[JsonProperty(PropertyName = "levels")]
[JsonConverter(typeof(SingleObjectArrayConverter<Levels>))]
public Levels Levels { get; set; }
[JsonProperty("badge_pack")] [JsonProperty("notifications")]
public bool BadgePack { get; set; } [JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("badge_pack_name")] [JsonProperty("response")]
public bool BadgePackName { get; set; } public Response Response { get; set; }
}
[JsonProperty("badge_pack_progress")]
public BadgePackProgress BadgePackProgress { get; set; }
}
public class Response
{
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("sort")]
public string Sort { get; set; }
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("items")]
public IList<Item> Items { get; set; }
}
/// <summary>
/// jsonutils.com fails to parse Untappd response for this requests
/// It fails getting the badge levels.
/// added manually.
/// </summary>
public class UserBadges : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
{
protected override string EndPointWithConfiguration { get { return "v4/user/badges{0}"; } }
[JsonProperty("meta")]
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]
public Response Response { get; set; }
}
} }

View File

@@ -4,238 +4,231 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.UserDistinctBeer namespace Untappd.Net.Responses.UserDistinctBeer
{ {
public sealed class ResponseTime
{
[JsonProperty("time")]
public double Time { get; set; }
public sealed class ResponseTime [JsonProperty("measure")]
{ public string Measure { get; set; }
}
[JsonProperty("time")] public class InitTime
public double Time { get; set; } {
[JsonProperty("time")]
public double Time { get; set; }
[JsonProperty("measure")] [JsonProperty("measure")]
public string Measure { get; set; } public string Measure { get; set; }
} }
public class InitTime public class Meta
{ {
[JsonProperty("code")]
public int Code { get; set; }
[JsonProperty("time")] [JsonProperty("response_time")]
public double Time { get; set; } public ResponseTime ResponseTime { get; set; }
[JsonProperty("measure")] [JsonProperty("init_time")]
public string Measure { get; set; } public InitTime InitTime { get; set; }
} }
public class Meta public class Beer
{ {
[JsonProperty("bid")]
public int Bid { get; set; }
[JsonProperty("code")] [JsonProperty("beer_name")]
public int Code { get; set; } public string BeerName { get; set; }
[JsonProperty("response_time")] [JsonProperty("beer_label")]
public ResponseTime ResponseTime { get; set; } public string BeerLabel { get; set; }
[JsonProperty("init_time")] [JsonProperty("beer_abv")]
public InitTime InitTime { get; set; } public double BeerAbv { get; set; }
}
public class Beer [JsonProperty("beer_ibu")]
{ public int BeerIbu { get; set; }
[JsonProperty("bid")] [JsonProperty("beer_slug")]
public int Bid { get; set; } public string BeerSlug { get; set; }
[JsonProperty("beer_name")] [JsonProperty("beer_style")]
public string BeerName { get; set; } public string BeerStyle { get; set; }
[JsonProperty("beer_label")] [JsonProperty("beer_description")]
public string BeerLabel { get; set; } public string BeerDescription { get; set; }
[JsonProperty("beer_abv")] [JsonProperty("created_at")]
public double BeerAbv { get; set; } public string CreatedAt { get; set; }
[JsonProperty("beer_ibu")] [JsonProperty("auth_rating")]
public int BeerIbu { get; set; } public double AuthRating { get; set; }
[JsonProperty("beer_slug")] [JsonProperty("wish_list")]
public string BeerSlug { get; set; } public bool WishList { get; set; }
[JsonProperty("beer_style")] [JsonProperty("rating_score")]
public string BeerStyle { get; set; } public double RatingScore { get; set; }
[JsonProperty("beer_description")] [JsonProperty("rating_count")]
public string BeerDescription { get; set; } public int RatingCount { get; set; }
}
[JsonProperty("created_at")] public class Contact
public string CreatedAt { get; set; } {
[JsonProperty("twitter")]
public string Twitter { get; set; }
[JsonProperty("auth_rating")] [JsonProperty("facebook")]
public double AuthRating { get; set; } public string Facebook { get; set; }
[JsonProperty("wish_list")] [JsonProperty("instagram")]
public bool WishList { get; set; } public string Instagram { get; set; }
[JsonProperty("rating_score")] [JsonProperty("url")]
public double RatingScore { get; set; } public string Url { get; set; }
}
[JsonProperty("rating_count")] public class Location
public int RatingCount { get; set; } {
} [JsonProperty("brewery_city")]
public string BreweryCity { get; set; }
public class Contact [JsonProperty("brewery_state")]
{ public string BreweryState { get; set; }
[JsonProperty("twitter")] [JsonProperty("lat")]
public string Twitter { get; set; } public double Lat { get; set; }
[JsonProperty("facebook")] [JsonProperty("lng")]
public string Facebook { get; set; } public double Lng { get; set; }
}
[JsonProperty("instagram")] public class Brewery
public string Instagram { get; set; } {
[JsonProperty("brewery_id")]
public int BreweryId { get; set; }
[JsonProperty("url")] [JsonProperty("brewery_name")]
public string Url { get; set; } public string BreweryName { get; set; }
}
public class Location [JsonProperty("brewery_slug")]
{ public string BrewerySlug { get; set; }
[JsonProperty("brewery_city")] [JsonProperty("brewery_label")]
public string BreweryCity { get; set; } public string BreweryLabel { get; set; }
[JsonProperty("brewery_state")] [JsonProperty("country_name")]
public string BreweryState { get; set; } public string CountryName { get; set; }
[JsonProperty("lat")] [JsonProperty("contact")]
public double Lat { get; set; } public Contact Contact { get; set; }
[JsonProperty("lng")] [JsonProperty("location")]
public double Lng { get; set; } public Location Location { get; set; }
}
public class Brewery [JsonProperty("brewery_active")]
{ public int BreweryActive { get; set; }
}
[JsonProperty("brewery_id")] public class Item
public int BreweryId { get; set; } {
[JsonProperty("first_checkin_id")]
public int FirstCheckinId { get; set; }
[JsonProperty("brewery_name")] [JsonProperty("first_created_at")]
public string BreweryName { get; set; } public string FirstCreatedAt { get; set; }
[JsonProperty("brewery_slug")] [JsonProperty("recent_checkin_id")]
public string BrewerySlug { get; set; } public int RecentCheckinId { get; set; }
[JsonProperty("brewery_label")] [JsonProperty("recent_created_at")]
public string BreweryLabel { get; set; } public string RecentCreatedAt { get; set; }
[JsonProperty("country_name")] [JsonProperty("recent_created_at_timezone")]
public string CountryName { get; set; } public string RecentCreatedAtTimezone { get; set; }
[JsonProperty("contact")] [JsonProperty("rating_score")]
public Contact Contact { get; set; } public double RatingScore { get; set; }
[JsonProperty("location")] [JsonProperty("first_had")]
public Location Location { get; set; } public string FirstHad { get; set; }
[JsonProperty("brewery_active")] [JsonProperty("count")]
public int BreweryActive { get; set; } public int Count { get; set; }
}
public class Item [JsonProperty("beer")]
{ public Beer Beer { get; set; }
[JsonProperty("first_checkin_id")] [JsonProperty("brewery")]
public int FirstCheckinId { get; set; } public Brewery Brewery { get; set; }
}
[JsonProperty("first_created_at")] public class Beers
public string FirstCreatedAt { get; set; } {
[JsonProperty("sort")]
public string Sort { get; set; }
[JsonProperty("recent_checkin_id")] [JsonProperty("sort_english")]
public int RecentCheckinId { get; set; } public string SortEnglish { get; set; }
[JsonProperty("recent_created_at")] [JsonProperty("count")]
public string RecentCreatedAt { get; set; } public int Count { get; set; }
[JsonProperty("recent_created_at_timezone")] [JsonProperty("items")]
public string RecentCreatedAtTimezone { get; set; } public IList<Item> Items { get; set; }
}
[JsonProperty("rating_score")] public class UnreadCount
public double RatingScore { get; set; } {
[JsonProperty("comments")]
public int Comments { get; set; }
[JsonProperty("first_had")] [JsonProperty("toasts")]
public string FirstHad { get; set; } public int Toasts { get; set; }
[JsonProperty("count")] [JsonProperty("friends")]
public int Count { get; set; } public int Friends { get; set; }
[JsonProperty("beer")] [JsonProperty("messages")]
public Beer Beer { get; set; } public int Messages { get; set; }
[JsonProperty("brewery")] [JsonProperty("news")]
public Brewery Brewery { get; set; } public int news { get; set; }
} }
public class Beers public class Notifications
{ {
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("sort")] [JsonProperty("unread_count")]
public string Sort { get; set; } public UnreadCount UnreadCount { get; set; }
}
[JsonProperty("sort_english")] public class Response
public string SortEnglish { get; set; } {
[JsonProperty("is_search")]
public bool IsSearch { get; set; }
[JsonProperty("count")] [JsonProperty("beers")]
public int Count { get; set; } public Beers Beers { get; set; }
}
[JsonProperty("items")] public class UserDistinctBeers : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
public IList<Item> Items { get; set; } {
} protected override string EndPointWithConfiguration { get { return "v4/user/beers{0}"; } }
public class UnreadCount [JsonProperty("meta")]
{ public Meta Meta { get; set; }
[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("notifications")]
{ [JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
[JsonProperty("type")] public Notifications Notifications { get; set; }
public string Type { get; set; }
[JsonProperty("unread_count")]
public UnreadCount UnreadCount { get; set; }
}
public class Response [JsonProperty("response")]
{ public Response Response { get; set; }
}
[JsonProperty("is_search")] }
public bool IsSearch { get; set; }
[JsonProperty("beers")]
public Beers Beers { get; set; }
}
public class UserDistinctBeers : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
{
protected override string EndPointWithConfiguration { get { return "v4/user/beers{0}"; } }
[JsonProperty("meta")]
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]
public Response Response { get; set; }
}
}

View File

@@ -4,148 +4,138 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.UserFriends namespace Untappd.Net.Responses.UserFriends
{ {
public class ResponseTime
{
[JsonProperty("time")]
public double Time { get; set; }
public class ResponseTime [JsonProperty("measure")]
{ public string Measure { get; set; }
}
[JsonProperty("time")] public class InitTime
public double Time { get; set; } {
[JsonProperty("time")]
public double Time { get; set; }
[JsonProperty("measure")] [JsonProperty("measure")]
public string Measure { get; set; } public string Measure { get; set; }
} }
public class InitTime public class Meta
{ {
[JsonProperty("code")]
public int Code { get; set; }
[JsonProperty("time")] [JsonProperty("response_time")]
public double Time { get; set; } public ResponseTime ResponseTime { get; set; }
[JsonProperty("measure")] [JsonProperty("init_time")]
public string Measure { get; set; } public InitTime InitTime { get; set; }
} }
public class Meta public class UnreadCount
{ {
[JsonProperty("comments")]
public int Comments { get; set; }
[JsonProperty("code")] [JsonProperty("toasts")]
public int Code { get; set; } public int Toasts { get; set; }
[JsonProperty("response_time")] [JsonProperty("friends")]
public ResponseTime ResponseTime { get; set; } public int Friends { get; set; }
[JsonProperty("init_time")] [JsonProperty("messages")]
public InitTime InitTime { get; set; } public int Messages { get; set; }
}
public class UnreadCount [JsonProperty("news")]
{ public int News { get; set; }
}
[JsonProperty("comments")] public class Notifications
public int Comments { get; set; } {
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("toasts")] [JsonProperty("unread_count")]
public int Toasts { get; set; } public UnreadCount UnreadCount { get; set; }
}
[JsonProperty("friends")] public class User
public int Friends { get; set; } {
[JsonProperty("uid")]
public int Uid { get; set; }
[JsonProperty("messages")] [JsonProperty("user_name")]
public int Messages { get; set; } public string UserName { get; set; }
[JsonProperty("news")] [JsonProperty("location")]
public int News { get; set; } public string Location { get; set; }
}
public class Notifications [JsonProperty("bio")]
{ public string Bio { get; set; }
[JsonProperty("type")] [JsonProperty("is_supporter")]
public string Type { get; set; } public int IsSupporter { get; set; }
[JsonProperty("unread_count")] [JsonProperty("first_name")]
public UnreadCount UnreadCount { get; set; } public string FirstName { get; set; }
}
public class User [JsonProperty("last_name")]
{ public string LastName { get; set; }
[JsonProperty("uid")] [JsonProperty("relationship")]
public int Uid { get; set; } public string Relationship { get; set; }
[JsonProperty("user_name")] [JsonProperty("user_avatar")]
public string UserName { get; set; } public string UserAvatar { get; set; }
}
[JsonProperty("location")] public class MutualFriends
public string Location { get; set; } {
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("bio")] [JsonProperty("items")]
public string Bio { get; set; } public IList<object> Items { get; set; }
}
[JsonProperty("is_supporter")] public class Item
public int IsSupporter { get; set; } {
[JsonProperty("friendship_hash")]
public string FriendshipHash { get; set; }
[JsonProperty("first_name")] [JsonProperty("created_at")]
public string FirstName { get; set; } public string CreatedAt { get; set; }
[JsonProperty("last_name")] [JsonProperty("user")]
public string LastName { get; set; } public User User { get; set; }
[JsonProperty("relationship")] [JsonProperty("mutual_friends")]
public string Relationship { get; set; } public MutualFriends MutualFriends { get; set; }
}
[JsonProperty("user_avatar")] public class Response
public string UserAvatar { get; set; } {
} [JsonProperty("count")]
public int Count { get; set; }
public class MutualFriends [JsonProperty("items")]
{ public IList<Item> Items { get; set; }
}
[JsonProperty("count")] public class UserFriends : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
public int Count { get; set; } {
protected override string EndPointWithConfiguration { get { return "v4/user/friends{0}"; } }
[JsonProperty("items")] [JsonProperty("meta")]
public IList<object> Items { get; set; } public Meta Meta { get; set; }
}
public class Item [JsonProperty("notifications")]
{ [JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("friendship_hash")] [JsonProperty("response")]
public string FriendshipHash { get; set; } public Response Response { get; set; }
}
[JsonProperty("created_at")] }
public string CreatedAt { get; set; }
[JsonProperty("user")]
public User User { get; set; }
[JsonProperty("mutual_friends")]
public MutualFriends MutualFriends { get; set; }
}
public class Response
{
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("items")]
public IList<Item> Items { get; set; }
}
public class UserFriends : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
{
protected override string EndPointWithConfiguration { get { return "v4/user/friends{0}"; } }
[JsonProperty("meta")]
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]
public Response Response { get; set; }
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -4,229 +4,216 @@ using Untappd.Net.Request;
namespace Untappd.Net.Responses.UserWishlist namespace Untappd.Net.Responses.UserWishlist
{ {
public class ResponseTime
{
[JsonProperty("time")]
public double Time { get; set; }
public class ResponseTime [JsonProperty("measure")]
{ public string Measure { get; set; }
}
[JsonProperty("time")] public class InitTime
public double Time { get; set; } {
[JsonProperty("time")]
public double Time { get; set; }
[JsonProperty("measure")] [JsonProperty("measure")]
public string Measure { get; set; } public string Measure { get; set; }
} }
public class InitTime public class Meta
{ {
[JsonProperty("code")]
public int Code { get; set; }
[JsonProperty("time")] [JsonProperty("response_time")]
public double Time { get; set; } public ResponseTime ResponseTime { get; set; }
[JsonProperty("measure")] [JsonProperty("init_time")]
public string Measure { get; set; } public InitTime InitTime { get; set; }
} }
public class Meta public class UnreadCount
{ {
[JsonProperty("comments")]
public int Comments { get; set; }
[JsonProperty("code")] [JsonProperty("toasts")]
public int Code { get; set; } public int Toasts { get; set; }
[JsonProperty("response_time")] [JsonProperty("friends")]
public ResponseTime ResponseTime { get; set; } public int Friends { get; set; }
[JsonProperty("init_time")] [JsonProperty("messages")]
public InitTime InitTime { get; set; } public int Messages { get; set; }
}
public class UnreadCount [JsonProperty("news")]
{ public int News { get; set; }
}
[JsonProperty("comments")] public class Notifications
public int Comments { get; set; } {
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("toasts")] [JsonProperty("unread_count")]
public int Toasts { get; set; } public UnreadCount UnreadCount { get; set; }
}
[JsonProperty("friends")] public class Beer
public int Friends { get; set; } {
[JsonProperty("bid")]
public int Bid { get; set; }
[JsonProperty("messages")] [JsonProperty("beer_name")]
public int Messages { get; set; } public string BeerName { get; set; }
[JsonProperty("news")] [JsonProperty("beer_label")]
public int News { get; set; } public string BeerLabel { get; set; }
}
public class Notifications [JsonProperty("beer_abv")]
{ public double BeerAbv { get; set; }
[JsonProperty("type")] [JsonProperty("beer_ibu")]
public string Type { get; set; } public int BeerIbu { get; set; }
[JsonProperty("unread_count")] [JsonProperty("beer_slug")]
public UnreadCount UnreadCount { get; set; } public string BeerSlug { get; set; }
}
public class Beer [JsonProperty("beer_description")]
{ public string BeerDescription { get; set; }
[JsonProperty("bid")] [JsonProperty("is_in_production")]
public int Bid { get; set; } public int IsInProduction { get; set; }
[JsonProperty("beer_name")] [JsonProperty("beer_style")]
public string BeerName { get; set; } public string BeerStyle { get; set; }
[JsonProperty("beer_label")] [JsonProperty("created_at")]
public string BeerLabel { get; set; } public string CreatedAt { get; set; }
[JsonProperty("beer_abv")] [JsonProperty("auth_rating")]
public double BeerAbv { get; set; } public double AuthRating { get; set; }
[JsonProperty("beer_ibu")] [JsonProperty("rating_score")]
public int BeerIbu { get; set; } public double RatingScore { get; set; }
[JsonProperty("beer_slug")] [JsonProperty("rating_count")]
public string BeerSlug { get; set; } public int RatingCount { get; set; }
[JsonProperty("beer_description")] [JsonProperty("wish_list")]
public string BeerDescription { get; set; } public bool WishList { get; set; }
}
[JsonProperty("is_in_production")] public class Contact
public int IsInProduction { get; set; } {
[JsonProperty("twitter")]
public string Twitter { get; set; }
[JsonProperty("beer_style")] [JsonProperty("facebook")]
public string BeerStyle { get; set; } public string Facebook { get; set; }
[JsonProperty("created_at")] [JsonProperty("instagram")]
public string CreatedAt { get; set; } public string Instagram { get; set; }
[JsonProperty("auth_rating")] [JsonProperty("url")]
public double AuthRating { get; set; } public string Url { get; set; }
}
[JsonProperty("rating_score")] public class Location
public double RatingScore { get; set; } {
[JsonProperty("brewery_city")]
public string BreweryCity { get; set; }
[JsonProperty("rating_count")] [JsonProperty("brewery_state")]
public int RatingCount { get; set; } public string BreweryState { get; set; }
[JsonProperty("wish_list")] [JsonProperty("lat")]
public bool WishList { get; set; } public double Lat { get; set; }
}
public class Contact [JsonProperty("lng")]
{ public double Lng { get; set; }
}
[JsonProperty("twitter")] public class Brewery
public string Twitter { get; set; } {
[JsonProperty("brewery_id")]
public int BreweryId { get; set; }
[JsonProperty("facebook")] [JsonProperty("brewery_name")]
public string Facebook { get; set; } public string BreweryName { get; set; }
[JsonProperty("instagram")] [JsonProperty("brewery_slug")]
public string Instagram { get; set; } public string BrewerySlug { get; set; }
[JsonProperty("url")] [JsonProperty("brewery_label")]
public string Url { get; set; } public string BreweryLabel { get; set; }
}
public class Location [JsonProperty("country_name")]
{ public string CountryName { get; set; }
[JsonProperty("brewery_city")] [JsonProperty("contact")]
public string BreweryCity { get; set; } public Contact Contact { get; set; }
[JsonProperty("brewery_state")] [JsonProperty("location")]
public string BreweryState { get; set; } public Location Location { get; set; }
[JsonProperty("lat")] [JsonProperty("brewery_active")]
public double Lat { get; set; } public int BreweryActive { get; set; }
}
[JsonProperty("lng")] public class Item
public double Lng { get; set; } {
} [JsonProperty("created_at")]
public string CreatedAt { get; set; }
public class Brewery [JsonProperty("beer")]
{ public Beer Beer { get; set; }
[JsonProperty("brewery_id")] [JsonProperty("brewery")]
public int BreweryId { get; set; } public Brewery Brewery { get; set; }
[JsonProperty("brewery_name")] [JsonProperty("friends")]
public string BreweryName { get; set; } public IList<object> Friends { get; set; }
}
[JsonProperty("brewery_slug")] public class Beers
public string BrewerySlug { get; set; } {
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("brewery_label")] [JsonProperty("items")]
public string BreweryLabel { get; set; } public IList<Item> Items { get; set; }
}
[JsonProperty("country_name")] public class Response
public string CountryName { get; set; } {
[JsonProperty("sort")]
public string Sort { get; set; }
[JsonProperty("contact")] [JsonProperty("sort_english")]
public Contact Contact { get; set; } public string SortEnglish { get; set; }
[JsonProperty("location")] [JsonProperty("type_id")]
public Location Location { get; set; } public int TypeId { get; set; }
[JsonProperty("brewery_active")] [JsonProperty("beers")]
public int BreweryActive { get; set; } public Beers Beers { get; set; }
} }
public class Item public class UserWishList : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
{ {
protected override string EndPointWithConfiguration { get { return "/v4/user/wishlist{0}"; } }
[JsonProperty("created_at")] [JsonProperty("meta")]
public string CreatedAt { get; set; } public Meta Meta { get; set; }
[JsonProperty("beer")] [JsonProperty("notifications")]
public Beer Beer { get; set; } [JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("brewery")] [JsonProperty("response")]
public Brewery Brewery { get; set; } public Response Response { get; set; }
}
[JsonProperty("friends")]
public IList<object> Friends { get; set; }
}
public class Beers
{
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("items")]
public IList<Item> Items { get; set; }
}
public class Response
{
[JsonProperty("sort")]
public string Sort { get; set; }
[JsonProperty("sort_english")]
public string SortEnglish { get; set; }
[JsonProperty("type_id")]
public int TypeId { get; set; }
[JsonProperty("beers")]
public Beers Beers { get; set; }
}
public class UserWishList : BasicRequest, IAuthenticatedRequest, IUnAuthenticatedRequest
{
protected override string EndPointWithConfiguration { get { return "/v4/user/wishlist{0}"; } }
[JsonProperty("meta")]
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]
public Response Response { get; set; }
}
} }

File diff suppressed because it is too large Load Diff

View File

@@ -3,44 +3,44 @@ using Newtonsoft.Json;
namespace Untappd.Net namespace Untappd.Net
{ {
/// <summary> /// <summary>
/// Created to fix bad json results. /// Created to fix bad json results.
/// Object expected but sometimes it comes as an empty array. /// Object expected but sometimes it comes as an empty array.
/// ///
/// Deserialize json as T if json schema defines an object. /// Deserialize json as T if json schema defines an object.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
internal sealed class SingleObjectArrayConverter<T> : JsonConverter internal sealed class SingleObjectArrayConverter<T> : JsonConverter
where T : new() where T : new()
{ {
public override bool CanConvert(Type objectType) public override bool CanConvert(Type objectType)
{ {
return true; return true;
}
} public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
var retval = new object();
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) switch (reader.TokenType)
{ {
var retval = new object(); case JsonToken.StartObject:
var instance = (T)serializer.Deserialize(reader, typeof(T));
retval = instance;
break;
switch (reader.TokenType) case JsonToken.StartArray:
{ reader.Read();
case JsonToken.StartObject: retval = new T();
var instance = (T)serializer.Deserialize(reader, typeof(T)); break;
retval = instance; }
break;
case JsonToken.StartArray:
reader.Read();
retval = new T();
break;
}
return retval; return retval;
} }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
} }

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" /> <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="RestSharp" version="105.0.1" targetFramework="net45" /> <package id="RestSharp" version="105.0.1" targetFramework="net45" />
</packages> </packages>