From 865f6f515c209bbb3da6a0304c6de719e930acd6 Mon Sep 17 00:00:00 2001 From: Oleg Shevchenko Date: Mon, 10 Oct 2022 19:44:37 +0300 Subject: [PATCH] Migrate to v9 API (#17) * Migrate to sync API v9 --- README.md | 2 +- build.cake | 29 ++++------- src/Todoist.Net.Tests/Extensions/Constants.cs | 8 +++ .../Extensions/CustomTraitBaseAttribute.cs | 9 ---- .../Extensions/IntegrationFreeAttribute.cs | 12 ----- .../Extensions/IntegrationPremiumAttribute.cs | 12 ----- .../Extensions/UnitAttribute.cs | 12 ----- src/Todoist.Net.Tests/Models/DueDateTests.cs | 4 +- .../Models/StringEnumTests.cs | 4 +- .../Services/ActivityServiceTests.cs | 2 +- .../Services/BackupServiceTests.cs | 2 +- .../Services/EmailServiceTests.cs | 2 +- .../Services/FiltersServiceTests.cs | 2 +- .../Services/ItemsServiceTests.cs | 17 +++--- .../Services/LabelsServiceTests.cs | 2 +- .../Services/NotesServiceTests.cs | 6 +-- .../Services/NotificationsServiceTests.cs | 2 +- .../Services/ProjectsServiceTests.cs | 12 ++--- .../Services/ReminersServiceTests.cs | 2 +- .../Services/SectionServiceTests.cs | 2 +- .../Services/SharingServiceTests.cs | 2 +- .../Services/TemplateServiceTests.cs | 2 +- .../Services/TransactionTests.cs | 2 +- .../Services/UploadServiceTests.cs | 4 +- .../Services/UsersServiceTests.cs | 36 +++++++------ .../Todoist.Net.Tests.csproj | 4 -- src/Todoist.Net.Tests/TodoistClientTests.cs | 19 +++++-- src/Todoist.Net/Models/CommandType.cs | 4 -- .../Models/CompleteItemArgument.cs | 26 +++------- src/Todoist.Net/Models/ComplexId.cs | 12 ++--- src/Todoist.Net/Models/DueDate.cs | 4 +- src/Todoist.Net/Models/Filter.cs | 16 ++++-- .../Models/IWithRelationsArgument.cs | 4 +- src/Todoist.Net/Models/Item.cs | 52 +++++++------------ src/Todoist.Net/Models/Label.cs | 16 ++++-- src/Todoist.Net/Models/Note.cs | 25 +++------ src/Todoist.Net/Models/Notification.cs | 10 ++-- src/Todoist.Net/Models/Project.cs | 20 ++++--- src/Todoist.Net/Models/Reminder.cs | 11 +--- src/Todoist.Net/Models/Section.cs | 25 ++------- src/Todoist.Net/Models/SyncResponse.cs | 4 +- src/Todoist.Net/Models/User.cs | 38 +++++--------- src/Todoist.Net/Models/UserInfo.cs | 31 ++++++++--- .../Converters/ComplexIdConverter.cs | 7 +-- .../Resolvers/ConverterContractResolver.cs | 4 +- .../Services/IItemsCommandService.cs | 26 ---------- src/Todoist.Net/Services/IUsersService.cs | 14 ----- .../Services/ItemsCommandService.cs | 38 +------------- .../Services/NotificationsCommandService.cs | 4 +- src/Todoist.Net/Services/UsersService.cs | 34 +----------- src/Todoist.Net/Todoist.Net.csproj | 4 +- src/Todoist.Net/TodoistClient.cs | 4 +- src/Todoist.Net/TodoistRestClient.cs | 4 +- 53 files changed, 233 insertions(+), 416 deletions(-) delete mode 100644 src/Todoist.Net.Tests/Extensions/CustomTraitBaseAttribute.cs delete mode 100644 src/Todoist.Net.Tests/Extensions/IntegrationFreeAttribute.cs delete mode 100644 src/Todoist.Net.Tests/Extensions/IntegrationPremiumAttribute.cs delete mode 100644 src/Todoist.Net.Tests/Extensions/UnitAttribute.cs diff --git a/README.md b/README.md index a9a1a92..7bfb885 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![codecov](https://codecov.io/gh/olsh/todoist-net/branch/master/graph/badge.svg)](https://codecov.io/gh/olsh/todoist-net) [![NuGet](https://img.shields.io/nuget/v/Todoist.Net.svg)](https://www.nuget.org/packages/Todoist.Net/) -A [Todoist Sync API](https://developer.todoist.com/sync/v8/) client for .NET. +A [Todoist Sync API](https://developer.todoist.com/sync/v9/) client for .NET. ## Installation The library is available as a [Nuget package](https://www.nuget.org/packages/Todoist.Net/). diff --git a/build.cake b/build.cake index 7582520..2b760ce 100644 --- a/build.cake +++ b/build.cake @@ -1,6 +1,3 @@ -#tool nuget:?package=Codecov&version=1.13.0 -#addin nuget:?package=Cake.Codecov&version=1.0.1 - #tool nuget:?package=MSBuild.SonarQube.Runner.Tool&version=4.8.0 #addin nuget:?package=Cake.Sonar&version=1.1.30 @@ -36,36 +33,30 @@ Task("Build") DotNetBuild(string.Format("{0}.sln", projectName), settings); }); -Task("Test") +Task("UnitTest") .IsDependentOn("Build") .Does(() => { var settings = new DotNetTestSettings { Configuration = buildConfiguration, - Loggers = new List { "console;verbosity=detailed" } + Filter = "trait=unit" }; DotNetTest(testProjectFile, settings); }); -Task("CodeCoverage") +Task("Test") .IsDependentOn("Build") .Does(() => { - var settings = new DotNetTestSettings - { - Configuration = buildConfiguration, - Loggers = new List { "console;verbosity=detailed" }, - ArgumentCustomization = args => args - .Append("/p:CollectCoverage=true") - .Append("/p:CoverletOutputFormat=opencover") - .Append("/p:Include=\"[Todoist.Net]*\"") - }; - - DotNetTest(testProjectFile, settings); + var settings = new DotNetTestSettings + { + Configuration = buildConfiguration, + Loggers = new List { "console;verbosity=detailed" } + }; - Codecov(string.Format("{0}coverage.net6.0.opencover.xml", testProjectFolder), EnvironmentVariable("codecov:token")); + DotNetTest(testProjectFile, settings); }); Task("NugetPack") @@ -121,7 +112,7 @@ Task("Default") Task("CI") .IsDependentOn("UpdateBuildVersion") .IsDependentOn("Sonar") - .IsDependentOn("CodeCoverage") + .IsDependentOn("UnitTest") .IsDependentOn("CreateArtifact"); RunTarget(target); diff --git a/src/Todoist.Net.Tests/Extensions/Constants.cs b/src/Todoist.Net.Tests/Extensions/Constants.cs index 5fea949..7ce2f37 100644 --- a/src/Todoist.Net.Tests/Extensions/Constants.cs +++ b/src/Todoist.Net.Tests/Extensions/Constants.cs @@ -3,4 +3,12 @@ namespace Todoist.Net.Tests.Extensions; internal static class Constants { public const string TodoistApiTestCollectionName = "todoist-api-tests"; + + public const string TraitName = "trait"; + + public const string UnitTraitValue = "unit"; + + public const string IntegrationFreeTraitValue = "integration-free"; + + public const string IntegrationPremiumTraitValue = "integration-premium"; } diff --git a/src/Todoist.Net.Tests/Extensions/CustomTraitBaseAttribute.cs b/src/Todoist.Net.Tests/Extensions/CustomTraitBaseAttribute.cs deleted file mode 100644 index f30d756..0000000 --- a/src/Todoist.Net.Tests/Extensions/CustomTraitBaseAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace Todoist.Net.Tests.Extensions -{ - public class CustomTraitBaseAttribute : Attribute - { - public string Name { get; protected set; } - } -} diff --git a/src/Todoist.Net.Tests/Extensions/IntegrationFreeAttribute.cs b/src/Todoist.Net.Tests/Extensions/IntegrationFreeAttribute.cs deleted file mode 100644 index dc59bab..0000000 --- a/src/Todoist.Net.Tests/Extensions/IntegrationFreeAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Xunit.Sdk; - -namespace Todoist.Net.Tests.Extensions -{ - public class IntegrationFreeAttribute : CustomTraitBaseAttribute, ITraitAttribute - { - public IntegrationFreeAttribute() - { - Name = "integration-free"; - } - } -} diff --git a/src/Todoist.Net.Tests/Extensions/IntegrationPremiumAttribute.cs b/src/Todoist.Net.Tests/Extensions/IntegrationPremiumAttribute.cs deleted file mode 100644 index f22d262..0000000 --- a/src/Todoist.Net.Tests/Extensions/IntegrationPremiumAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Xunit.Sdk; - -namespace Todoist.Net.Tests.Extensions -{ - public class IntegrationPremiumAttribute : CustomTraitBaseAttribute, ITraitAttribute - { - public IntegrationPremiumAttribute() - { - Name = "integration-premium"; - } - } -} diff --git a/src/Todoist.Net.Tests/Extensions/UnitAttribute.cs b/src/Todoist.Net.Tests/Extensions/UnitAttribute.cs deleted file mode 100644 index ef60e2f..0000000 --- a/src/Todoist.Net.Tests/Extensions/UnitAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Xunit.Sdk; - -namespace Todoist.Net.Tests.Extensions -{ - public class UnitAttribute : CustomTraitBaseAttribute, ITraitAttribute - { - public UnitAttribute() - { - Name = "unit"; - } - } -} diff --git a/src/Todoist.Net.Tests/Models/DueDateTests.cs b/src/Todoist.Net.Tests/Models/DueDateTests.cs index 914e86f..e0eda5b 100644 --- a/src/Todoist.Net.Tests/Models/DueDateTests.cs +++ b/src/Todoist.Net.Tests/Models/DueDateTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using Todoist.Net.Models; using Todoist.Net.Tests.Extensions; @@ -6,7 +6,7 @@ namespace Todoist.Net.Tests.Models { - [Unit] + [Trait(Constants.TraitName, Constants.UnitTraitValue)] public class DueDateTests { [Fact] diff --git a/src/Todoist.Net.Tests/Models/StringEnumTests.cs b/src/Todoist.Net.Tests/Models/StringEnumTests.cs index 3e887db..b3152dd 100644 --- a/src/Todoist.Net.Tests/Models/StringEnumTests.cs +++ b/src/Todoist.Net.Tests/Models/StringEnumTests.cs @@ -1,11 +1,11 @@ -using Todoist.Net.Models; +using Todoist.Net.Models; using Todoist.Net.Tests.Extensions; using Xunit; namespace Todoist.Net.Tests.Models { - [Unit] + [Trait(Constants.TraitName, Constants.UnitTraitValue)] public class StringEnumTests { [Fact] diff --git a/src/Todoist.Net.Tests/Services/ActivityServiceTests.cs b/src/Todoist.Net.Tests/Services/ActivityServiceTests.cs index 4bbffe6..866be26 100644 --- a/src/Todoist.Net.Tests/Services/ActivityServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/ActivityServiceTests.cs @@ -7,7 +7,7 @@ namespace Todoist.Net.Tests.Services { [Collection(Constants.TodoistApiTestCollectionName)] - [IntegrationPremium] + [Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)] public class ActivityServiceTests { private readonly ITestOutputHelper _outputHelper; diff --git a/src/Todoist.Net.Tests/Services/BackupServiceTests.cs b/src/Todoist.Net.Tests/Services/BackupServiceTests.cs index 83278be..958ccb0 100644 --- a/src/Todoist.Net.Tests/Services/BackupServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/BackupServiceTests.cs @@ -7,6 +7,7 @@ namespace Todoist.Net.Tests.Services { [Collection(Constants.TodoistApiTestCollectionName)] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public class BackupServiceTests { private readonly ITestOutputHelper _outputHelper; @@ -17,7 +18,6 @@ public BackupServiceTests(ITestOutputHelper outputHelper) } [Fact] - [IntegrationFree] public void GetBackups_Success() { var client = TodoistClientFactory.Create(_outputHelper); diff --git a/src/Todoist.Net.Tests/Services/EmailServiceTests.cs b/src/Todoist.Net.Tests/Services/EmailServiceTests.cs index a8b9ce3..bf73098 100644 --- a/src/Todoist.Net.Tests/Services/EmailServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/EmailServiceTests.cs @@ -19,7 +19,7 @@ public EmailServiceTests(ITestOutputHelper outputHelper) } [Fact] - [IntegrationPremium] + [Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)] public void GetOrCreateAsyncDisable_NewProject_Success() { var client = TodoistClientFactory.Create(_outputHelper); diff --git a/src/Todoist.Net.Tests/Services/FiltersServiceTests.cs b/src/Todoist.Net.Tests/Services/FiltersServiceTests.cs index c77a9b9..f155bb1 100644 --- a/src/Todoist.Net.Tests/Services/FiltersServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/FiltersServiceTests.cs @@ -10,7 +10,7 @@ namespace Todoist.Net.Tests.Services { [Collection(Constants.TodoistApiTestCollectionName)] - [IntegrationPremium] + [Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)] public class FiltersServiceTests { private readonly ITestOutputHelper _outputHelper; diff --git a/src/Todoist.Net.Tests/Services/ItemsServiceTests.cs b/src/Todoist.Net.Tests/Services/ItemsServiceTests.cs index e18b652..375c560 100644 --- a/src/Todoist.Net.Tests/Services/ItemsServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/ItemsServiceTests.cs @@ -21,7 +21,7 @@ public ItemsServiceTests(ITestOutputHelper outputHelper) } [Fact] - [IntegrationPremium] + [Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)] public void CreateItemCompleteGetCloseAsync_Success() { var client = TodoistClientFactory.Create(_outputHelper); @@ -45,7 +45,7 @@ public void CreateItemCompleteGetCloseAsync_Success() } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void CreateItemCompleteUncompleteAsync_Success() { var client = TodoistClientFactory.Create(_outputHelper); @@ -62,7 +62,6 @@ public void CreateItemCompleteUncompleteAsync_Success() Assert.True(itemInfo.Item.IsChecked == true); - client.Items.UnArchiveAsync(itemId).Wait(); client.Items.UncompleteAsync(itemId).Wait(); var anotherItem = client.Items.GetAsync().Result.First(i => i.Id != item.Id); @@ -84,7 +83,7 @@ public void CreateItemCompleteUncompleteAsync_Success() } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void CreateItemClearDueDateAndDelete_Success() { var client = TodoistClientFactory.Create(_outputHelper); @@ -108,7 +107,7 @@ public void CreateItemClearDueDateAndDelete_Success() [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void CreateItem_InvalidPDueDate_ThrowsException() { var client = TodoistClientFactory.Create(_outputHelper); @@ -125,7 +124,7 @@ public void CreateItem_InvalidPDueDate_ThrowsException() } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void MoveItemsToProject_Success() { var client = TodoistClientFactory.Create(_outputHelper); @@ -153,7 +152,7 @@ public void MoveItemsToProject_Success() } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void QuickAddAsync_Success() { var client = TodoistClientFactory.Create(_outputHelper); @@ -169,7 +168,7 @@ public void QuickAddAsync_Success() } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void UpdateOrders_Success() { var client = TodoistClientFactory.Create(_outputHelper); @@ -184,7 +183,7 @@ public void UpdateOrders_Success() } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void CreateNewItem_DueDateIsLocal_DueDateNotChanged() { var client = TodoistClientFactory.Create(_outputHelper); diff --git a/src/Todoist.Net.Tests/Services/LabelsServiceTests.cs b/src/Todoist.Net.Tests/Services/LabelsServiceTests.cs index 02f5956..a9376b9 100644 --- a/src/Todoist.Net.Tests/Services/LabelsServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/LabelsServiceTests.cs @@ -17,7 +17,7 @@ public LabelsServiceTests(ITestOutputHelper outputHelper) } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void CreateUpdateOrderGetInfoDelete_Success() { var client = TodoistClientFactory.Create(_outputHelper); diff --git a/src/Todoist.Net.Tests/Services/NotesServiceTests.cs b/src/Todoist.Net.Tests/Services/NotesServiceTests.cs index b0a1900..fe1c670 100644 --- a/src/Todoist.Net.Tests/Services/NotesServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/NotesServiceTests.cs @@ -21,7 +21,7 @@ public NotesServiceTests(ITestOutputHelper outputHelper) } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void AddNoteGetByIdAndDelete_Success() { var todoistClient = TodoistClientFactory.Create(_outputHelper); @@ -39,7 +39,7 @@ public void AddNoteGetByIdAndDelete_Success() } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void AddNoteToNewProjectAndUpdateIt_Success() { var todoistClient = TodoistClientFactory.Create(_outputHelper); @@ -57,7 +57,7 @@ public void AddNoteToNewProjectAndUpdateIt_Success() } [Fact] - [IntegrationPremium] + [Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)] public void AddNoteToNewProjectAttachFileAndDeleteIt_Success() { var client = TodoistClientFactory.Create(_outputHelper); diff --git a/src/Todoist.Net.Tests/Services/NotificationsServiceTests.cs b/src/Todoist.Net.Tests/Services/NotificationsServiceTests.cs index f08a439..e3b4ae9 100644 --- a/src/Todoist.Net.Tests/Services/NotificationsServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/NotificationsServiceTests.cs @@ -8,7 +8,7 @@ namespace Todoist.Net.Tests.Services { [Collection(Constants.TodoistApiTestCollectionName)] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public class NotificationsServiceTests { private readonly ITestOutputHelper _outputHelper; diff --git a/src/Todoist.Net.Tests/Services/ProjectsServiceTests.cs b/src/Todoist.Net.Tests/Services/ProjectsServiceTests.cs index 8e478c6..8ca8689 100644 --- a/src/Todoist.Net.Tests/Services/ProjectsServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/ProjectsServiceTests.cs @@ -20,7 +20,7 @@ public ProjectsServiceTests(ITestOutputHelper outputHelper) } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void CreateGetAndDelete_Success() { var client = TodoistClientFactory.Create(_outputHelper); @@ -42,7 +42,7 @@ public void CreateGetAndDelete_Success() } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void CreateUpdateOrderMoveAndDelete_Success() { var client = TodoistClientFactory.Create(_outputHelper); @@ -51,20 +51,20 @@ public void CreateUpdateOrderMoveAndDelete_Success() var project = new Project(projectName); client.Projects.AddAsync(project).Wait(); - Assert.True(project.Id != default(int)); + Assert.True(project.Id != default(string)); project.Name = "u_" + Guid.NewGuid(); client.Projects.UpdateAsync(project).Wait(); client.Projects.ReorderAsync(new ReorderEntry(project.Id, 1)).Wait(); - client.Projects.MoveAsync(new MoveArgument(project.Id, null)); + client.Projects.MoveAsync(new MoveArgument(project.Id, null)).Wait(); client.Projects.DeleteAsync(project.Id).Wait(); } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void CreateArchiveAndDelete_Success() { var client = TodoistClientFactory.Create(_outputHelper); @@ -86,7 +86,7 @@ public void CreateArchiveAndDelete_Success() } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void CreateProjectAndGetProjectData_Success() { var client = TodoistClientFactory.Create(_outputHelper); diff --git a/src/Todoist.Net.Tests/Services/ReminersServiceTests.cs b/src/Todoist.Net.Tests/Services/ReminersServiceTests.cs index 51a75ea..a0ae773 100644 --- a/src/Todoist.Net.Tests/Services/ReminersServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/ReminersServiceTests.cs @@ -10,7 +10,7 @@ namespace Todoist.Net.Tests.Services { [Collection(Constants.TodoistApiTestCollectionName)] - [IntegrationPremium] + [Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)] public class ReminersServiceTests { private readonly ITestOutputHelper _outputHelper; diff --git a/src/Todoist.Net.Tests/Services/SectionServiceTests.cs b/src/Todoist.Net.Tests/Services/SectionServiceTests.cs index 39be166..4402c63 100644 --- a/src/Todoist.Net.Tests/Services/SectionServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/SectionServiceTests.cs @@ -9,7 +9,7 @@ namespace Todoist.Net.Tests.Services { [Collection(Constants.TodoistApiTestCollectionName)] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public class SectionServiceTests { private readonly ITestOutputHelper _outputHelper; diff --git a/src/Todoist.Net.Tests/Services/SharingServiceTests.cs b/src/Todoist.Net.Tests/Services/SharingServiceTests.cs index 4b9f79e..cd8156e 100644 --- a/src/Todoist.Net.Tests/Services/SharingServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/SharingServiceTests.cs @@ -9,7 +9,7 @@ namespace Todoist.Net.Tests.Services { [Collection(Constants.TodoistApiTestCollectionName)] - [IntegrationPremium] + [Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)] public class SharingServiceTests { private readonly ITestOutputHelper _outputHelper; diff --git a/src/Todoist.Net.Tests/Services/TemplateServiceTests.cs b/src/Todoist.Net.Tests/Services/TemplateServiceTests.cs index cabc205..6d55deb 100644 --- a/src/Todoist.Net.Tests/Services/TemplateServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/TemplateServiceTests.cs @@ -11,7 +11,7 @@ namespace Todoist.Net.Tests.Services { [Collection(Constants.TodoistApiTestCollectionName)] - [IntegrationPremium] + [Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)] public class TemplateServiceTests { private readonly ITestOutputHelper _outputHelper; diff --git a/src/Todoist.Net.Tests/Services/TransactionTests.cs b/src/Todoist.Net.Tests/Services/TransactionTests.cs index fceaac7..2f232aa 100644 --- a/src/Todoist.Net.Tests/Services/TransactionTests.cs +++ b/src/Todoist.Net.Tests/Services/TransactionTests.cs @@ -18,7 +18,7 @@ public TransactionTests(ITestOutputHelper outputHelper) } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void CreateProjectAndCreateNote_Success() { var client = TodoistClientFactory.Create(_outputHelper); diff --git a/src/Todoist.Net.Tests/Services/UploadServiceTests.cs b/src/Todoist.Net.Tests/Services/UploadServiceTests.cs index 257d748..d15235a 100644 --- a/src/Todoist.Net.Tests/Services/UploadServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/UploadServiceTests.cs @@ -20,12 +20,12 @@ public UploadServiceTests(ITestOutputHelper outputHelper) } [Fact] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public void CreateGetDeleteAsync_Success() { var client = TodoistClientFactory.Create(_outputHelper); - var fileName = $"{Guid.NewGuid().ToString()}.txt"; + var fileName = $"{Guid.NewGuid()}.txt"; var upload = client.Uploads.UploadAsync(fileName, Encoding.UTF8.GetBytes("hello")).Result; var allUploads = client.Uploads.GetAsync().Result; diff --git a/src/Todoist.Net.Tests/Services/UsersServiceTests.cs b/src/Todoist.Net.Tests/Services/UsersServiceTests.cs index e3ed7ed..14f1c1a 100644 --- a/src/Todoist.Net.Tests/Services/UsersServiceTests.cs +++ b/src/Todoist.Net.Tests/Services/UsersServiceTests.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Todoist.Net.Models; using Todoist.Net.Tests.Extensions; @@ -19,38 +20,39 @@ public UsersServiceTests(ITestOutputHelper outputHelper) } [Fact] - [IntegrationFree] - public void GetCurrentAsync_Success() + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] + public async Task GetCurrentAsync_Success() { var client = TodoistClientFactory.Create(_outputHelper); - var user = client.Users.GetCurrentAsync().Result; + var user = await client.Users.GetCurrentAsync(); Assert.NotNull(user); Assert.True(user.Id > 0); } [Fact] - [IntegrationFree] - public void RegisterUpdateSettingsAndDeleteUser_Success() + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] + public async Task RegisterUpdateSettingsAndDeleteUser_Success() { var todoistTokenlessClient = TodoistClientFactory.CreateTokenlessClient(); - var userBase = new UserBase(Guid.NewGuid().ToString("N") + "@example.com", "test user", "Pa$$W@rd"); - var userInfo = todoistTokenlessClient.RegisterUserAsync(userBase).Result; + + 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 = todoistTokenlessClient.LoginAsync(userBase.Email, userBase.Password).Result; + var todoistClient = await todoistTokenlessClient.LoginAsync(userBase.Email, userBase.Password); + await todoistClient.Users.UpdateKarmaGoalsAsync(new KarmaGoals() { KarmaDisabled = true }); + + if (userInfo.HasPassword) + { + userInfo.CurrentPassword = password; + } - todoistClient.Users.UpdateNotificationSettingsAsync( - NotificationType.ItemCompleted, - NotificationService.Email, - true); - todoistClient.Users.UpdateKarmaGoalsAsync(new KarmaGoals() { KarmaDisabled = true }) - .Wait(); - todoistClient.Users.UpdateAsync(userInfo) - .Wait(); + await todoistClient.Users.UpdateAsync(userInfo); - todoistClient.Users.DeleteAsync(userBase.Password, "test"); + await todoistClient.Users.DeleteAsync(userBase.Password, "test"); todoistClient.Dispose(); } diff --git a/src/Todoist.Net.Tests/Todoist.Net.Tests.csproj b/src/Todoist.Net.Tests/Todoist.Net.Tests.csproj index 1015e25..d14eb1c 100644 --- a/src/Todoist.Net.Tests/Todoist.Net.Tests.csproj +++ b/src/Todoist.Net.Tests/Todoist.Net.Tests.csproj @@ -4,10 +4,6 @@ - - all - runtime; build; native; contentfiles; analyzers - diff --git a/src/Todoist.Net.Tests/TodoistClientTests.cs b/src/Todoist.Net.Tests/TodoistClientTests.cs index cc37faa..a7f9ba5 100644 --- a/src/Todoist.Net.Tests/TodoistClientTests.cs +++ b/src/Todoist.Net.Tests/TodoistClientTests.cs @@ -1,3 +1,5 @@ +using System.Threading.Tasks; + using Todoist.Net.Tests.Extensions; using Xunit; @@ -6,7 +8,7 @@ namespace Todoist.Net.Tests { [Collection(Constants.TodoistApiTestCollectionName)] - [IntegrationFree] + [Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)] public class TodoistClientTests { private readonly ITestOutputHelper _outputHelper; @@ -17,11 +19,22 @@ public TodoistClientTests(ITestOutputHelper outputHelper) } [Fact] - public void GetAllResources_Success() + public async Task GetAllResources_Success() + { + var client = TodoistClientFactory.Create(_outputHelper); + + var resources = await client.GetResourcesAsync(); + + Assert.NotNull(resources); + } + + [Fact] + public async Task GetAllResourcesWithSyncToken_Success() { var client = TodoistClientFactory.Create(_outputHelper); - var resources = client.GetResourcesAsync().Result; + var resources = await client.GetResourcesAsync(); + resources = await client.GetResourcesAsync(resources.SyncToken); Assert.NotNull(resources); } diff --git a/src/Todoist.Net/Models/CommandType.cs b/src/Todoist.Net/Models/CommandType.cs index 11a7c55..d702023 100644 --- a/src/Todoist.Net/Models/CommandType.cs +++ b/src/Todoist.Net/Models/CommandType.cs @@ -23,8 +23,6 @@ private CommandType(string command) public static CommandType AddSection { get; } = new CommandType("section_add"); - public static CommandType ArchiveItem { get; } = new CommandType("item_archive"); - public static CommandType ArchiveProject { get; } = new CommandType("project_archive"); public static CommandType ArchiveSection { get; } = new CommandType("section_archive"); @@ -74,8 +72,6 @@ private CommandType(string command) public static CommandType ShareProject { get; } = new CommandType("share_project"); - public static CommandType UnArchiveItem { get; } = new CommandType("item_unarchive"); - public static CommandType UnarchiveProject { get; } = new CommandType("project_unarchive"); public static CommandType UnarchiveSection { get; } = new CommandType("section_unarchive"); diff --git a/src/Todoist.Net/Models/CompleteItemArgument.cs b/src/Todoist.Net/Models/CompleteItemArgument.cs index 709f7e3..6705a3c 100644 --- a/src/Todoist.Net/Models/CompleteItemArgument.cs +++ b/src/Todoist.Net/Models/CompleteItemArgument.cs @@ -1,4 +1,4 @@ -using System; +using System; using Newtonsoft.Json; @@ -14,18 +14,13 @@ public class CompleteItemArgument : ICommandArgument /// Initializes a new instance of the class. /// /// The identifier. - /// + /// /// The date completed. If not set, the server will set the value to the current timestamp. /// - /// - /// The force history. When enabled the item is moved to history irregardless of whether it’s a - /// sub-task or not (by default only root tasks are moved to history). - /// - public CompleteItemArgument(ComplexId id, DateTime? dateCompleted = null, bool? forceHistory = null) + public CompleteItemArgument(ComplexId id, DateTime? completedAt = null) { Id = id; - DateCompleted = dateCompleted; - ForceHistory = forceHistory; + CompletedAt = completedAt; } /// @@ -34,17 +29,8 @@ public CompleteItemArgument(ComplexId id, DateTime? dateCompleted = null, bool? /// /// The date completed. /// - [JsonProperty("date_completed")] - public DateTime? DateCompleted { get; } - - /// - /// Gets the force history. - /// - /// - /// The force history. - /// - [JsonProperty("force_history")] - public bool? ForceHistory { get; } + [JsonProperty("completed_at")] + public DateTime? CompletedAt { get; } /// /// Gets the identifier. diff --git a/src/Todoist.Net/Models/ComplexId.cs b/src/Todoist.Net/Models/ComplexId.cs index f01fbdd..543ae1c 100644 --- a/src/Todoist.Net/Models/ComplexId.cs +++ b/src/Todoist.Net/Models/ComplexId.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Todoist.Net.Models { @@ -11,7 +11,7 @@ public struct ComplexId : IEquatable /// Initializes a new instance of the struct. /// /// The persistent identifier. - public ComplexId(long persistentId) + public ComplexId(string persistentId) : this() { PersistentId = persistentId; @@ -31,7 +31,7 @@ public ComplexId(Guid tempId) /// Gets the persistent identifier. /// /// The persistent identifier. - public long PersistentId { get; } + public string PersistentId { get; } /// /// Gets the temporary identifier. @@ -85,7 +85,7 @@ internal object DynamicId /// /// The i. /// The result of the conversion. - public static implicit operator ComplexId(long i) + public static implicit operator ComplexId(string i) { return new ComplexId(i); } @@ -143,9 +143,9 @@ public override int GetHashCode() /// A that represents this instance. public override string ToString() { - if (PersistentId != default(int)) + if (!string.IsNullOrEmpty(PersistentId)) { - return PersistentId.ToString(); + return PersistentId; } if (TempId != default) diff --git a/src/Todoist.Net/Models/DueDate.cs b/src/Todoist.Net/Models/DueDate.cs index 8e6d8c3..2eda686 100644 --- a/src/Todoist.Net/Models/DueDate.cs +++ b/src/Todoist.Net/Models/DueDate.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Globalization; using Newtonsoft.Json; @@ -103,7 +103,7 @@ internal DueDate() /// The string date. /// /// - /// Format date according this rules https://developer.todoist.com/sync/v8/?shell#due-dates + /// Format date according this rules https://developer.todoist.com/sync/v9/?shell#due-dates /// [JsonProperty("date")] internal string StringDate diff --git a/src/Todoist.Net/Models/Filter.cs b/src/Todoist.Net/Models/Filter.cs index c692d5a..c3e8fe6 100644 --- a/src/Todoist.Net/Models/Filter.cs +++ b/src/Todoist.Net/Models/Filter.cs @@ -1,9 +1,7 @@ -using System; +using System; using Newtonsoft.Json; -using Todoist.Net.Serialization.Converters; - namespace Todoist.Net.Models { /// @@ -50,7 +48,7 @@ internal Filter() /// The color. /// [JsonProperty("color")] - public int? Color { get; set; } + public string Color { get; set; } /// /// Gets a value indicating whether this instance is deleted. @@ -59,9 +57,17 @@ internal Filter() /// true if this instance is deleted; otherwise, false. /// [JsonProperty("is_deleted")] - [JsonConverter(typeof(BoolConverter))] public bool IsDeleted { get; internal set; } + /// + /// Gets a value indicating whether this instance is favorite. + /// + /// + /// true if this instance is favorite; otherwise, false. + /// + [JsonProperty("is_favorite")] + public bool IsFavorite { get; internal set; } + /// /// Gets or sets the item order. /// diff --git a/src/Todoist.Net/Models/IWithRelationsArgument.cs b/src/Todoist.Net/Models/IWithRelationsArgument.cs index 8b367f4..847eeed 100644 --- a/src/Todoist.Net/Models/IWithRelationsArgument.cs +++ b/src/Todoist.Net/Models/IWithRelationsArgument.cs @@ -1,10 +1,10 @@ -using System; +using System; using System.Collections.Generic; namespace Todoist.Net.Models { internal interface IWithRelationsArgument { - void UpdateRelatedTempIds(IDictionary map); + void UpdateRelatedTempIds(IDictionary map); } } diff --git a/src/Todoist.Net/Models/Item.cs b/src/Todoist.Net/Models/Item.cs index e33b556..57bb914 100644 --- a/src/Todoist.Net/Models/Item.cs +++ b/src/Todoist.Net/Models/Item.cs @@ -1,11 +1,9 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using Newtonsoft.Json; -using Todoist.Net.Serialization.Converters; - namespace Todoist.Net.Models { /// @@ -33,19 +31,26 @@ public Item(string content, ComplexId projectId) { Content = content; ProjectId = projectId; - Labels = new Collection(); + Labels = new Collection(); } internal Item() { } + /// + /// Gets or sets the added by uid. + /// + /// The added by uid. + [JsonProperty("added_by_uid")] + public string AddedByUid { get; set; } + /// /// Gets or sets the assigned by uid. /// /// The assigned by uid. [JsonProperty("assigned_by_uid")] - public long? AssignedByUid { get; set; } + public string AssignedByUid { get; set; } /// /// Gets or sets order of project. Defines the position of the project among all the projects with the same parent_id. @@ -58,7 +63,6 @@ internal Item() /// Gets or sets a value indicating whether this is collapsed. /// /// null if [collapsed] contains no value, true if [collapsed]; otherwise, false. - [JsonConverter(typeof(BoolConverter))] [JsonProperty("collapsed")] public bool? Collapsed { get; set; } @@ -73,8 +77,8 @@ internal Item() /// Gets the date added. /// /// The date added. - [JsonProperty("date_added")] - public DateTime? DateAdded { get; internal set; } + [JsonProperty("added_at")] + public DateTime? AddedAt { get; internal set; } /// /// Gets or sets the day order. @@ -99,27 +103,10 @@ internal Item() [JsonProperty("due")] public DueDate DueDate { get; set; } - /// - /// Gets a value indicating whether [in history]. - /// - /// null if [in history] contains no value, true if [in history]; otherwise, false. - [JsonConverter(typeof(BoolConverter))] - [JsonProperty("in_history")] - public bool? InHistory { get; internal set; } - - /// - /// Gets a value indicating whether this instance is archived. - /// - /// null if [is archived] contains no value, true if [is archived]; otherwise, false. - [JsonConverter(typeof(BoolConverter))] - [JsonProperty("is_archived")] - public bool? IsArchived { get; internal set; } - /// /// Gets a value indicating whether this instance is checked. /// /// null if [is checked] contains no value, true if [is checked]; otherwise, false. - [JsonConverter(typeof(BoolConverter))] [JsonProperty("checked")] public bool? IsChecked { get; internal set; } @@ -127,7 +114,6 @@ internal Item() /// Gets a value indicating whether this instance is deleted. /// /// null if [is deleted] contains no value, true if [is deleted]; otherwise, false. - [JsonConverter(typeof(BoolConverter))] [JsonProperty("is_deleted")] public bool? IsDeleted { get; internal set; } @@ -136,7 +122,7 @@ internal Item() /// /// The labels. [JsonProperty("labels")] - public ICollection Labels { get; internal set; } + public ICollection Labels { get; internal set; } /// /// Gets or sets the id of the parent task. Set to for root tasks. @@ -145,7 +131,7 @@ internal Item() /// The parent identifier. /// [JsonProperty("parent_id")] - public long? ParentId { get; set; } + public string ParentId { get; set; } /// /// Gets or sets the priority. @@ -166,14 +152,14 @@ internal Item() /// /// The responsible uid. [JsonProperty("responsible_uid")] - public long? ResponsibleUid { get; set; } + public string ResponsibleUid { get; set; } /// /// Gets or sets section of project. Defines the section that the task belongs to. /// /// The project order. [JsonProperty("section_id")] - public long? Section { get; set; } + public string Section { get; set; } /// @@ -181,20 +167,20 @@ internal Item() /// /// The synchronize identifier. [JsonProperty("sync_id")] - public long? SyncId { get; internal set; } + public string SyncId { get; internal set; } /// /// Gets the user identifier. /// /// The user identifier. [JsonProperty("user_id")] - public long? UserId { get; internal set; } + public string UserId { get; internal set; } /// /// Updates the related temporary ids. /// /// The map. - void IWithRelationsArgument.UpdateRelatedTempIds(IDictionary map) + void IWithRelationsArgument.UpdateRelatedTempIds(IDictionary map) { if (ProjectId.HasValue && map.TryGetValue(ProjectId.Value.TempId, out var persistentProjectId)) { diff --git a/src/Todoist.Net/Models/Label.cs b/src/Todoist.Net/Models/Label.cs index cbc78a7..25063f6 100644 --- a/src/Todoist.Net/Models/Label.cs +++ b/src/Todoist.Net/Models/Label.cs @@ -1,9 +1,7 @@ -using System; +using System; using Newtonsoft.Json; -using Todoist.Net.Serialization.Converters; - namespace Todoist.Net.Models { /// @@ -32,16 +30,24 @@ public Label(string name) /// /// The color. [JsonProperty("color")] - public int Color { get; set; } + public string Color { get; set; } /// /// Gets a value indicating whether this instance is deleted. /// /// true if this instance is deleted; otherwise, false. [JsonProperty("is_deleted")] - [JsonConverter(typeof(BoolConverter))] public bool IsDeleted { get; internal set; } + /// + /// Gets a value indicating whether this instance is favorite. + /// + /// + /// true if this instance is favorite; otherwise, false. + /// + [JsonProperty("is_favorite")] + public bool IsFavorite { get; internal set; } + /// /// Gets or sets the item order. /// diff --git a/src/Todoist.Net/Models/Note.cs b/src/Todoist.Net/Models/Note.cs index a3402e1..1acc318 100644 --- a/src/Todoist.Net/Models/Note.cs +++ b/src/Todoist.Net/Models/Note.cs @@ -1,11 +1,9 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using Newtonsoft.Json; -using Todoist.Net.Serialization.Converters; - namespace Todoist.Net.Models { /// @@ -22,7 +20,7 @@ public Note(string content) { Content = content; - UserIdsToNotify = new Collection(); + UserIdsToNotify = new Collection(); } /// @@ -39,20 +37,11 @@ public Note(string content) [JsonProperty("file_attachment")] public FileAttachment FileAttachment { get; set; } - /// - /// Gets the is archived. - /// - /// The is archived. - [JsonProperty("is_archived")] - [JsonConverter(typeof(BoolConverter))] - public bool? IsArchived { get; internal set; } - /// /// Gets the is deleted. /// /// The is deleted. [JsonProperty("is_deleted")] - [JsonConverter(typeof(BoolConverter))] public bool? IsDeleted { get; internal set; } /// @@ -66,15 +55,15 @@ public Note(string content) /// Gets the posted. /// /// The posted. - [JsonProperty("posted")] - public DateTime? Posted { get; internal set; } + [JsonProperty("posted_at")] + public DateTime? PostedAt { get; internal set; } /// /// Gets the posted user identifier. /// /// The posted user identifier. [JsonProperty("posted_uid")] - public long? PostedUserId { get; internal set; } + public string PostedUserId { get; internal set; } /// /// Gets the project identifier. @@ -88,13 +77,13 @@ public Note(string content) /// /// The user ids to notify. [JsonProperty("uids_to_notify")] - public ICollection UserIdsToNotify { get; internal set; } + public ICollection UserIdsToNotify { get; internal set; } /// /// Updates the related temporary ids. /// /// The map. - void IWithRelationsArgument.UpdateRelatedTempIds(IDictionary map) + void IWithRelationsArgument.UpdateRelatedTempIds(IDictionary map) { if (ProjectId.HasValue && map.TryGetValue(ProjectId.Value.TempId, out var persistentProjectId)) { diff --git a/src/Todoist.Net/Models/Notification.cs b/src/Todoist.Net/Models/Notification.cs index a34b5ad..4dd7ed6 100644 --- a/src/Todoist.Net/Models/Notification.cs +++ b/src/Todoist.Net/Models/Notification.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Dynamic; @@ -17,22 +17,22 @@ public class Notification : DynamicObject /// Gets the created. /// /// The created. - [JsonProperty("created")] - public DateTime Created { get; internal set; } + [JsonProperty("created_at")] + public DateTime CreatedAt { get; internal set; } /// /// Gets from uid. /// /// From uid. [JsonProperty("from_uid")] - public long FromUid { get; internal set; } + public string FromUid { get; internal set; } /// /// Gets the identifier. /// /// The identifier. [JsonProperty("id")] - public long Id { get; internal set; } + public string Id { get; internal set; } /// /// Gets the notification key. diff --git a/src/Todoist.Net/Models/Project.cs b/src/Todoist.Net/Models/Project.cs index 7aaabe3..5944c46 100644 --- a/src/Todoist.Net/Models/Project.cs +++ b/src/Todoist.Net/Models/Project.cs @@ -1,6 +1,4 @@ -using Newtonsoft.Json; - -using Todoist.Net.Serialization.Converters; +using Newtonsoft.Json; namespace Todoist.Net.Models { @@ -23,7 +21,6 @@ public Project(string name) /// Gets or sets a value indicating whether this is collapsed. /// /// null if [collapsed] contains no value, true if [collapsed]; otherwise, false. - [JsonConverter(typeof(BoolConverter))] [JsonProperty("collapsed")] public bool? Collapsed { get; set; } @@ -32,20 +29,19 @@ public Project(string name) /// /// The color. [JsonProperty("color")] - public int? Color { get; set; } + public string Color { get; set; } /// /// Gets or sets the indent. /// /// The indent. [JsonProperty("parent_id")] - public long? ParentId { get; set; } + public string ParentId { get; set; } /// /// Gets a value indicating whether this instance is archived. /// /// true if this instance is archived; otherwise, false. - [JsonConverter(typeof(BoolConverter))] [JsonProperty("is_archived")] public bool IsArchived { get; internal set; } @@ -53,10 +49,18 @@ public Project(string name) /// Gets a value indicating whether this instance is deleted. /// /// true if this instance is deleted; otherwise, false. - [JsonConverter(typeof(BoolConverter))] [JsonProperty("is_deleted")] public bool IsDeleted { get; internal set; } + /// + /// Gets a value indicating whether this instance is favorite. + /// + /// + /// true if this instance is favorite; otherwise, false. + /// + [JsonProperty("is_favorite")] + public bool IsFavorite { get; internal set; } + /// /// Gets or sets order of project. Defines the position of the project among all the projects with the same parent_id. /// diff --git a/src/Todoist.Net/Models/Reminder.cs b/src/Todoist.Net/Models/Reminder.cs index 10dae47..f24ce63 100644 --- a/src/Todoist.Net/Models/Reminder.cs +++ b/src/Todoist.Net/Models/Reminder.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using Todoist.Net.Serialization.Converters; @@ -71,14 +71,7 @@ internal Reminder() /// /// The notify uid. [JsonProperty("notify_uid")] - public long? NotifyUid { get; set; } - - /// - /// Gets or sets the service. - /// - /// The service. - [JsonProperty("service")] - public ReminderService Service { get; set; } + public string NotifyUid { get; set; } /// /// Gets or sets the type. diff --git a/src/Todoist.Net/Models/Section.cs b/src/Todoist.Net/Models/Section.cs index 4c9a254..382d539 100644 --- a/src/Todoist.Net/Models/Section.cs +++ b/src/Todoist.Net/Models/Section.cs @@ -1,9 +1,7 @@ -using System; +using System; using Newtonsoft.Json; -using Todoist.Net.Serialization.Converters; - namespace Todoist.Net.Models { /// @@ -48,8 +46,8 @@ internal Section() /// /// The date when the section was created. /// - [JsonProperty("date_added")] - public DateTime? DateAdded { get; internal set; } + [JsonProperty("added_at")] + public DateTime? AddedAt { get; internal set; } /// /// Gets the date archived. @@ -57,14 +55,13 @@ internal Section() /// /// The date when the section was archived (or null if not archived). /// - [JsonProperty("date_archived")] - public DateTime? DateArchived { get; internal set; } + [JsonProperty("archived_at")] + public DateTime? ArchivedAt { get; internal set; } /// /// Gets a value indicating whether this instance is archived. /// /// true if this instance is archived; otherwise, false. - [JsonConverter(typeof(BoolConverter))] [JsonProperty("is_archived")] public bool IsArchived { get; internal set; } @@ -74,7 +71,6 @@ internal Section() /// /// true if the section’s tasks are collapsed; otherwise, false. /// - [JsonConverter(typeof(BoolConverter))] [JsonProperty("collapsed")] public bool IsCollapsed { get; set; } @@ -82,20 +78,9 @@ internal Section() /// Gets a value indicating whether this instance is deleted. /// /// true if this instance is deleted; otherwise, false. - [JsonConverter(typeof(BoolConverter))] [JsonProperty("is_deleted")] public bool IsDeleted { get; internal set; } - /// - /// Gets the legacy project identifier. - /// - /// - /// Legacy project id for the project that the section resides in. - /// (only shown for objects created before 1 April 2017) - /// - [JsonProperty("legacy_project_id")] - public long? LegacyProjectId { get; internal set; } - /// /// Gets or sets the name. /// diff --git a/src/Todoist.Net/Models/SyncResponse.cs b/src/Todoist.Net/Models/SyncResponse.cs index fafebc8..ef30dea 100644 --- a/src/Todoist.Net/Models/SyncResponse.cs +++ b/src/Todoist.Net/Models/SyncResponse.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Newtonsoft.Json; @@ -11,6 +11,6 @@ internal class SyncResponse public Dictionary SyncStatus { get; set; } [JsonProperty("temp_id_mapping")] - public Dictionary TempIdMappings { get; set; } + public Dictionary TempIdMappings { get; set; } } } diff --git a/src/Todoist.Net/Models/User.cs b/src/Todoist.Net/Models/User.cs index 636c32a..dc98bfa 100644 --- a/src/Todoist.Net/Models/User.cs +++ b/src/Todoist.Net/Models/User.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; namespace Todoist.Net.Models { @@ -30,6 +30,17 @@ internal User() [JsonProperty("auto_reminder")] public long? AutoReminder { get; set; } + /// + /// The user's current password. + /// This must be provided if the request is modifying the user's password or email address and the user already has a password set (indicated by has_password in the user object). + /// For amending other properties this is not required. + /// + /// + /// The current password. + /// + [JsonProperty("current_password")] + public string CurrentPassword { get; set; } + /// /// Gets or sets the date format. /// @@ -37,27 +48,6 @@ internal User() [JsonProperty("date_format")] public DateFormat? DateFormat { get; set; } - /// - /// Gets or sets the default reminder. - /// - /// The default reminder. - [JsonProperty("default_reminder")] - public ReminderService DefaultReminder { get; set; } - - /// - /// Gets or sets the mobile host. - /// - /// The mobile host. - [JsonProperty("mobile_host")] - public string MobileHost { get; set; } - - /// - /// Gets or sets the mobile number. - /// - /// The mobile number. - [JsonProperty("mobile_number")] - public string MobileNumber { get; set; } - /// /// Gets or sets the next week. /// @@ -90,8 +80,8 @@ internal User() /// Gets or sets the theme. /// /// The theme. - [JsonProperty("theme")] - public int? Theme { get; set; } + [JsonProperty("theme_id")] + public string Theme { get; set; } /// /// Gets or sets the time format. diff --git a/src/Todoist.Net/Models/UserInfo.cs b/src/Todoist.Net/Models/UserInfo.cs index dbd0111..8791696 100644 --- a/src/Todoist.Net/Models/UserInfo.cs +++ b/src/Todoist.Net/Models/UserInfo.cs @@ -1,4 +1,4 @@ -using System; +using System; using Newtonsoft.Json; @@ -51,7 +51,7 @@ internal UserInfo() /// /// The business account identifier. [JsonProperty("business_account_id")] - public long BusinessAccountId { get; internal set; } + public string BusinessAccountId { get; internal set; } /// /// Gets the completed count. @@ -67,6 +67,16 @@ internal UserInfo() [JsonProperty("completed_today")] public int CompletedToday { get; internal set; } + /// + /// Whether the user has a password set on the account. + /// It will be false if they have only authenticated without a password (e.g. using Google, Facebook, etc.) + /// + /// + /// true if the user has password; otherwise, false. + /// + [JsonProperty("has_password")] + public bool HasPassword { get; set; } + /// /// Gets the identifier. /// @@ -85,8 +95,8 @@ internal UserInfo() /// Gets the inbox project. /// /// The inbox project. - [JsonProperty("inbox_project")] - public long InboxProject { get; internal set; } + [JsonProperty("inbox_project_id")] + public string InboxProjectId { get; internal set; } /// /// Gets a value indicating whether this instance is biz admin. @@ -106,8 +116,8 @@ internal UserInfo() /// Gets the join date. /// /// The join date. - [JsonProperty("join_date")] - public DateTime? JoinDate { get; internal set; } + [JsonProperty("joined_at")] + public DateTime? JoinedAt { get; internal set; } /// /// Gets the karma. @@ -130,6 +140,15 @@ internal UserInfo() [JsonProperty("premium_until")] public DateTime? PremiumUntil { get; internal set; } + /// + /// Gets the team inbox identifier. + /// + /// + /// The team inbox identifier. + /// + [JsonProperty("team_inbox_id")] + public string TeamInboxId { get; internal set; } + /// /// Gets the token. /// diff --git a/src/Todoist.Net/Serialization/Converters/ComplexIdConverter.cs b/src/Todoist.Net/Serialization/Converters/ComplexIdConverter.cs index a89b5f8..e9e8e1b 100644 --- a/src/Todoist.Net/Serialization/Converters/ComplexIdConverter.cs +++ b/src/Todoist.Net/Serialization/Converters/ComplexIdConverter.cs @@ -1,4 +1,4 @@ -using System; +using System; using Newtonsoft.Json; @@ -19,9 +19,10 @@ public override object ReadJson( object existingValue, JsonSerializer serializer) { - if (long.TryParse(reader.Value?.ToString(), out var result)) + var value = reader.Value?.ToString(); + if (!string.IsNullOrEmpty(value)) { - return new ComplexId(result); + return new ComplexId(value); } return new ComplexId(); diff --git a/src/Todoist.Net/Serialization/Resolvers/ConverterContractResolver.cs b/src/Todoist.Net/Serialization/Resolvers/ConverterContractResolver.cs index 393d15d..265ec4e 100644 --- a/src/Todoist.Net/Serialization/Resolvers/ConverterContractResolver.cs +++ b/src/Todoist.Net/Serialization/Resolvers/ConverterContractResolver.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Reflection; using Newtonsoft.Json; @@ -36,7 +36,7 @@ protected override JsonProperty CreateProperty(MemberInfo member, MemberSerializ } // Null DueDate == no DueDate, so we should always send the DueDate - // https://developer.todoist.com/sync/v8/#due-dates + // https://developer.todoist.com/sync/v9/#due-dates else if (property.PropertyType == typeof(DueDate)) { property.NullValueHandling = NullValueHandling.Include; diff --git a/src/Todoist.Net/Services/IItemsCommandService.cs b/src/Todoist.Net/Services/IItemsCommandService.cs index 5a86537..63a7b12 100644 --- a/src/Todoist.Net/Services/IItemsCommandService.cs +++ b/src/Todoist.Net/Services/IItemsCommandService.cs @@ -133,31 +133,5 @@ public interface IItemsCommandService /// Command execution exception. /// is Task CompleteAsync(CompleteItemArgument completeItemArgument); - - /// - /// Archives a task and all its descendants asynchronous. - /// - /// The item ID. - /// Returns .The task object representing the asynchronous operation. - /// Command execution exception. - /// API exception. - /// - /// It is mostly intended to allow users to force sub-tasks to be moved to the history since root tasks are automatically - /// archived upon completion. See also item_close for a simplified version of the command. - /// - Task ArchiveAsync(ComplexId id); - - /// - /// UnArchives a task and all its descendants asynchronous. - /// - /// The item ID. - /// Returns .The task object representing the asynchronous operation. - /// Command execution exception. - /// API exception. - /// - /// No ancestors will be restored from the history. Instead, the item is unarchived (and uncompleted) alone, loses any - /// parent relationship (becomes a project root item), and is placed at the end of the list of other project root items. - /// - Task UnArchiveAsync(ComplexId id); } } diff --git a/src/Todoist.Net/Services/IUsersService.cs b/src/Todoist.Net/Services/IUsersService.cs index 68bed36..45db8cb 100644 --- a/src/Todoist.Net/Services/IUsersService.cs +++ b/src/Todoist.Net/Services/IUsersService.cs @@ -27,19 +27,5 @@ public interface IUsersService : IUsersCommandService /// The current user info. /// API exception. Task GetCurrentAsync(); - - /// - /// Gets the current user info. - /// - /// Type of the notification. - /// The service. - /// The notify. - /// The current user info. - /// API exception. - /// or is - Task UpdateNotificationSettingsAsync( - NotificationType notificationType, - NotificationService service, - bool notify); } } \ No newline at end of file diff --git a/src/Todoist.Net/Services/ItemsCommandService.cs b/src/Todoist.Net/Services/ItemsCommandService.cs index 3938334..d90d717 100644 --- a/src/Todoist.Net/Services/ItemsCommandService.cs +++ b/src/Todoist.Net/Services/ItemsCommandService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; @@ -66,42 +66,6 @@ public Task CloseAsync(ComplexId id) return ExecuteCommandAsync(command); } - /// - /// Archives a task and all its descendants asynchronous. - /// - /// The item ID. - /// Returns .The task object representing the asynchronous operation. - /// Command execution exception. - /// API exception. - /// - /// It is mostly intended to allow users to force sub-tasks to be moved to the history since root tasks are automatically - /// archived upon completion. See also item_close for a simplified version of the command. - /// - public Task ArchiveAsync(ComplexId id) - { - var command = CreateEntityCommand(CommandType.ArchiveItem, id); - - return ExecuteCommandAsync(command); - } - - /// - /// UnArchives a task and all its descendants asynchronous. - /// - /// The item ID. - /// Returns .The task object representing the asynchronous operation. - /// Command execution exception. - /// API exception. - /// - /// No ancestors will be restored from the history. Instead, the item is unarchived (and uncompleted) alone, loses any - /// parent relationship (becomes a project root item), and is placed at the end of the list of other project root items. - /// - public Task UnArchiveAsync(ComplexId id) - { - var command = CreateEntityCommand(CommandType.UnArchiveItem, id); - - return ExecuteCommandAsync(command); - } - /// /// Completes tasks and optionally move them to history. See also for a simplified version of the command. /// diff --git a/src/Todoist.Net/Services/NotificationsCommandService.cs b/src/Todoist.Net/Services/NotificationsCommandService.cs index 0cfe46e..2e46516 100644 --- a/src/Todoist.Net/Services/NotificationsCommandService.cs +++ b/src/Todoist.Net/Services/NotificationsCommandService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; @@ -27,7 +27,7 @@ internal NotificationsCommandService(ICollection queue) /// API exception. public Task MarkAllReadAsync() { - var command = CreateEntityCommand(CommandType.SetLastReadNotification, 0); + var command = CreateEntityCommand(CommandType.SetLastReadNotification, null); return ExecuteCommandAsync(command); } diff --git a/src/Todoist.Net/Services/UsersService.cs b/src/Todoist.Net/Services/UsersService.cs index 0529f6b..341b10b 100644 --- a/src/Todoist.Net/Services/UsersService.cs +++ b/src/Todoist.Net/Services/UsersService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; @@ -56,37 +56,5 @@ public async Task GetCurrentAsync() return response.UserInfo; } - - /// - /// Gets the current user info. - /// - /// Type of the notification. - /// The service. - /// The notify. - /// The current user info. - /// API exception. - /// or is - public Task UpdateNotificationSettingsAsync( - NotificationType notificationType, - NotificationService service, - bool notify) - { - if (notificationType == null) - { - throw new ArgumentNullException(nameof(notificationType)); - } - - if (service == null) - { - throw new ArgumentNullException(nameof(service)); - } - - var parameters = new LinkedList>(); - parameters.AddLast(new KeyValuePair("notification_type", notificationType.Value)); - parameters.AddLast(new KeyValuePair("service", service.Value)); - parameters.AddLast(new KeyValuePair("dont_notify", notify ? "0" : "1")); - - return TodoistClient.PostAsync("notification_settings/update", parameters); - } } } diff --git a/src/Todoist.Net/Todoist.Net.csproj b/src/Todoist.Net/Todoist.Net.csproj index b759f82..ff32373 100644 --- a/src/Todoist.Net/Todoist.Net.csproj +++ b/src/Todoist.Net/Todoist.Net.csproj @@ -1,8 +1,8 @@ - + A Todoist API client for .NET - 2.3.0 + 3.0.0 Oleg Shevchenko netstandard2.0;net45 true diff --git a/src/Todoist.Net/TodoistClient.cs b/src/Todoist.Net/TodoistClient.cs index bcd98a3..cceb9fc 100644 --- a/src/Todoist.Net/TodoistClient.cs +++ b/src/Todoist.Net/TodoistClient.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net; @@ -485,7 +485,7 @@ private void TryAddToken(ICollection> parameters) } } - private void UpdateTempIds(Command[] commands, IDictionary tempIdMappings) + private void UpdateTempIds(Command[] commands, IDictionary tempIdMappings) { foreach (var command in commands) { diff --git a/src/Todoist.Net/TodoistRestClient.cs b/src/Todoist.Net/TodoistRestClient.cs index cb64671..4c8372a 100644 --- a/src/Todoist.Net/TodoistRestClient.cs +++ b/src/Todoist.Net/TodoistRestClient.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Net; using System.Net.Http; @@ -24,7 +24,7 @@ public TodoistRestClient(IWebProxy proxy) } // ReSharper disable once ExceptionNotDocumented - _httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri("https://todoist.com/API/v8/") }; + _httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri("https://api.todoist.com/sync/v9/") }; } public void Dispose()