Skip to content

Commit

Permalink
Fix move project request (#22)
Browse files Browse the repository at this point in the history
* Fix move project request
  • Loading branch information
olsh authored Dec 27, 2022
1 parent ccf8c89 commit 2dc4a37
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/Todoist.Net.Tests/Services/ProjectsServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ public void CreateUpdateOrderMoveAndDelete_Success()

client.Projects.ReorderAsync(new ReorderEntry(project.Id, 1)).Wait();

// TODO: Fix the request
//client.Projects.MoveAsync(new MoveArgument(project.Id, null)).Wait();
var parentProjectName = Guid.NewGuid().ToString();
var parentProject = new Project(parentProjectName);
client.Projects.AddAsync(parentProject).Wait();

client.Projects.MoveAsync(new MoveArgument(project.Id, parentProject.Id)).Wait();

client.Projects.DeleteAsync(project.Id).Wait();
client.Projects.DeleteAsync(parentProject.Id).Wait();
}

[Fact]
Expand Down
9 changes: 7 additions & 2 deletions src/Todoist.Net/Models/MoveArgument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ public class MoveArgument : BaseEntity
/// <param name="id">The identifier of moved entity.</param>
/// <param name="parentId">The parent entity identifier.</param>
/// <exception cref="T:System.ArgumentException">Entity ID is required for the operation</exception>
public MoveArgument(ComplexId id, ComplexId? parentId)
public MoveArgument(ComplexId id, ComplexId parentId)
: base(id)
{
if (id.IsEmpty)
{
throw new ArgumentException("Entity ID is required for the move operation", nameof(id));
}

if (parentId.IsEmpty)
{
throw new ArgumentException("Parent ID is required for the move operation", nameof(parentId));
}

ParentId = parentId;
}

Expand All @@ -33,6 +38,6 @@ internal MoveArgument()
/// <summary>Gets the parent entity identifier.</summary>
/// <value>The parent entity identifier.</value>
[JsonProperty("parent_id")]
public ComplexId? ParentId { get; internal set; }
public ComplexId ParentId { get; internal set; }
}
}

0 comments on commit 2dc4a37

Please sign in to comment.