Skip to content

Commit

Permalink
Remove tokenless client. Closes #38 (#40)
Browse files Browse the repository at this point in the history
* Remove tokenless client. Closes #38

* Bump version
  • Loading branch information
olsh authored Oct 26, 2023
1 parent 796853c commit 1f7f320
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 245 deletions.
17 changes: 9 additions & 8 deletions src/Todoist.Net.Tests/Services/ItemsServiceTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Threading.Tasks;

using Todoist.Net.Exceptions;
using Todoist.Net.Models;
Expand Down Expand Up @@ -125,30 +126,30 @@ 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);

var item = new Item("demo task");
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]
Expand Down
28 changes: 0 additions & 28 deletions src/Todoist.Net.Tests/Services/UsersServiceTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Threading.Tasks;

using Todoist.Net.Models;
using Todoist.Net.Tests.Extensions;

using Xunit;
Expand Down Expand Up @@ -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();
}
}
}
5 changes: 0 additions & 5 deletions src/Todoist.Net.Tests/TodoistClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
64 changes: 0 additions & 64 deletions src/Todoist.Net/ITodoistTokenlessClient.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Todoist.Net/Todoist.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>A Todoist API client for .NET</Description>
<VersionPrefix>5.1.0</VersionPrefix>
<VersionPrefix>6.0.0</VersionPrefix>
<Authors>Oleg Shevchenko</Authors>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
2 changes: 1 addition & 1 deletion src/Todoist.Net/TodoistClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void Dispose()
/// <inheritdoc/>
public Task<Resources> GetResourcesAsync(params ResourceType[] resourceTypes) =>
GetResourcesAsync("*", resourceTypes);

/// <inheritdoc/>
public Task<Resources> GetResourcesAsync(CancellationToken cancellationToken, params ResourceType[] resourceTypes) =>
GetResourcesAsync("*", cancellationToken, resourceTypes);
Expand Down
138 changes: 0 additions & 138 deletions src/Todoist.Net/TodoistTokenlessClient.cs

This file was deleted.

0 comments on commit 1f7f320

Please sign in to comment.