Get, Update and Delete categories

This commit is contained in:
2014-11-18 22:38:41 +01:00
parent 8c38b047f9
commit 5c6dae63f7
4 changed files with 58 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
using FeedlySharp.Models;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace FeedlySharp
{
public partial class FeedlyClient
{
public async Task<List<FeedlyCategory>> GetCategories(CancellationToken cancellationToken = default(CancellationToken))
{
return await Client.AuthRequest<List<FeedlyCategory>>(HttpMethod.Get, "v3/categories", null, cancellationToken);
}
public async Task UpdateCategory(string id, string label, CancellationToken cancellationToken = default(CancellationToken))
{
await Client.AuthRequest<FeedlyUser>(HttpMethod.Post, String.Format("v3/categories/{0}", id), new Dictionary<string, string>()
{
{ "label", label }
}, cancellationToken);
}
public async Task DeleteCategory(string id, CancellationToken cancellationToken = default(CancellationToken))
{
await Client.AuthRequest<FeedlyUser>(HttpMethod.Delete, String.Format("v3/categories/{0}", id), null, cancellationToken);
}
}
}
+9
View File
@@ -88,6 +88,15 @@ namespace FeedlySharp
}
}
if (responseString == "[]")
{
return new T();
}
if ((new string[] { "", "{}" }).Contains(responseString))
{
return null;
}
return DeserializeJson<T>(responseString);
}
+2
View File
@@ -37,10 +37,12 @@
<Compile Include="Extensions\JsonExtensions.cs" />
<Compile Include="Extensions\UriExtensions.cs" />
<Compile Include="FeedlyClient.Auth.cs" />
<Compile Include="FeedlyClient.Categories.cs" />
<Compile Include="FeedlyClient.cs" />
<Compile Include="FeedlyClient.User.cs" />
<Compile Include="FeedlyHttpClient.cs" />
<Compile Include="FeedlySharpException.cs" />
<Compile Include="Models\FeedlyCategory.cs" />
<Compile Include="Models\FeedlyUser.cs" />
<Compile Include="Models\Responses.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+14
View File
@@ -0,0 +1,14 @@
using Newtonsoft.Json;
using System;
namespace FeedlySharp.Models
{
public class FeedlyCategory
{
public string Id { get; set; }
public string Label { get; set; }
public bool IsGlobal { get; set; }
}
}