method to get a new GUID from Pocket

This commit is contained in:
2018-04-09 12:34:52 +02:00
parent ed087ffdf5
commit 1c2c85ad05
3 changed files with 46 additions and 3 deletions
+15 -1
View File
@@ -1,4 +1,4 @@
using PocketSharp.Models;
using PocketSharp.Models;
using System;
using System.Collections.Generic;
using System.Threading;
@@ -124,5 +124,19 @@ namespace PocketSharp
return response;
}
/// <summary>
/// Get a new GUID from the Pocket API.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The GUID
/// </returns>
public async Task<string> GetGuid(CancellationToken cancellationToken = default(CancellationToken))
{
GuidResponse response = await Request<GuidResponse>("guid", cancellationToken, requireAuth: false);
return response.Guid;
}
}
}
+11 -2
View File
@@ -1,4 +1,4 @@
using PocketSharp.Models;
using PocketSharp.Models;
using System;
using System.Collections.Generic;
using System.Threading;
@@ -90,6 +90,15 @@ namespace PocketSharp
/// <returns>A valid URI to redirect the user to.</returns>
/// <exception cref="System.NullReferenceException">Call GetRequestCode() first to receive a request_code</exception>
Uri GenerateRegistrationUri(string requestCode = null);
/// <summary>
/// Get a new GUID from the Pocket API.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The GUID
/// </returns>
Task<string> GetGuid(CancellationToken cancellationToken = default(CancellationToken));
#endregion
#region add methods
@@ -461,4 +470,4 @@ namespace PocketSharp
/// </summary>
void Dispose();
}
}
}
+20
View File
@@ -0,0 +1,20 @@
using Newtonsoft.Json;
namespace PocketSharp.Models
{
/// <summary>
/// Guid
/// </summary>
[JsonObject]
internal class GuidResponse
{
/// <summary>
/// Gets or sets the GUID.
/// </summary>
/// <value>
/// The GUID.
/// </value>
[JsonProperty]
public string Guid { get; set; }
}
}