fix json parsing for auth; fix cloud urls; generate TimeSpan from expires_in
This commit is contained in:
@@ -27,6 +27,28 @@ namespace FeedlySharp.Extensions
|
||||
|
||||
|
||||
|
||||
public class TimeSpanConverter : JsonConverter
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WriteValue(((TimeSpan)value).TotalSeconds);
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
double doubleVal;
|
||||
bool isSuccess = Double.TryParse(reader.Value.ToString(), out doubleVal);
|
||||
return reader.Value == null || !isSuccess ? default(TimeSpan) : TimeSpan.FromSeconds(doubleVal);
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType == typeof(TimeSpan);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class UnixDateTimeConverter : DateTimeConverterBase
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace FeedlySharp
|
||||
|
||||
private readonly string RedirectUri;
|
||||
|
||||
private string CloudUri { get { return GetCloudUri(CloudEnvironment.Production); } }
|
||||
private string CloudUri { get { return GetCloudUri(Environment); } }
|
||||
|
||||
private FeedlyHttpClient Client { get; set; }
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using FeedlySharp.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
namespace FeedlySharp.Models
|
||||
{
|
||||
@@ -14,16 +16,22 @@ namespace FeedlySharp.Models
|
||||
}
|
||||
|
||||
|
||||
[JsonObject]
|
||||
public class AccessTokenResponse
|
||||
{
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("access_token")]
|
||||
public string AccessToken { get; set; }
|
||||
|
||||
public int ExpiresIn { get; set; }
|
||||
[JsonProperty("expires_in")]
|
||||
[JsonConverter(typeof(TimeSpanConverter))]
|
||||
public TimeSpan ExpiresIn { get; set; }
|
||||
|
||||
[JsonProperty("refresh_token")]
|
||||
public string RefreshToken { get; set; }
|
||||
|
||||
[JsonProperty("plan")]
|
||||
public FeedlyUserAccountPlan UserAccountPlan { get; set; }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user