diff --git a/PocketSharp.Console/Program.cs b/PocketSharp.Console/Program.cs index 7f802ec..b3a729c 100644 --- a/PocketSharp.Console/Program.cs +++ b/PocketSharp.Console/Program.cs @@ -14,6 +14,9 @@ namespace PocketSharp.Console // this apiKey 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("15396-f6f92101d72c8e270a6c9bb3"); + client.AccessCode = "a85134a7-243c-6656-ab82-97c901"; + + client.Get(); System.Console.ReadKey(); } diff --git a/PocketSharp/Components/Get.cs b/PocketSharp/Components/Get.cs new file mode 100644 index 0000000..5a5f042 --- /dev/null +++ b/PocketSharp/Components/Get.cs @@ -0,0 +1,24 @@ +using PocketSharp.Models; +using RestSharp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PocketSharp +{ + public partial class PocketClient : IPocketClient + { + public bool Get() + { + //var parameters = new List() + //{ + // new Parameter { Name = "favorite", Value = "1", Type = ParameterType.GetOrPost } + //}; + + Retrieve result = GetResource("get", parameters); + + return true; + } + } +} diff --git a/PocketSharp/IPocketClient.cs b/PocketSharp/IPocketClient.cs index 342b69b..a282c34 100644 --- a/PocketSharp/IPocketClient.cs +++ b/PocketSharp/IPocketClient.cs @@ -45,6 +45,6 @@ namespace PocketSharp /// Additional POST parameters /// /// No access token available. Use authentification first. - public T GetResource(string method, List parameters) where T : class, new(); + T GetResource(string method, List parameters) where T : class, new(); } } diff --git a/PocketSharp/Models/PocketItem.cs b/PocketSharp/Models/PocketItem.cs index 8a080ea..1d70d28 100644 --- a/PocketSharp/Models/PocketItem.cs +++ b/PocketSharp/Models/PocketItem.cs @@ -1,6 +1,4 @@ -using RestSharp.Serializers; -using System; -using System.Collections.Generic; +using System; using System.Runtime.Serialization; namespace PocketSharp.Models diff --git a/PocketSharp/Models/ResponseBase.cs b/PocketSharp/Models/ResponseBase.cs new file mode 100644 index 0000000..16ab4f6 --- /dev/null +++ b/PocketSharp/Models/ResponseBase.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PocketSharp.Models +{ + class ResponseBase + { + public bool Status { get; set; } + } +} diff --git a/PocketSharp/Models/Retrieve.cs b/PocketSharp/Models/Retrieve.cs new file mode 100644 index 0000000..a5c1058 --- /dev/null +++ b/PocketSharp/Models/Retrieve.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace PocketSharp.Models +{ + [DataContract] + class Retrieve : ResponseBase + { + [DataMember] + public bool Complete { get; set; } + + [DataMember] + public int Since { get; set; } + + [DataMember(Name = "list")] + public List Items { get; set; } + } +} diff --git a/PocketSharp/PocketClient.cs b/PocketSharp/PocketClient.cs index 2a5c709..97add76 100644 --- a/PocketSharp/PocketClient.cs +++ b/PocketSharp/PocketClient.cs @@ -41,7 +41,7 @@ namespace PocketSharp /// /// Code retrieved on authentification-success /// - protected string AccessCode { get; set; } + public string AccessCode { get; set; } /// @@ -114,27 +114,6 @@ namespace PocketSharp } - /// - /// Validates the response. - /// - /// The response. - /// - /// - /// Error retrieving response - /// - protected void ValidateResponse(IRestResponse 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); - } - } - - /// /// Fetches a typed resource /// @@ -166,5 +145,26 @@ namespace PocketSharp // do the request return Request(request); } + + + /// + /// Validates the response. + /// + /// The response. + /// + /// + /// Error retrieving response + /// + protected void ValidateResponse(IRestResponse 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); + } + } } } diff --git a/PocketSharp/PocketSharp.csproj b/PocketSharp/PocketSharp.csproj index cecd567..8a67ed3 100644 --- a/PocketSharp/PocketSharp.csproj +++ b/PocketSharp/PocketSharp.csproj @@ -48,11 +48,14 @@ + + +