Merge pull request #33 from tparnell8/master

json serialization fixes
This commit is contained in:
Tommy Parnell
2015-05-02 22:03:51 -04:00
6 changed files with 27 additions and 2 deletions

1
.gitignore vendored
View File

@@ -10,6 +10,7 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
**/.settings
# Build results
[Dd]ebug/
[Dd]ebugPublic/

View File

@@ -46,6 +46,17 @@ var t = new Repository().Get<ActivityFeed>(ts);
```
For Actions (usually post requests). Note: Actions return a dynamic object. Usually these responses are not needed, and you should still be able to use the dynamic object's data. If strong typed returns is required feel free to file an issue. However we don't predict people will really need to care about the returns of these actions.
```csharp
var ts = new AuthenticatedUntappdCredentials("token", "key", "secret");
var checkin = new CheckIn("-5", "EST", 1044097) { Shout = "Awesome Brew", Rating = 4 };
var response = repository.Post(ts, checkin);
```
## Contributing
* Everyone is welcome to contribute!

View File

@@ -7,6 +7,7 @@ using RestSharp;
using Untappd.Net.Client;
using Untappd.Net.Request;
using Untappd.Net.Responses.BeerInfo;
using Untappd.Net.Responses.Actions;
namespace Untappd.Net.UnitTests.Request
{
@@ -54,6 +55,15 @@ namespace Untappd.Net.UnitTests.Request
repository.GetAsync<BeerInfo>(mockAuthCreds.Object, "awesome", bodyParam).Wait();
request.Verify(a => a.AddParameter("key", "value"));
request.Verify(a => a.AddParameter("access_token", "accessToken"));
mockAuthCreds.Setup(a => a.AccessToken).Returns("PostaccessToken");
var checkin = new CheckIn("-5", "EST", 1044097) { Shout = "Awesome Brew", Rating = 4 };
repository.Post(mockAuthCreds.Object, checkin);
request.Verify(a => a.AddParameter("access_token", "PostaccessToken"));
mockAuthCreds.Setup(a => a.AccessToken).Returns("PostAsyncaccessToken");
repository.PostAsync(mockAuthCreds.Object, checkin).Wait();
request.Verify(a => a.AddParameter("access_token", "PostAsyncaccessToken"));
}
[Test]

View File

@@ -331,7 +331,7 @@ namespace Untappd.Net.Responses.Feeds.ActivityFeed
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("auth_toast")]
[JsonProperty("auth_toast", NullValueHandling = NullValueHandling.Ignore)]
public bool AuthToast { get; set; }
[JsonProperty("items")]
@@ -516,6 +516,7 @@ namespace Untappd.Net.Responses.Feeds.ActivityFeed
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]

View File

@@ -348,7 +348,7 @@ namespace Untappd.Net.Responses.Feeds.UserActivityFeed
[JsonProperty("count")]
public int Count { get; set; }
[JsonProperty("auth_toast")]
[JsonProperty("auth_toast", NullValueHandling = NullValueHandling.Ignore)]
public bool AuthToast { get; set; }
[JsonProperty("items")]
@@ -483,6 +483,7 @@ namespace Untappd.Net.Responses.Feeds.UserActivityFeed
public Meta Meta { get; set; }
[JsonProperty("notifications")]
[JsonConverter(typeof(SingleObjectArrayConverter<Notifications>))]
public Notifications Notifications { get; set; }
[JsonProperty("response")]

View File

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