diff --git a/src/Todoist.Net.Tests/Services/ItemsServiceTests.cs b/src/Todoist.Net.Tests/Services/ItemsServiceTests.cs
index 68eba51..242d630 100644
--- a/src/Todoist.Net.Tests/Services/ItemsServiceTests.cs
+++ b/src/Todoist.Net.Tests/Services/ItemsServiceTests.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using System.Threading.Tasks;
using Todoist.Net.Exceptions;
using Todoist.Net.Models;
@@ -125,7 +126,7 @@ public void CreateItem_InvalidPDueDate_ThrowsException()
[Fact]
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
- public void MoveItemsToProject_Success()
+ public async Task MoveItemsToProject_Success()
{
var client = TodoistClientFactory.Create(_outputHelper);
@@ -133,22 +134,22 @@ public void MoveItemsToProject_Success()
client.Items.AddAsync(item).Wait();
item.DueDate = new DueDate("every fri");
- client.Items.UpdateAsync(item).Wait();
+ await client.Items.UpdateAsync(item);
var project = new Project(Guid.NewGuid().ToString());
- client.Projects.AddAsync(project).Wait();
+ await client.Projects.AddAsync(project);
- var itemInfo = client.Items.GetAsync(item.Id).Result;
+ var itemInfo = await client.Items.GetAsync(item.Id);
Assert.True(project.Id != itemInfo.Project.Id);
- client.Items.MoveAsync(ItemMoveArgument.CreateMoveToProject(itemInfo.Item.Id, project.Id)).Wait();
- itemInfo = client.Items.GetAsync(itemInfo.Item.Id).Result;
+ await client.Items.MoveAsync(ItemMoveArgument.CreateMoveToProject(itemInfo.Item.Id, project.Id));
+ itemInfo = await client.Items.GetAsync(itemInfo.Item.Id);
Assert.True(project.Id == itemInfo.Project.Id);
- client.Projects.DeleteAsync(project.Id).Wait();
- client.Items.DeleteAsync(itemInfo.Item.Id).Wait();
+ await client.Items.DeleteAsync(itemInfo.Item.Id);
+ await client.Projects.DeleteAsync(project.Id);
}
[Fact]
diff --git a/src/Todoist.Net.Tests/Services/UsersServiceTests.cs b/src/Todoist.Net.Tests/Services/UsersServiceTests.cs
index fc61602..645d1dd 100644
--- a/src/Todoist.Net.Tests/Services/UsersServiceTests.cs
+++ b/src/Todoist.Net.Tests/Services/UsersServiceTests.cs
@@ -1,7 +1,5 @@
-using System;
using System.Threading.Tasks;
-using Todoist.Net.Models;
using Todoist.Net.Tests.Extensions;
using Xunit;
@@ -30,31 +28,5 @@ public async Task GetCurrentAsync_Success()
Assert.NotNull(user);
Assert.NotNull(user.Id);
}
-
- [Fact]
- [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
- public async Task RegisterUpdateSettingsAndDeleteUser_Success()
- {
- var todoistTokenlessClient = TodoistClientFactory.CreateTokenlessClient();
-
- const string password = "Pa$$W@rd";
- var userBase = new UserBase(Guid.NewGuid().ToString("N") + "@example.com", "test user", password);
- var userInfo = await todoistTokenlessClient.RegisterUserAsync(userBase);
- Assert.NotNull(userInfo);
-
- var todoistClient = await todoistTokenlessClient.LoginAsync(userBase.Email, userBase.Password);
- await todoistClient.Users.UpdateKarmaGoalsAsync(new KarmaGoals() { KarmaDisabled = true });
-
- if (userInfo.HasPassword)
- {
- userInfo.CurrentPassword = password;
- }
-
- await todoistClient.Users.UpdateAsync(userInfo);
-
- await todoistClient.Users.DeleteAsync(userBase.Password, "test");
-
- todoistClient.Dispose();
- }
}
}
diff --git a/src/Todoist.Net.Tests/TodoistClientFactory.cs b/src/Todoist.Net.Tests/TodoistClientFactory.cs
index e63527e..6ac48c0 100644
--- a/src/Todoist.Net.Tests/TodoistClientFactory.cs
+++ b/src/Todoist.Net.Tests/TodoistClientFactory.cs
@@ -11,10 +11,5 @@ public static ITodoistClient Create(ITestOutputHelper outputHelper)
var token = SettingsProvider.GetToken();
return new TodoistClient(new RateLimitAwareRestClient(token, outputHelper));
}
-
- public static ITodoistTokenlessClient CreateTokenlessClient()
- {
- return new TodoistTokenlessClient();
- }
}
}
diff --git a/src/Todoist.Net/ITodoistTokenlessClient.cs b/src/Todoist.Net/ITodoistTokenlessClient.cs
deleted file mode 100644
index 2f82a7c..0000000
--- a/src/Todoist.Net/ITodoistTokenlessClient.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using System;
-using System.Net.Http;
-using System.Threading;
-using System.Threading.Tasks;
-
-using Todoist.Net.Exceptions;
-using Todoist.Net.Models;
-
-namespace Todoist.Net
-{
- ///
- /// A Todoist client without an access token.
- ///
- public interface ITodoistTokenlessClient
- {
- ///
- /// Logins user and returns a new instance of Todoist client.
- ///
- /// The email.
- /// The password.
- /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
- ///
- /// A new instance of Todoist client.
- ///
- ///
- /// Value cannot be null or empty. - email
- /// or
- /// Value cannot be null or empty. - password
- ///
- /// API exception.
- /// Unable to get token.
- Task LoginAsync(string email, string password, CancellationToken cancellationToken = default);
-
- ///
- /// Logins user and returns a new instance of Todoist client.
- ///
- /// The email.
- /// The oauth token.
- /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
- ///
- /// A new instance of Todoist client.
- ///
- ///
- /// Value cannot be null or empty. - email
- /// or
- /// Value cannot be null or empty. - oauthToken
- ///
- /// API exception.
- /// API exception.
- Task LoginWithGoogleAsync(string email, string oauthToken, CancellationToken cancellationToken = default);
-
- ///
- /// Registers a new user.
- ///
- /// The user.
- /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
- ///
- /// The user info.
- ///
- /// is
- /// API exception.
- Task RegisterUserAsync(UserBase user, CancellationToken cancellationToken = default);
- }
-}
diff --git a/src/Todoist.Net/Todoist.Net.csproj b/src/Todoist.Net/Todoist.Net.csproj
index 76fe1e9..67bad49 100644
--- a/src/Todoist.Net/Todoist.Net.csproj
+++ b/src/Todoist.Net/Todoist.Net.csproj
@@ -2,7 +2,7 @@
A Todoist API client for .NET
- 5.1.0
+ 6.0.0
Oleg Shevchenko
netstandard2.0;net45
true
diff --git a/src/Todoist.Net/TodoistClient.cs b/src/Todoist.Net/TodoistClient.cs
index c891211..914aa9e 100644
--- a/src/Todoist.Net/TodoistClient.cs
+++ b/src/Todoist.Net/TodoistClient.cs
@@ -200,7 +200,7 @@ public void Dispose()
///
public Task GetResourcesAsync(params ResourceType[] resourceTypes) =>
GetResourcesAsync("*", resourceTypes);
-
+
///
public Task GetResourcesAsync(CancellationToken cancellationToken, params ResourceType[] resourceTypes) =>
GetResourcesAsync("*", cancellationToken, resourceTypes);
diff --git a/src/Todoist.Net/TodoistTokenlessClient.cs b/src/Todoist.Net/TodoistTokenlessClient.cs
deleted file mode 100644
index cb1dca7..0000000
--- a/src/Todoist.Net/TodoistTokenlessClient.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Net;
-using System.Net.Http;
-using System.Threading;
-using System.Threading.Tasks;
-
-using Todoist.Net.Exceptions;
-using Todoist.Net.Models;
-
-namespace Todoist.Net
-{
- ///
- /// A Todoist client without an access token.
- ///
- ///
- ///
- public sealed class TodoistTokenlessClient : ITodoistTokenlessClient, IDisposable
- {
- private readonly TodoistClient _todoistClient;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public TodoistTokenlessClient() : this(new TodoistRestClient())
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The proxy.
- public TodoistTokenlessClient(IWebProxy proxy) : this(new TodoistRestClient(proxy))
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The rest client.
- public TodoistTokenlessClient(ITodoistRestClient restClient)
- {
- _todoistClient = new TodoistClient(restClient);
- }
-
- ///
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- ///
- public void Dispose()
- {
- _todoistClient?.Dispose();
- }
-
- ///
- [Obsolete("This method is scheduled for deprecation and probably will be removed in future versions.")]
- public Task LoginAsync(string email, string password, CancellationToken cancellationToken = default)
- {
- if (string.IsNullOrEmpty(email))
- {
- throw new ArgumentException("Value cannot be null or empty.", nameof(email));
- }
-
- if (string.IsNullOrEmpty(password))
- {
- throw new ArgumentException("Value cannot be null or empty.", nameof(password));
- }
-
- var parameters = new[]
- {
- new KeyValuePair("email", email),
- new KeyValuePair("password", password)
- };
-
- return LoginWithCredentialsAsync("login", parameters, cancellationToken);
- }
-
- ///
- [Obsolete("This method is scheduled for deprecation and probably will be removed in future versions.")]
- public Task LoginWithGoogleAsync(string email, string oauthToken, CancellationToken cancellationToken = default)
- {
- if (string.IsNullOrEmpty(email))
- {
- throw new ArgumentException("Value cannot be null or empty.", nameof(email));
- }
-
- if (string.IsNullOrEmpty(oauthToken))
- {
- throw new ArgumentException("Value cannot be null or empty.", nameof(oauthToken));
- }
-
- var parameters = new[]
- {
- new KeyValuePair("email", email),
- new KeyValuePair("oauth2_token", oauthToken)
- };
-
- return LoginWithCredentialsAsync("login_with_google", parameters, cancellationToken);
- }
-
- ///
- public async Task RegisterUserAsync(UserBase user, CancellationToken cancellationToken = default)
- {
- if (user == null)
- {
- throw new ArgumentNullException(nameof(user));
- }
-
- var userInfo = await ((IAdvancedTodoistClient)_todoistClient)
- .ProcessPostAsync("user/register", user.ToParameters(), cancellationToken)
- .ConfigureAwait(false);
-
- return userInfo;
- }
-
- ///
- /// Logins with credentials and returns a new instance of Todoist client.
- ///
- /// The resource.
- /// The parameters.
- /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
- ///
- /// A new instance of Todoist client.
- ///
- /// API exception.
- /// Unable to get token.
- private async Task LoginWithCredentialsAsync(
- string resource,
- KeyValuePair[] parameters,
- CancellationToken cancellationToken)
- {
- var userInfo = await ((IAdvancedTodoistClient)_todoistClient)
- .ProcessPostAsync(resource, parameters, cancellationToken)
- .ConfigureAwait(false);
-
- return new TodoistClient(userInfo.Token);
- }
- }
-}