Skip to content

Commit a89cd42

Browse files
authored
API v1 Migration - Phase 1: Core Renames (#73)
* refactor: rename Items to Tasks and Notes to Comments within file contents * refactor: rename file names from Items to Tasks and Notes to Comments. * docs+refactor: update README examples and rename Reminder.TaskId
1 parent 70c10a9 commit a89cd42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+865
-809
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ ITodoistClient client = new TodoistClient("API token");
2222

2323
Implementation of the Quick Add Task available in the official clients.
2424
```csharp
25-
var quickAddItem = new QuickAddItem("Task title @Label1 #Project1 +ExampleUser");
26-
var task = await client.Items.QuickAddAsync(quickAddItem);
25+
var quickAddTask = new QuickAddTask("Task title @Label1 #Project1 +ExampleUser");
26+
var task = await client.Tasks.QuickAddAsync(quickAddTask);
2727
```
2828

2929
### Simple API calls
3030
```csharp
31-
// Get all resources (labels, projects, tasks, notes etc.).
31+
// Get all resources (labels, projects, tasks, comments etc.).
3232
var resources = await client.GetResourcesAsync();
3333

3434
// Get only projects and labels.
@@ -40,9 +40,9 @@ var projectsOnly = await client.GetResourcesAsync(ResourceType.Projects);
4040
// Alternatively you can use this API to get projects.
4141
var projects = await client.Projects.GetAsync();
4242

43-
// Add a task with a note.
44-
var taskId = await client.Items.AddAsync(new Item("New task"));
45-
await client.Notes.AddToItemAsync(new Note("Task description"), taskId);
43+
// Add a task with a comment.
44+
var taskId = await client.Tasks.AddAsync(new AddTask("New task"));
45+
await client.Comments.AddToTaskAsync(new Comment("Task description"), taskId);
4646
```
4747

4848
### Transactions (Batching)
@@ -55,8 +55,8 @@ var transaction = client.CreateTransaction();
5555

5656
// These requests are queued and will be executed later.
5757
var projectId = await transaction.Project.AddAsync(new Project("New project"));
58-
var taskId = await transaction.Items.AddAsync(new Item("New task", projectId));
59-
await transaction.Notes.AddToItemAsync(new Note("Task description"), taskId);
58+
var taskId = await transaction.Tasks.AddAsync(new AddTask("New task", projectId));
59+
await transaction.Comments.AddToTaskAsync(new Comment("Task description"), taskId);
6060

6161
// Execute all the requests in the transaction in a single HTTP request.
6262
await transaction.CommitAsync();
@@ -71,8 +71,8 @@ since including `null` properties will update them to `null`.
7171
However, if you want to intentionally send a `null` value to the API, you need to use the `Unset` extension method, for example:
7272
```csharp
7373
// This code removes a task's due date.
74-
var task = new UpdateItem("TASK_ID");
74+
var task = new UpdateTask("TASK_ID");
7575
task.Unset(t => t.DueDate);
7676

77-
await client.Items.UpdateAsync(task);
77+
await client.Tasks.UpdateAsync(task);
7878
```

src/Todoist.Net.Tests/Services/NotesServiceTests.cs renamed to src/Todoist.Net.Tests/Services/CommentsServiceTests.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,30 @@
1212
namespace Todoist.Net.Tests.Services
1313
{
1414
[Collection(Constants.TodoistApiTestCollectionName)]
15-
public class NotesServiceTests
15+
public class CommentsServiceTests
1616
{
1717
private readonly ITestOutputHelper _outputHelper;
1818

19-
public NotesServiceTests(ITestOutputHelper outputHelper)
19+
public CommentsServiceTests(ITestOutputHelper outputHelper)
2020
{
2121
_outputHelper = outputHelper;
2222
}
2323

2424
[Fact]
2525
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
26-
public async Task AddNoteGetAndDelete_Success()
26+
public async Task AddCommentGetAndDelete_Success()
2727
{
2828
var todoistClient = TodoistClientFactory.Create(_outputHelper);
2929

3030
var project = new Project(Guid.NewGuid().ToString());
3131
await todoistClient.Projects.AddAsync(project);
3232
try
3333
{
34-
var note = new Note("Hello");
35-
await todoistClient.Notes.AddToProjectAsync(note, project.Id.PersistentId);
34+
var comment = new Comment("Hello");
35+
await todoistClient.Comments.AddToProjectAsync(comment, project.Id.PersistentId);
3636

37-
var notesInfo = await todoistClient.Notes.GetAsync();
38-
Assert.Contains(notesInfo.ProjectNotes, n => n.Id == note.Id);
37+
var commentsInfo = await todoistClient.Comments.GetAsync();
38+
Assert.Contains(commentsInfo.ProjectComments, c => c.Id == comment.Id);
3939
}
4040
finally
4141
{
@@ -45,19 +45,19 @@ public async Task AddNoteGetAndDelete_Success()
4545

4646
[Fact]
4747
[Trait(Constants.TraitName, Constants.IntegrationFreeTraitValue)]
48-
public async Task AddNoteToNewProjectAndUpdateIt_Success()
48+
public async Task AddCommentToNewProjectAndUpdateIt_Success()
4949
{
5050
var todoistClient = TodoistClientFactory.Create(_outputHelper);
5151

5252
var project = new Project(Guid.NewGuid().ToString());
5353
await todoistClient.Projects.AddAsync(project);
5454
try
5555
{
56-
var note = new Note("Hello");
57-
await todoistClient.Notes.AddToProjectAsync(note, project.Id.PersistentId);
56+
var comment = new Comment("Hello");
57+
await todoistClient.Comments.AddToProjectAsync(comment, project.Id.PersistentId);
5858

59-
note.Content = "Updated";
60-
await todoistClient.Notes.UpdateAsync(note);
59+
comment.Content = "Updated";
60+
await todoistClient.Comments.UpdateAsync(comment);
6161
}
6262
finally
6363
{
@@ -67,30 +67,30 @@ public async Task AddNoteToNewProjectAndUpdateIt_Success()
6767

6868
[Fact]
6969
[Trait(Constants.TraitName, Constants.IntegrationPremiumTraitValue)]
70-
public async Task AddNoteToNewProjectAttachFileAndDeleteIt_Success()
70+
public async Task AddCommentToNewProjectAttachFileAndDeleteIt_Success()
7171
{
7272
var client = TodoistClientFactory.Create(_outputHelper);
7373

7474
var project = new Project(Guid.NewGuid().ToString());
7575
await client.Projects.AddAsync(project);
7676
try
7777
{
78-
var note = new Note("Hello");
78+
var comment = new Comment("Hello");
7979
var fileName = "test.txt";
8080
var upload = await client.Uploads.UploadAsync(fileName, Encoding.UTF8.GetBytes("hello"));
81-
note.FileAttachment = upload;
81+
comment.FileAttachment = upload;
8282

83-
await client.Notes.AddToProjectAsync(note, project.Id.PersistentId);
83+
await client.Comments.AddToProjectAsync(comment, project.Id.PersistentId);
8484

8585
var projectInfo = await client.Projects.GetAsync(project.Id);
86-
var attachedNote = projectInfo.Notes.FirstOrDefault();
87-
Assert.NotNull(attachedNote);
88-
Assert.True(attachedNote.FileAttachment.FileName == fileName);
86+
var attachedComment = projectInfo.Comments.FirstOrDefault();
87+
Assert.NotNull(attachedComment);
88+
Assert.True(attachedComment.FileAttachment.FileName == fileName);
8989

90-
await client.Notes.DeleteAsync(attachedNote.Id);
90+
await client.Comments.DeleteAsync(attachedComment.Id);
9191

9292
projectInfo = await client.Projects.GetAsync(project.Id);
93-
Assert.Empty(projectInfo.Notes);
93+
Assert.Empty(projectInfo.Comments);
9494
}
9595
finally
9696
{

0 commit comments

Comments
 (0)