Skip to content

Commit

Permalink
Consumer API: Return the full identity deletion process on each put a…
Browse files Browse the repository at this point in the history
…nd post request (#641)

* feat: return full deletion process on approve

* feat: return full deletion process on cancel

* feat: return full deletion process on reject

* feat: return full deletion process on start

* fix: compiler error
  • Loading branch information
tnotheis authored May 6, 2024
1 parent 3c56584 commit ec69d13
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
using Backbone.Modules.Devices.Application.DTOs;
using Backbone.Modules.Devices.Domain.Entities.Identities;

namespace Backbone.Modules.Devices.Application.Identities.Commands.ApproveDeletionProcess;

public class ApproveDeletionProcessResponse
public class ApproveDeletionProcessResponse : IdentityDeletionProcessOverviewDTO
{
public ApproveDeletionProcessResponse(IdentityDeletionProcess deletionProcess)
public ApproveDeletionProcessResponse(IdentityDeletionProcess deletionProcess) : base(deletionProcess)
{
Id = deletionProcess.Id;
Status = deletionProcess.Status;
CreatedAt = deletionProcess.CreatedAt;
ApprovedAt = deletionProcess.ApprovedAt ?? throw new Exception($"The '{nameof(IdentityDeletionProcess.ApprovedAt)}' property of the given deletion process must not be null.");
ApprovedByDevice = deletionProcess.ApprovedByDevice ?? throw new Exception($"The '{nameof(IdentityDeletionProcess.ApprovedByDevice)}' property of the given deletion process must not be null.");
}

public string Id { get; }
public DeletionProcessStatus Status { get; }
public DateTime CreatedAt { get; }
public DateTime ApprovedAt { get; }
public string ApprovedByDevice { get; }
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
using Backbone.Modules.Devices.Domain.Entities.Identities;
using Backbone.Modules.Devices.Application.DTOs;
using Backbone.Modules.Devices.Domain.Entities.Identities;

namespace Backbone.Modules.Devices.Application.Identities.Commands.CancelDeletionProcessAsOwner;

public class CancelDeletionProcessAsOwnerResponse
public class CancelDeletionProcessAsOwnerResponse : IdentityDeletionProcessOverviewDTO
{
public CancelDeletionProcessAsOwnerResponse(IdentityDeletionProcess deletionProcess)
public CancelDeletionProcessAsOwnerResponse(IdentityDeletionProcess deletionProcess) : base(deletionProcess)
{
Id = deletionProcess.Id;
Status = deletionProcess.Status;
CancelledAt = deletionProcess.CancelledAt ?? throw new Exception($"The '{nameof(IdentityDeletionProcess.CancelledAt)}' property of the given deletion process must not be null.");
CancelledByDevice = deletionProcess.CancelledByDevice ?? throw new Exception($"The '{nameof(IdentityDeletionProcess.CancelledByDevice)}' property of the given deletion process must not be null.");
}

public string Id { get; }
public DeletionProcessStatus Status { get; }
public DateTime CancelledAt { get; }
public string CancelledByDevice { get; }
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
using Backbone.Modules.Devices.Domain.Entities.Identities;
using Backbone.Modules.Devices.Application.DTOs;
using Backbone.Modules.Devices.Domain.Entities.Identities;

namespace Backbone.Modules.Devices.Application.Identities.Commands.RejectDeletionProcess;
public class RejectDeletionProcessResponse

public class RejectDeletionProcessResponse : IdentityDeletionProcessOverviewDTO
{
public RejectDeletionProcessResponse(IdentityDeletionProcess deletionProcess)
public RejectDeletionProcessResponse(IdentityDeletionProcess deletionProcess) : base(deletionProcess)
{
Id = deletionProcess.Id;
Status = deletionProcess.Status;
RejectedAt = deletionProcess.RejectedAt ?? throw new Exception($"The '{nameof(IdentityDeletionProcess.RejectedAt)}' property of the given deletion process must not be null.");
RejectedByDevice = deletionProcess.RejectedByDevice ?? throw new Exception($"The '{nameof(IdentityDeletionProcess.RejectedByDevice)}' property of the given deletion process must not be null.");
}

public string Id { get; }
public DeletionProcessStatus Status { get; }
public DateTime RejectedAt { get; }
public string RejectedByDevice { get; }
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
using Backbone.DevelopmentKit.Identity.ValueObjects;
using Backbone.Modules.Devices.Application.DTOs;
using Backbone.Modules.Devices.Domain.Entities.Identities;

namespace Backbone.Modules.Devices.Application.Identities.Commands.StartDeletionProcessAsOwner;

public class StartDeletionProcessAsOwnerResponse
public class StartDeletionProcessAsOwnerResponse : IdentityDeletionProcessOverviewDTO
{
public StartDeletionProcessAsOwnerResponse(IdentityDeletionProcess deletionProcess)
public StartDeletionProcessAsOwnerResponse(IdentityDeletionProcess deletionProcess) : base(deletionProcess)
{
Id = deletionProcess.Id;
Status = deletionProcess.Status;
CreatedAt = deletionProcess.CreatedAt;
ApprovedAt = deletionProcess.ApprovedAt ?? throw new Exception($"The '{nameof(IdentityDeletionProcess.ApprovedAt)}' property of the given deletion process must not be null.");
ApprovedByDevice = deletionProcess.ApprovedByDevice ?? throw new Exception($"The '{nameof(IdentityDeletionProcess.ApprovedByDevice)}' property of the given deletion process must not be null.");
GracePeriodEndsAt = deletionProcess.GracePeriodEndsAt.GetValueOrDefault();
}

public string Id { get; set; }
public DeletionProcessStatus Status { get; set; }
public DateTime CreatedAt { get; set; }

public DateTime ApprovedAt { get; set; }
public DeviceId ApprovedByDevice { get; set; }

public DateTime GracePeriodEndsAt { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using static Backbone.UnitTestTools.Data.TestDataGenerator;

namespace Backbone.Modules.Devices.Application.Tests.Tests.Identities.Commands.RejectDeletionProcess;

public class HandlerTests
{
[Fact]
Expand Down Expand Up @@ -46,8 +47,6 @@ public async Task Happy_path()

response.Id.Should().Be(deletionProcess.Id);
response.Status.Should().Be(DeletionProcessStatus.Rejected);
response.RejectedAt.Should().Be(utcNow);
response.RejectedByDevice.Should().Be(device.Id);
}

[Fact]
Expand Down

0 comments on commit ec69d13

Please sign in to comment.