diff --git a/PocketSharp/IPocketClient.cs b/PocketSharp/IPocketClient.cs
index 6c5fec3..d0d3f34 100644
--- a/PocketSharp/IPocketClient.cs
+++ b/PocketSharp/IPocketClient.cs
@@ -1,8 +1,5 @@
using RestSharp;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
namespace PocketSharp
{
diff --git a/PocketSharp/PocketClient.cs b/PocketSharp/PocketClient.cs
index 96773ba..ceef569 100644
--- a/PocketSharp/PocketClient.cs
+++ b/PocketSharp/PocketClient.cs
@@ -1,11 +1,91 @@
-using System;
+using RestSharp;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PocketSharp
{
- public class PocketClient
+ public partial class PocketClient : IPocketClient
+ {
+ ///
+ /// REST client used for the API communication
+ ///
+ private readonly RestClient _restClient;
+
+ ///
+ /// default base URL for the API, which is used, when no baseURL is delivered
+ ///
+ private static Uri defaultUrl = new Uri("https://getpocket.com/v3/");
+
+ ///
+ /// base URL for the API
+ ///
+ public Uri BaseUrl { get; set; }
+
+ ///
+ /// Accessor for the Pocket API key
+ /// see: http://getpocket.com/developer
+ ///
+ public string ConsumerKey { get; set; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The API key.
+ public PocketClient(string consumerKey)
+ : this(defaultUrl, consumerKey) { }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The base URL.
+ /// The API key.
+ public PocketClient(Uri baseUrl, string consumerKey)
{
+ // assign public properties
+ BaseUrl = baseUrl;
+ ConsumerKey = consumerKey;
+
+ // initialize REST client
+ _restClient = new RestClient
+ {
+ BaseUrl = baseUrl.ToString()
+ };
+
+ // add default parameters to each request
+ _restClient.AddDefaultParameter("consumer_key", ConsumerKey);
+
+ // defines the response format (according to the Pocket docs)
+ _restClient.AddDefaultHeader("X-Accept", "application/json");
+
+ // custom JSON deserializer (ServiceStack.Text)
+ _restClient.AddHandler("application/json", new JsonDeserializer());
}
+
+
+ ///
+ /// Makes a HTTP REST request to the API
+ ///
+ /// The request.
+ ///
+ public IRestResponse Request(RestRequest request)
+ {
+ return _restClient.Execute(request);
+ }
+
+
+ ///
+ /// Makes a typed HTTP REST request to the API
+ ///
+ ///
+ /// The request.
+ ///
+ public T Request(RestRequest request) where T : new()
+ {
+ var response = _restClient.Execute(request);
+
+ return response.Data;
+ }
+ }
}