fix: add events interfaces of disconnect bank account

This commit is contained in:
Ahmed Bouhuolia
2024-07-29 20:10:15 +02:00
parent acd3265e35
commit b5d570417b
2 changed files with 10 additions and 4 deletions

View File

@@ -6,7 +6,11 @@ import { PlaidClientWrapper } from '@/lib/Plaid';
import HasTenancyService from '@/services/Tenancy/TenancyService';
import UnitOfWork from '@/services/UnitOfWork';
import events from '@/subscribers/events';
import { ERRORS } from './types';
import {
ERRORS,
IBankAccountDisconnectedEventPayload,
IBankAccountDisconnectingEventPayload,
} from './types';
import { ACCOUNT_TYPE } from '@/data/AccountTypes';
@Service()
@@ -48,7 +52,8 @@ export class DisconnectBankAccount {
await this.eventPublisher.emitAsync(events.bankAccount.onDisconnecting, {
tenantId,
bankAccountId,
});
} as IBankAccountDisconnectingEventPayload);
// Remove the Plaid item from the system.
await PlaidItem.query(trx).findById(account.plaidItemId).delete();
@@ -66,7 +71,8 @@ export class DisconnectBankAccount {
await this.eventPublisher.emitAsync(events.bankAccount.onDisconnected, {
tenantId,
bankAccountId,
});
trx,
} as IBankAccountDisconnectedEventPayload);
});
}
}