simplify Put;

This commit is contained in:
2013-06-24 20:02:01 +02:00
parent 3470c7bb80
commit 316db90df3
3 changed files with 33 additions and 9 deletions
+2 -1
View File
@@ -16,7 +16,8 @@ namespace PocketSharp.Console
// this consumerKey is just for demonstration purposes
// please create your own application and retrieve it's key. It's a 1-step process ;-)
PocketClient client = new PocketClient(
consumerKey: "15396-f6f92101d72c8e270a6c9bb3"
consumerKey: "15396-f6f92101d72c8e270a6c9bb3",
accessCode: ""
);
//Uri redirect = client.Authenticate(new Uri("http://example.com"));
+10 -4
View File
@@ -5,14 +5,20 @@ namespace PocketSharp
{
public partial class PocketClient
{
/// <summary>
/// Archives the specified item ID.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
public bool Archive(int itemID)
{
List<ActionParameter> actions = new List<ActionParameter>()
{
new ActionParameter() { Action = "archive", ID = itemID }
ActionParameter action = new ActionParameter()
{
Action = "archive",
ID = itemID
};
return Put<Modify>("send", actions).Status == 1;
return Put<Modify>("send", action).Status == 1;
}
}
}
+21 -4
View File
@@ -133,7 +133,7 @@ namespace PocketSharp
/// <summary>
/// Fetches/Updates a typed resource
/// Fetches a typed resource
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="method">Requested method (path after /v3/)</param>
@@ -165,6 +165,13 @@ namespace PocketSharp
}
/// <summary>
/// Puts/Updates a typed resource
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="method">Requested method (path after /v3/)</param>
/// <param name="actions">Additional action parameters</param>
/// <returns></returns>
protected T Put<T>(string method, List<ActionParameter> actions) where T : class, new()
{
// put requests only with authentification
@@ -174,13 +181,23 @@ namespace PocketSharp
{
Actions = actions
};
//var x = (parameters.Convert());
return Get<T>(method, parameters.Convert());
}
/// <summary>
/// Puts/Updates a typed resource
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="method">Requested method (path after /v3/)</param>
/// <param name="action">action parameter</param>
/// <returns></returns>
protected T Put<T>(string method, ActionParameter action) where T : class, new()
{
return Put<T>(method, new List<ActionParameter>() { action });
}
/// <summary>
/// Validates the response.
/// </summary>