diff --git a/CHANGELOG.md b/CHANGELOG.md index ac4049d..c668a12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,13 @@ +### 2.2.0 (2013-10-26) + +- Made `GetAccessCode` obsolete +- Return username after authentication with `GetUser` (thanks to [ScottIsAFool](https://github.com/ScottIsAFool)) + ### 2.1.0 (2013-10-25) - Rename `Statistics()` to `GetUserStatistics()` -- Made `CallbackUri` public (thanks to @ScottIsAFool) -- Added Fody/PropertyChanged (thanks to @ScottIsAFool) +- Made `CallbackUri` public (thanks to [ScottIsAFool](https://github.com/ScottIsAFool)) +- Added Fody/PropertyChanged (thanks to [ScottIsAFool](https://github.com/ScottIsAFool)) - Method `GetUsageLimits()` to retrieve API usage limits - Add PORTABLE constant to SgmlReader diff --git a/PocketSharp/Components/Account.cs b/PocketSharp/Components/Account.cs index facfac7..e30a485 100644 --- a/PocketSharp/Components/Account.cs +++ b/PocketSharp/Components/Account.cs @@ -65,36 +65,51 @@ namespace PocketSharp /// /// Requests the access code after authentication - /// The access code has to permanently be stored within the users session, and should be added as a parameter for all future PocketClient initializations. + /// The access code has to permanently be stored within the users session, and should be passed in the constructor for all future PocketClient initializations. /// /// The requestCode. If no requestCode is supplied, the property from the PocketClient intialization is used. /// The permanent access code, which is used to authenticate the user with the application /// Call GetRequestCode() first to receive a request_code /// + [Obsolete("Please use GetUser instead")] public async Task GetAccessCode(string requestCode = null) + { + await GetUser(requestCode); + return AccessCode; + } + + + /// + /// Requests the access code and username after authentication + /// The access code has to permanently be stored within the users session, and should be passed in the constructor for all future PocketClient initializations. + /// + /// The request code. + /// The authenticated user + /// Call GetRequestCode() first to receive a request_code + public async Task GetUser(string requestCode = null) { // check if request code is available - if(RequestCode == null && requestCode == null) + if (RequestCode == null && requestCode == null) { throw new NullReferenceException("Call GetRequestCode() first to receive a request_code"); } // override property with given param if available - if(requestCode != null) + if (requestCode != null) { RequestCode = requestCode; } // do request - AccessCode response = await Request("oauth/authorize", new Dictionary() - { - { "code", RequestCode } + PocketUser response = await Request("oauth/authorize", new Dictionary() + { + {"code", RequestCode} }, false); // save code to client AccessCode = response.Code; - return AccessCode; + return response; } diff --git a/PocketSharp/Components/Statistics.cs b/PocketSharp/Components/Statistics.cs index 28a6354..10c16cc 100644 --- a/PocketSharp/Components/Statistics.cs +++ b/PocketSharp/Components/Statistics.cs @@ -25,7 +25,7 @@ namespace PocketSharp /// /// /// - [Obsolete("Please use GetUserStatistics")] + [Obsolete("Please use GetUserStatistics instead")] public async Task Statistics() { return await GetUserStatistics(); diff --git a/PocketSharp/Models/Response/AccessCode.cs b/PocketSharp/Models/PocketUser.cs similarity index 81% rename from PocketSharp/Models/Response/AccessCode.cs rename to PocketSharp/Models/PocketUser.cs index 6d88856..9f68d7a 100644 --- a/PocketSharp/Models/Response/AccessCode.cs +++ b/PocketSharp/Models/PocketUser.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using PropertyChanged; namespace PocketSharp.Models { @@ -6,7 +7,8 @@ namespace PocketSharp.Models /// Access Code /// [JsonObject] - internal class AccessCode + [ImplementPropertyChanged] + public class PocketUser { /// /// Gets or sets the code. @@ -23,7 +25,7 @@ namespace PocketSharp.Models /// /// The username. /// - [JsonProperty] + [JsonProperty("username")] public string Username { get; set; } } } diff --git a/PocketSharp/PocketReader.cs b/PocketSharp/PocketReader.cs index 0071a61..3bf37b5 100644 --- a/PocketSharp/PocketReader.cs +++ b/PocketSharp/PocketReader.cs @@ -37,7 +37,7 @@ namespace PocketSharp _httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Encoding", "gzip,deflate"); // add user agent (default for Opera with PocketSharp identifier appended) - _httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.4 Safari/537.36 OPR/18.0.1284.2 PocketSharp/2.0"); + _httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.4 Safari/537.36 OPR/18.0.1284.2 PocketSharp/2.2"); } diff --git a/PocketSharp/PocketSharp.csproj b/PocketSharp/PocketSharp.csproj index 7371795..0d0c35a 100644 --- a/PocketSharp/PocketSharp.csproj +++ b/PocketSharp/PocketSharp.csproj @@ -63,7 +63,7 @@ - + diff --git a/PocketSharp/Properties/AssemblyInfo.cs b/PocketSharp/Properties/AssemblyInfo.cs index 8864a69..a3d72c0 100644 --- a/PocketSharp/Properties/AssemblyInfo.cs +++ b/PocketSharp/Properties/AssemblyInfo.cs @@ -25,5 +25,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.0")] -[assembly: AssemblyFileVersion("2.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.2.0")] +[assembly: AssemblyFileVersion("2.2.0")] \ No newline at end of file