add SendActions method
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using PocketSharp.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -9,6 +10,20 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
public partial class PocketClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Sends multiple actions in one request.
|
||||
/// See: http://getpocket.com/developer/docs/v3/modify
|
||||
/// </summary>
|
||||
/// <param name="actions">The actions.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> SendActions(List<PocketAction> actions, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await Send(actions, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Archives the specified item.
|
||||
/// </summary>
|
||||
@@ -147,7 +162,7 @@ namespace PocketSharp
|
||||
/// <returns></returns>
|
||||
protected async Task<bool> SendDefault(CancellationToken cancellationToken, int itemID, string action)
|
||||
{
|
||||
return await Send(new ActionParameter()
|
||||
return await Send(new PocketAction()
|
||||
{
|
||||
Action = action,
|
||||
ID = itemID
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace PocketSharp
|
||||
/// <returns></returns>
|
||||
protected async Task<bool> SendTags(CancellationToken cancellationToken, int itemID, string action, string[] tags)
|
||||
{
|
||||
return await Send(new ActionParameter()
|
||||
return await Send(new PocketAction()
|
||||
{
|
||||
Action = action,
|
||||
ID = itemID,
|
||||
|
||||
+26
-4
@@ -5,10 +5,10 @@ using System.Runtime.Serialization;
|
||||
namespace PocketSharp.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// All parameters which can be passed for a modify action
|
||||
/// All parameters which can be passed for a send action
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
internal class ActionParameter
|
||||
public class PocketAction
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the action.
|
||||
@@ -20,7 +20,7 @@ namespace PocketSharp.Models
|
||||
public string Action { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ID.
|
||||
/// Gets or sets the PocketItem ID.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The ID.
|
||||
@@ -28,6 +28,24 @@ namespace PocketSharp.Models
|
||||
[DataMember(Name = "item_id")]
|
||||
public int ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the URI (for adding a new item).
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The URI.
|
||||
/// </value>
|
||||
[DataMember(Name = "url")]
|
||||
public Uri Uri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Title (for adding a new item).
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The Title.
|
||||
/// </value>
|
||||
[DataMember(Name = "title")]
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time.
|
||||
/// </summary>
|
||||
@@ -71,7 +89,7 @@ namespace PocketSharp.Models
|
||||
/// Converts this instance to a parameter list.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, object> Convert()
|
||||
internal Dictionary<string, object> Convert()
|
||||
{
|
||||
Dictionary<string, object> parameters = new Dictionary<string, object>
|
||||
{
|
||||
@@ -87,6 +105,10 @@ namespace PocketSharp.Models
|
||||
parameters.Add("old_tag", OldTag);
|
||||
if (NewTag != null)
|
||||
parameters.Add("new_tag", NewTag);
|
||||
if (Title != null)
|
||||
parameters.Add("title", Title);
|
||||
if (Uri != null)
|
||||
parameters.Add("uri", Uri.ToString());
|
||||
|
||||
return parameters;
|
||||
}
|
||||
@@ -214,7 +214,7 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="actionParameters">The action parameters.</param>
|
||||
/// <returns></returns>
|
||||
internal async Task<bool> Send(List<ActionParameter> actionParameters, CancellationToken cancellationToken)
|
||||
internal async Task<bool> Send(List<PocketAction> actionParameters, CancellationToken cancellationToken)
|
||||
{
|
||||
List<Dictionary<string, object>> actionParamList = new List<Dictionary<string, object>>();
|
||||
|
||||
@@ -238,9 +238,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="actionParameter">The action parameter.</param>
|
||||
/// <returns></returns>
|
||||
internal async Task<bool> Send(ActionParameter actionParameter, CancellationToken cancellationToken)
|
||||
internal async Task<bool> Send(PocketAction actionParameter, CancellationToken cancellationToken)
|
||||
{
|
||||
return await Send(new List<ActionParameter>() { actionParameter }, cancellationToken);
|
||||
return await Send(new List<PocketAction>() { actionParameter }, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user