feat: add Plaid transaction handling and async queue processing
- introduced new migration to add Cursor column to AccountMetadata. - updated AppDbContext model snapshot to reflect changes in the database schema. - implemented async queue processing with ChannelAsyncQueue and AsyncQueueHostedService. - created Plaid transaction handlers for added, modified, and removed transactions. - developed PlaidTransactionService and PlaidTransactionSyncer for syncing transactions. - added SyncUpdatesProcessor to handle sync updates from Plaid. - updated tests to accommodate changes in institution and account metadata handling.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
namespace FiscalOS.API.Transactions.Webhook;
|
||||
|
||||
internal static class Endpoint
|
||||
{
|
||||
private const string Route = "/webhook";
|
||||
|
||||
public static RouteHandlerBuilder MapWebhookEndpoint(this RouteGroupBuilder groupBuilder)
|
||||
{
|
||||
return groupBuilder.MapPost(Route, HandleAsync);
|
||||
}
|
||||
|
||||
private static async Task<IResult> HandleAsync(
|
||||
[FromBody] WebhookBase request,
|
||||
[FromServices] ILogger<Program> logger,
|
||||
[FromServices] IAsyncQueue<SyncUpdatesQueueItem> queue,
|
||||
CancellationToken ct
|
||||
)
|
||||
{
|
||||
logger.LogInformation(
|
||||
"Received {WebhookType} webhook with {WebhookCode} payload",
|
||||
request.WebhookType,
|
||||
request.WebhookCode
|
||||
);
|
||||
|
||||
switch (request)
|
||||
{
|
||||
case SyncUpdatesAvailableWebhook webhook:
|
||||
await queue.EnqueueAsync(new(webhook.ItemId), ct);
|
||||
logger.LogInformation(
|
||||
"Enqueued {WebhookType} webhook with {WebhookCode} payload",
|
||||
request.WebhookType,
|
||||
request.WebhookCode
|
||||
);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Results.Ok();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user