diff --git a/PocketSharp/Components/Add.cs b/PocketSharp/Components/Add.cs
new file mode 100644
index 0000000..274f0f4
--- /dev/null
+++ b/PocketSharp/Components/Add.cs
@@ -0,0 +1,44 @@
+using PocketSharp.Models;
+using System;
+using System.Collections.Generic;
+
+namespace PocketSharp
+{
+ ///
+ /// PocketClient
+ ///
+ public partial class PocketClient
+ {
+ ///
+ /// Adds a new item to pocket
+ ///
+ /// The URL of the item you want to save
+ /// A comma-separated list of tags to apply to the item
+ /// This can be included for cases where an item does not have a title, which is typical for image or PDF URLs. If Pocket detects a title from the content of the page, this parameter will be ignored.
+ /// If you are adding Pocket support to a Twitter client, please send along a reference to the tweet status id. This allows Pocket to show the original tweet alongside the article.
+ ///
+ public PocketItem Add(Uri uri, string[] tags = null, string title = null, string tweetID = null)
+ {
+ ExpectAuthentification();
+ AddParameters parameters = new AddParameters()
+ {
+ Uri = uri,
+ Tags = tags,
+ Title = title,
+ TweetID = tweetID
+ };
+ return Get("add", parameters.Convert()).Item;
+ }
+
+
+ ///
+ /// Adds a new item to pocket
+ ///
+ /// The URL of the item you want to save
+ ///
+ public PocketItem Add(Uri uri)
+ {
+ return Add(uri, null, null, null);
+ }
+ }
+}
diff --git a/PocketSharp/Components/Modify.cs b/PocketSharp/Components/Modify.cs
index ecedf82..094c589 100644
--- a/PocketSharp/Components/Modify.cs
+++ b/PocketSharp/Components/Modify.cs
@@ -15,7 +15,7 @@ namespace PocketSharp
///
public bool Archive(int itemID)
{
- return PutAction(itemID, "archive");
+ return PutSendAction(itemID, "archive");
}
@@ -59,7 +59,7 @@ namespace PocketSharp
///
public bool Unarchive(int itemID)
{
- return PutAction(itemID, "readd");
+ return PutSendAction(itemID, "readd");
}
@@ -81,7 +81,7 @@ namespace PocketSharp
///
public bool Favorite(int itemID)
{
- return PutAction(itemID, "favorite");
+ return PutSendAction(itemID, "favorite");
}
@@ -103,7 +103,7 @@ namespace PocketSharp
///
public bool Unfavorite(int itemID)
{
- return PutAction(itemID, "unfavorite");
+ return PutSendAction(itemID, "unfavorite");
}
@@ -125,7 +125,7 @@ namespace PocketSharp
///
public bool Delete(int itemID)
{
- return PutAction(itemID, "delete");
+ return PutSendAction(itemID, "delete");
}
diff --git a/PocketSharp/Models/Parameters/AddParameters.cs b/PocketSharp/Models/Parameters/AddParameters.cs
new file mode 100644
index 0000000..beea8c0
--- /dev/null
+++ b/PocketSharp/Models/Parameters/AddParameters.cs
@@ -0,0 +1,35 @@
+using RestSharp;
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.Serialization;
+
+namespace PocketSharp.Models
+{
+ public class AddParameters : ParameterBase
+ {
+ public Uri Uri { get; set; }
+
+ public string Title { get; set; }
+
+ public string[] Tags { get; set; }
+
+ public string TweetID { get; set; }
+
+ public List Convert()
+ {
+ List parameters = new List();
+
+ if (Uri != null)
+ parameters.Add(CreateParam("url", Uri.ToString()));
+ if (Title != null)
+ parameters.Add(CreateParam("title", Title));
+ if (Tags != null)
+ parameters.Add(CreateParam("tags", String.Join(",", Tags)));
+ if (TweetID != null)
+ parameters.Add(CreateParam("tweet_id", TweetID));
+
+ return parameters;
+ }
+ }
+}
diff --git a/PocketSharp/Models/Response/Add.cs b/PocketSharp/Models/Response/Add.cs
new file mode 100644
index 0000000..8e3499b
--- /dev/null
+++ b/PocketSharp/Models/Response/Add.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+namespace PocketSharp.Models
+{
+ [DataContract]
+ class Add : ResponseBase
+ {
+ [DataMember]
+ public PocketItem Item { get; set; }
+ }
+}
diff --git a/PocketSharp/Models/Response/Modify.cs b/PocketSharp/Models/Response/Modify.cs
index 1361472..d064b62 100644
--- a/PocketSharp/Models/Response/Modify.cs
+++ b/PocketSharp/Models/Response/Modify.cs
@@ -9,8 +9,5 @@ namespace PocketSharp.Models
{
[DataMember(Name = "action_results")]
public bool[] ActionResults { get; set; }
-
- [DataMember(Name = "status")]
- public int Status { get; set; }
}
}
diff --git a/PocketSharp/Models/Response/ResponseBase.cs b/PocketSharp/Models/Response/ResponseBase.cs
index 16ab4f6..2e65e69 100644
--- a/PocketSharp/Models/Response/ResponseBase.cs
+++ b/PocketSharp/Models/Response/ResponseBase.cs
@@ -1,12 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.Serialization;
using System.Text;
namespace PocketSharp.Models
{
+ [DataContract]
class ResponseBase
{
+ [DataMember(Name = "status")]
public bool Status { get; set; }
}
}
diff --git a/PocketSharp/PocketClient.cs b/PocketSharp/PocketClient.cs
index f851b94..cfb17a9 100644
--- a/PocketSharp/PocketClient.cs
+++ b/PocketSharp/PocketClient.cs
@@ -183,54 +183,27 @@ namespace PocketSharp
}
- ///
- /// Puts/Updates a typed resource
- ///
- ///
- /// Requested method (path after /v3/)
- /// Additional action parameters
- ///
- protected T Put(string method, List actions) where T : class, new()
- {
- // put requests only with authentification
- ExpectAuthentification();
-
- ModifyParameters parameters = new ModifyParameters()
- {
- Actions = actions
- };
- return Get(method, parameters.Convert());
- }
-
-
- ///
- /// Puts/Updates a typed resource
- ///
- ///
- /// Requested method (path after /v3/)
- /// action parameter
- ///
- protected T Put(string method, ActionParameter action) where T : class, new()
- {
- return Put(method, new List() { action });
- }
-
-
///
/// Puts an action
///
/// The item ID.
/// The action.
///
- protected bool PutAction(int itemID, string action)
+ protected bool PutSendAction(int itemID, string action)
{
- ActionParameter actionParam = new ActionParameter()
+ ModifyParameters parameters = new ModifyParameters()
{
- Action = action,
- ID = itemID
+ Actions = new List()
+ {
+ new ActionParameter()
+ {
+ Action = action,
+ ID = itemID
+ }
+ }
};
- return Put("send", actionParam).Status == 1;
+ return Get("send", parameters.Convert()).Status;
}
diff --git a/PocketSharp/PocketSharp.csproj b/PocketSharp/PocketSharp.csproj
index 4458ea9..4ab0366 100644
--- a/PocketSharp/PocketSharp.csproj
+++ b/PocketSharp/PocketSharp.csproj
@@ -50,6 +50,7 @@
+
@@ -57,9 +58,11 @@
+
+