Skip to content

Commit

Permalink
Add AuthenticationRequests table
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTTY committed Nov 1, 2024
1 parent 2a545d8 commit d9b077d
Show file tree
Hide file tree
Showing 10 changed files with 424 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,47 @@ public class AuthenticationRequest
/// </summary>
public string Id { get; set; }
/// <summary>
/// The ids of the accounts associated with this authentication request.
/// </summary>
public IEnumerable<string> AssociatedAccounts { get; set; }
/// <summary>
/// The status of this authentication request.
/// </summary>
public AuthenticationStatus Status { get; set; }
/// <summary>
/// A <see cref="Uri"/> which can be used to start the authentication via the third party provider.
/// </summary>
public Uri AuthenticationLink { get; set; }
/// <summary>
/// The ids of the accounts associated with this authentication request.
/// </summary>
public List<BankAccount> AssociatedAccounts { get; set; }

/// <summary>
/// Creates a new instance of <see cref="AuthenticationRequest"/>.
/// Required constructor for Ef Core.
/// </summary>
/// <param name="id">The id of this authentication request.</param>
/// <param name="status">The status of this authentication request.</param>
/// <param name="authenticationLink">A <see cref="Uri"/> which can be used to start the authentication via the third party provider.</param>
public AuthenticationRequest(string id, AuthenticationStatus status, Uri authenticationLink)
{
Id = id;
Status = status;
AuthenticationLink = authenticationLink;
AssociatedAccounts = [];
}

/// <summary>
/// Creates a new instance of <see cref="AuthenticationRequest"/>.
/// </summary>
/// <param name="id">The id of this authentication request.</param>
/// <param name="associatedAccounts">The ids of the accounts associated with this authentication request.</param>
/// <param name="status">The status of this authentication request.</param>
/// <param name="authenticationLink">A <see cref="Uri"/> which can be used to start the authentication via the third party provider.</param>
public AuthenticationRequest(string id, IEnumerable<string> associatedAccounts, AuthenticationStatus status, Uri authenticationLink)
/// <param name="associatedAccounts">The ids of the accounts associated with this authentication request.</param>
public AuthenticationRequest(string id, AuthenticationStatus status, Uri authenticationLink,
List<BankAccount> associatedAccounts)
{
Id = id;
AssociatedAccounts = associatedAccounts;
Status = status;
AuthenticationLink = authenticationLink;
AssociatedAccounts = associatedAccounts;
}
}

Expand All @@ -44,20 +60,24 @@ public enum AuthenticationStatus
/// A user action is required for the authentication to proceed.
/// </summary>
RequiresUserAction,

/// <summary>
/// The authentication is currently pending.
/// </summary>
Pending,

/// <summary>
/// The authentication was successful and associated accounts can be used.
/// </summary>
Successful,

/// <summary>
/// The authentication failed.
/// </summary>
Failed,

/// <summary>
/// The authentication has expired and is no longer valid.
/// </summary>
Expired
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
public enum ThirdPartyDataType
{
Undefined,
BankingInstitutions
BankingInstitutions,
AuthenticationRequests
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.EntityFrameworkCore;
using RobinTTY.PersonalFinanceDashboard.Core.Models;
using RobinTTY.PersonalFinanceDashboard.Infrastructure.Entities;

namespace RobinTTY.PersonalFinanceDashboard.Infrastructure;

Expand Down Expand Up @@ -29,6 +28,11 @@ public sealed class ApplicationDbContext : DbContext

public DbSet<BankAccount> BankAccounts => Set<BankAccount>();

/// <summary>
/// <see cref="DbSet{TEntity}"/> holding authentication requests of the application.
/// </summary>
public DbSet<AuthenticationRequest> AuthenticationRequests => Set<AuthenticationRequest>();

/// <summary>
/// Creates a new instance of <see cref="ApplicationDbContext"/>.
/// </summary>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using RobinTTY.PersonalFinanceDashboard.Core.Models;
using RobinTTY.PersonalFinanceDashboard.ThirdPartyDataProviders.Models;

namespace RobinTTY.PersonalFinanceDashboard.Infrastructure.EntityConfigurations;

public class
ThirdPartyDataRetrievalMetadataTypeConfiguration : IEntityTypeConfiguration<ThirdPartyDataRetrievalMetadata>
{
public void Configure(EntityTypeBuilder<ThirdPartyDataRetrievalMetadata> builder)
{
builder.HasData(
new ThirdPartyDataRetrievalMetadata(new Guid("f948e52f-ad17-44b8-9cdf-e0b952f139b3"),
ThirdPartyDataType.BankingInstitutions, ThirdPartyDataSource.GoCardless, DateTime.MinValue,
TimeSpan.FromDays(7)),
new ThirdPartyDataRetrievalMetadata(new Guid("0b53ec13-5a8c-4910-bfff-1ba06c3f3859"),
ThirdPartyDataType.AuthenticationRequests, ThirdPartyDataSource.GoCardless, DateTime.MinValue,
TimeSpan.FromDays(7))
);
}
}
Loading

0 comments on commit d9b077d

Please sign in to comment.