Get, Update and Delete categories
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,15 @@ namespace FeedlySharp
|
||||
}
|
||||
}
|
||||
|
||||
if (responseString == "[]")
|
||||
{
|
||||
return new T();
|
||||
}
|
||||
if ((new string[] { "", "{}" }).Contains(responseString))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return DeserializeJson<T>(responseString);
|
||||
}
|
||||
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user