diff --git a/PocketSharp.Console/Program.cs b/PocketSharp.Console/Program.cs
index a6589cd..010fa8b 100644
--- a/PocketSharp.Console/Program.cs
+++ b/PocketSharp.Console/Program.cs
@@ -15,15 +15,17 @@ namespace PocketSharp.Console
// please create your own application and retrieve it's key. It's a 1-step process ;-)
PocketClient client = new PocketClient("15396-f6f92101d72c8e270a6c9bb3");
- client.Test();
+ //client.Test();
- System.Console.WriteLine(client.Test2());
+ //System.Console.WriteLine(client.Test2());
- System.Console.WriteLine("---------------------------------");
+ //System.Console.WriteLine("---------------------------------");
- var result = client.Test3();
+ //var result = client.Test3();
- System.Console.WriteLine(string.Format("Code: {0}, Username: {1}", result.Code, result.Username));
+ //System.Console.WriteLine(string.Format("Code: {0}, Username: {1}", result.Code, result.Username));
+
+ client.Test4("a85134a7-243c-6656-ab82-97c901");
System.Console.ReadKey();
}
diff --git a/PocketSharp/IPocketClient.cs b/PocketSharp/IPocketClient.cs
index 49b01c0..91bd6d4 100644
--- a/PocketSharp/IPocketClient.cs
+++ b/PocketSharp/IPocketClient.cs
@@ -16,6 +16,11 @@ namespace PocketSharp
///
string ConsumerKey { get; set; }
+ ///
+ /// Returns all associated data from the last request
+ ///
+ IRestResponse LastRequestData { get; }
+
///
/// Makes a HTTP REST request to the API
///
diff --git a/PocketSharp/PocketClient.cs b/PocketSharp/PocketClient.cs
index f0b4970..ea78dc1 100644
--- a/PocketSharp/PocketClient.cs
+++ b/PocketSharp/PocketClient.cs
@@ -1,6 +1,7 @@
using PocketSharp.Models.Authentification;
using RestSharp;
using System;
+using System.Net;
namespace PocketSharp
{
@@ -27,6 +28,11 @@ namespace PocketSharp
///
public string ConsumerKey { get; set; }
+ ///
+ /// Returns all associated data from the last request
+ ///
+ public IRestResponse LastRequestData { get; private set; }
+
///
/// Code retrieved on authentification
///
@@ -38,7 +44,6 @@ namespace PocketSharp
protected string AccessCode { get; set; }
-
///
/// Initializes a new instance of the class.
///
@@ -95,7 +100,18 @@ namespace PocketSharp
///
public T Request(RestRequest request) where T : new()
{
- var response = _restClient.Execute(request);
+ IRestResponse response = _restClient.Execute(request);
+
+ LastRequestData = response;
+
+ if(response.StatusCode != HttpStatusCode.OK)
+ {
+ throw new APIException(response.Content, response.ErrorException);
+ }
+ else if(response.ErrorException != null)
+ {
+ throw new APIException("Error retrieving response", response.ErrorException);
+ }
return response.Data;
}
@@ -122,11 +138,23 @@ namespace PocketSharp
{
var request = new RestRequest("oauth/authorize", Method.POST);
- request.AddParameter("code", RequestCode);
+ request.AddParameter("code", "fbe15035-d6b1-e4c2-590b-60de6e");
AccessCode rawResponse = Request(request);
return rawResponse;
}
+
+ public bool Test4(string code)
+ {
+ var request = new RestRequest("get", Method.POST);
+
+ request.AddParameter("access_toiken", code);
+ request.AddParameter("favorite", "1");
+
+ AccessCode rawResponse = Request(request);
+
+ return true;
+ }
}
}