feat(api): return balance info to frontend
This commit is contained in:
@@ -22,6 +22,9 @@ internal sealed record AccountDto
|
|||||||
{
|
{
|
||||||
public string ProviderId { get; init; } = string.Empty;
|
public string ProviderId { get; init; } = string.Empty;
|
||||||
public string ProviderName { get; init; } = string.Empty;
|
public string ProviderName { get; init; } = string.Empty;
|
||||||
|
public decimal CurrentBalance { get; init; }
|
||||||
|
public decimal AvailableBalance { get; init; }
|
||||||
|
public string CurrencyCode { get; init; } = string.Empty;
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
private AccountDto()
|
private AccountDto()
|
||||||
@@ -33,7 +36,10 @@ internal sealed record AccountDto
|
|||||||
return new AccountDto
|
return new AccountDto
|
||||||
{
|
{
|
||||||
ProviderId = plaidAccount.AccountId,
|
ProviderId = plaidAccount.AccountId,
|
||||||
ProviderName = plaidAccount.Name
|
ProviderName = plaidAccount.Name,
|
||||||
|
AvailableBalance = plaidAccount.Available,
|
||||||
|
CurrentBalance = plaidAccount.Current,
|
||||||
|
CurrencyCode = plaidAccount.CurrencyCode,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,10 @@ namespace FiscalOS.API.Tests.Integration.Institutions;
|
|||||||
|
|
||||||
public class GetAvailableTests(TestApi testApi) : IntegrationTest(testApi)
|
public class GetAvailableTests(TestApi testApi) : IntegrationTest(testApi)
|
||||||
{
|
{
|
||||||
private static Uri GetAvailableUri(Guid id) => new($"/institutions/{id}/available", UriKind.Relative);
|
private static Uri GetAvailableUri(Guid id)
|
||||||
|
{
|
||||||
|
return new($"/institutions/{id}/available", UriKind.Relative);
|
||||||
|
}
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetAvailable_WhenCalledAndUnauthenticated_ItShouldReturn401WithProblemDetails()
|
public async Task GetAvailable_WhenCalledAndUnauthenticated_ItShouldReturn401WithProblemDetails()
|
||||||
{
|
{
|
||||||
@@ -46,7 +48,6 @@ public class GetAvailableTests(TestApi testApi) : IntegrationTest(testApi)
|
|||||||
|
|
||||||
context.Add(user);
|
context.Add(user);
|
||||||
await context.SaveChangesAsync(ct);
|
await context.SaveChangesAsync(ct);
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}, TestContext.Current.CancellationToken);
|
}, TestContext.Current.CancellationToken);
|
||||||
|
|
||||||
@@ -89,7 +90,6 @@ public class GetAvailableTests(TestApi testApi) : IntegrationTest(testApi)
|
|||||||
{
|
{
|
||||||
AccessToken = exchangeTokenResponse.AccessToken,
|
AccessToken = exchangeTokenResponse.AccessToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
var encryptedAccessToken = await encryptor.EncryptAsyncFor(user, exchangeTokenResponse.AccessToken, ct);
|
var encryptedAccessToken = await encryptor.EncryptAsyncFor(user, exchangeTokenResponse.AccessToken, ct);
|
||||||
var institutionMetadata = PlaidMetadata.From(institutionId, "Some Bank", encryptedAccessToken);
|
var institutionMetadata = PlaidMetadata.From(institutionId, "Some Bank", encryptedAccessToken);
|
||||||
var institution = Institution.From("Some Bank", institutionMetadata);
|
var institution = Institution.From("Some Bank", institutionMetadata);
|
||||||
@@ -99,7 +99,6 @@ public class GetAvailableTests(TestApi testApi) : IntegrationTest(testApi)
|
|||||||
context.Add(user);
|
context.Add(user);
|
||||||
context.Add(institution);
|
context.Add(institution);
|
||||||
await context.SaveChangesAsync(ct);
|
await context.SaveChangesAsync(ct);
|
||||||
|
|
||||||
return (user, institution, accountsResponse.Accounts);
|
return (user, institution, accountsResponse.Accounts);
|
||||||
}, TestContext.Current.CancellationToken);
|
}, TestContext.Current.CancellationToken);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user